Files
firefly-iii/tests/acceptance/Controllers/RuleGroupControllerTest.php
James Cole 83b404d01e More tests.
2016-12-18 21:04:53 +01:00

174 lines
5.1 KiB
PHP

<?php
/**
* 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.
*/
use Carbon\Carbon;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-12-10 at 05:51:43.
*/
class RuleGroupControllerTest extends TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::create
*/
public function testCreate()
{
$this->be($this->user());
$this->call('get', route('rule-groups.create'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('get', route('rule-groups.delete', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::destroy
*/
public function testDestroy()
{
$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');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::down
*/
public function testDown()
{
$this->be($this->user());
$this->call('get', route('rule-groups.down', [1]));
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('rules.index');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('get', route('rule-groups.edit', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::execute
*/
public function testExecute()
{
$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');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::selectTransactions
*/
public function testSelectTransactions()
{
$this->be($this->user());
$this->call('get', route('rule-groups.select-transactions', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::store
*/
public function testStore()
{
$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');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::up
*/
public function testUp()
{
$this->be($this->user());
$this->call('get', route('rule-groups.up', [1]));
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('rules.index');
}
/**
* @covers \FireflyIII\Http\Controllers\RuleGroupController::update
*/
public function testUpdate()
{
$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');
}
}