More tests

This commit is contained in:
James Cole
2016-12-11 14:03:30 +01:00
parent dc28ba42ef
commit 74e01a52b9
6 changed files with 307 additions and 214 deletions

View File

@@ -8,6 +8,7 @@
*
* See the LICENSE file for details.
*/
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
/**
@@ -28,165 +29,193 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::amount
* Implement testAmount().
*/
public function testAmount()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = [
'amount' => 200,
];
$this->be($this->user());
$this->call('post', route('budgets.amount', [1], $data));
$this->assertResponseStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::create
* Implement testCreate().
*/
public function testCreate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('budgets.create'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::delete
* Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('budgets.delete', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::destroy
* Implement testDestroy().
*/
public function testDestroy()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->session(['budgets.delete.url' => 'http://localhost']);
$repository = $this->mock(BudgetRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$this->be($this->user());
$this->call('post', route('budgets.destroy', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::edit
* Implement testEdit().
*/
public function testEdit()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('budgets.edit', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::index
* Implement testIndex().
* @covers \FireflyIII\Http\Controllers\BudgetController::index
* @dataProvider dateRangeProvider
*/
public function testIndex()
public function testIndex(string $range)
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('budgets.index'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::noBudget
* Implement testNoBudget().
* @covers \FireflyIII\Http\Controllers\BudgetController::noBudget
* @dataProvider dateRangeProvider
*/
public function testNoBudget()
public function testNoBudget(string $range)
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('budgets.no-budget'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::postUpdateIncome
* Implement testPostUpdateIncome().
*/
public function testPostUpdateIncome()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = [
'amount' => 200,
];
$this->be($this->user());
$this->call('post', route('budgets.income.post', [1]), $data);
$this->assertResponseStatus(302);
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::show
* Implement testShow().
* @covers \FireflyIII\Http\Controllers\BudgetController::show
* @dataProvider dateRangeProvider
*/
public function testShow()
public function testShow(string $range)
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('budgets.show', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::showByRepetition
* Implement testShowByRepetition().
* @covers \FireflyIII\Http\Controllers\BudgetController::showByRepetition
* @dataProvider dateRangeProvider
*/
public function testShowByRepetition()
public function testShowByRepetition(string $range)
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('budgets.show.repetition', [1, 1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::store
* Implement testStore().
*/
public function testStore()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->session(['budgets.create.url' => 'http://localhost']);
$data = [
'name' => 'New Budget ' . rand(1000, 9999),
];
$this->be($this->user());
$this->call('post', route('budgets.store'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// must be in list
$this->be($this->user());
$this->call('GET', route('budgets.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
$this->see($data['name']);
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::update
* Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->session(['budgets.edit.url' => 'http://localhost']);
$data = [
'name' => 'Updated Budget ' . rand(1000, 9999),
'active' => 1,
];
$this->be($this->user());
$this->call('post', route('budgets.update', [1]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// must be in list
$this->be($this->user());
$this->call('GET', route('budgets.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
$this->see($data['name']);
}
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::updateIncome
* Implement testUpdateIncome().
*/
public function testUpdateIncome()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
// must be in list
$this->be($this->user());
$this->call('GET', route('budgets.income', [1]));
$this->assertResponseStatus(200);
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
}