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,8 @@
*
* See the LICENSE file for details.
*/
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use Illuminate\Support\Collection;
/**
@@ -28,117 +30,150 @@ class BillControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BillController::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('bills.create'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::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('bills.delete', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::destroy
* Implement testDestroy().
*/
public function testDestroy()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$this->session(['bills.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('post', route('bills.destroy', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::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('bills.edit', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::index
* Implement testIndex().
*/
public function testIndex()
{
// 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('bills.index'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::rescan
* Implement testRescan().
*/
public function testRescan()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('getPossiblyRelatedJournals')->once()->andReturn(new Collection);
$this->be($this->user());
$this->call('GET', route('bills.rescan', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::show
* Implement testShow().
*/
public function testShow()
{
// 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('bills.show', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::store
* Implement testStore().
*/
public function testStore()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = [
'name' => 'New Bill ' . rand(1000, 9999),
'match' => 'some words',
'amount_min' => 100,
'amount_currency_id_amount_min' => 1,
'amount_currency_id_amount_max' => 1,
'skip' => 0,
'amount_max' => 100,
'date' => '2016-01-01',
'repeat_freq' => 'monthly',
];
$this->session(['bills.create.url' => 'http://localhost']);
$this->be($this->user());
$this->call('post', route('bills.store'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// list must be updated
$this->be($this->user());
$this->call('GET', route('bills.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
$this->see($data['name']);
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::update
* Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = [
'name' => 'Updated Bill ' . rand(1000, 9999),
'match' => 'some more words',
'amount_min' => 100,
'amount_currency_id_amount_min' => 1,
'amount_currency_id_amount_max' => 1,
'skip' => 0,
'amount_max' => 100,
'date' => '2016-01-01',
'repeat_freq' => 'monthly',
];
$this->session(['bills.edit.url' => 'http://localhost']);
$this->be($this->user());
$this->call('post', route('bills.update', [1]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// list must be updated
$this->be($this->user());
$this->call('GET', route('bills.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
$this->see($data['name']);
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
}