2016-11-19 20:30:30 +01:00
|
|
|
<?php
|
2016-12-06 09:16:36 +01:00
|
|
|
/**
|
|
|
|
* RuleGroupControllerTest.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
|
|
*
|
|
|
|
* See the LICENSE file for details.
|
|
|
|
*/
|
2016-12-18 21:04:53 +01:00
|
|
|
use Carbon\Carbon;
|
|
|
|
use FireflyIII\Models\RuleGroup;
|
|
|
|
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
2016-11-19 20:30:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-10 06:54:50 +01:00
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-12-10 at 05:51:43.
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
class RuleGroupControllerTest extends TestCase
|
|
|
|
{
|
2016-11-20 07:24:18 +01:00
|
|
|
|
2016-11-19 20:30:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up the fixture, for example, opens a network connection.
|
|
|
|
* This method is called before a test is executed.
|
|
|
|
*/
|
|
|
|
public function setUp()
|
|
|
|
{
|
2016-11-20 08:30:25 +01:00
|
|
|
parent::setUp();
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
2016-12-07 19:53:41 +01:00
|
|
|
/**
|
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::create
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testCreate()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('get', route('rule-groups.create'));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('<ol class="breadcrumb">');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::delete
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testDelete()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('get', route('rule-groups.delete', [1]));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('<ol class="breadcrumb">');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::destroy
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testDestroy()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$repository = $this->mock(RuleGroupRepositoryInterface::class);
|
|
|
|
$repository->shouldReceive('destroy');
|
|
|
|
|
|
|
|
$this->session(['rule-groups.delete.url' => 'http://localhost']);
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('post', route('rule-groups.destroy', [1]));
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertSessionHas('success');
|
|
|
|
$this->assertRedirectedToRoute('index');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::down
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testDown()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('get', route('rule-groups.down', [1]));
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertRedirectedToRoute('rules.index');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::edit
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testEdit()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('get', route('rule-groups.edit', [1]));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('<ol class="breadcrumb">');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::execute
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testExecute()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$this->session(['first' => new Carbon('2010-01-01')]);
|
|
|
|
$data = [
|
|
|
|
'accounts' => [1],
|
|
|
|
'start_date' => '2010-01-02',
|
|
|
|
'end_date' => '2010-01-02',
|
|
|
|
];
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('post', route('rule-groups.execute', [1]), $data);
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertSessionHas('success');
|
|
|
|
$this->assertRedirectedToRoute('rules.index');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::selectTransactions
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testSelectTransactions()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('get', route('rule-groups.select-transactions', [1]));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('<ol class="breadcrumb">');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::store
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testStore()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$this->session(['rule-groups.create.url' => 'http://localhost']);
|
|
|
|
$data = [
|
|
|
|
'title' => 'A',
|
|
|
|
'description' => '',
|
|
|
|
];
|
|
|
|
|
|
|
|
$repository = $this->mock(RuleGroupRepositoryInterface::class);
|
|
|
|
$repository->shouldReceive('store')->andReturn(new RuleGroup);
|
|
|
|
$repository->shouldReceive('find')->andReturn(new RuleGroup);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('post', route('rule-groups.store', [1]), $data);
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertSessionHas('success');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::up
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testUp()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('get', route('rule-groups.up', [1]));
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertRedirectedToRoute('rules.index');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\RuleGroupController::update
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testUpdate()
|
|
|
|
{
|
2016-12-18 21:04:53 +01:00
|
|
|
$data = [
|
|
|
|
'title' => 'C',
|
|
|
|
'description' => 'XX',
|
|
|
|
];
|
|
|
|
$this->session(['rule-groups.edit.url' => 'http://localhost']);
|
|
|
|
|
|
|
|
$repository = $this->mock(RuleGroupRepositoryInterface::class);
|
|
|
|
$repository->shouldReceive('update');
|
|
|
|
$repository->shouldReceive('find')->andReturn(new RuleGroup);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('post', route('rule-groups.update', [1]), $data);
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertSessionHas('success');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
}
|