This completes all controller acceptance tests

This commit is contained in:
James Cole 2016-12-19 20:21:14 +01:00
parent f172151252
commit e2e54d342a
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 90 additions and 69 deletions

View File

@ -8,6 +8,8 @@
*
* See the LICENSE file for details.
*/
use FireflyIII\Support\Search\SearchInterface;
use Illuminate\Support\Collection;
/**
@ -32,9 +34,16 @@ class SearchControllerTest extends TestCase
*/
public function testIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$search = $this->mock(SearchInterface::class);
$search->shouldReceive('setLimit')->once();
$search->shouldReceive('searchTransactions')->andReturn(new Collection)->withArgs([['test']])->once();
$search->shouldReceive('searchBudgets')->andReturn(new Collection)->withArgs([['test']])->once();
$search->shouldReceive('searchTags')->andReturn(new Collection)->withArgs([['test']])->once();
$search->shouldReceive('searchCategories')->andReturn(new Collection)->withArgs([['test']])->once();
$search->shouldReceive('searchAccounts')->andReturn(new Collection)->withArgs([['test']])->once();
$this->be($this->user());
$this->call('get', route('search.index') . '?q=test');
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
}

View File

@ -8,6 +8,8 @@
*
* See the LICENSE file for details.
*/
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
/**
@ -28,97 +30,106 @@ class TagControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\TagController::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('tags.create'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TagController::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('tags.delete', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TagController::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(TagRepositoryInterface::class);
$repository->shouldReceive('destroy');
$this->be($this->user());
$this->call('post', route('tags.destroy', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\TagController::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('tags.edit', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TagController::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('tags.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TagController::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('tags.show', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TagController::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(['tags.create.url' => 'http://localhost']);
$data = [
'tag' => 'Hello new tag' . rand(999, 10000),
'tagMode' => 'nothing',
];
$this->be($this->user());
$this->call('post', route('tags.store'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\TagController::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(['tags.edit.url' => 'http://localhost']);
$data = [
'tag' => 'Hello updated tag' . rand(999, 10000),
'tagMode' => 'nothing',
];
$repository = $this->mock(TagRepositoryInterface::class);
$repository->shouldReceive('update');
$repository->shouldReceive('find')->andReturn(new Tag);
$this->be($this->user());
$this->call('post', route('tags.update', [1]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -28,61 +28,62 @@ class TransactionControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\TransactionController::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('transactions.index', ['transfer']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TransactionController::indexAll
* Implement testIndexAll().
*/
public function testIndexAll()
{
// 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('transactions.index.all', ['transfer']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TransactionController::indexByDate
* Implement testIndexByDate().
*/
public function testIndexByDate()
{
// 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('transactions.index.date', ['transfer', '2016-01-01']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TransactionController::reorder
* Implement testReorder().
*/
public function testReorder()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = [
'items' => [],
];
$this->be($this->user());
$this->call('post', route('transactions.reorder'), $data);
$this->assertResponseStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\TransactionController::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('transactions.show', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
}