Skip to content

Commit

Permalink
Add a test for PR #153
Browse files Browse the repository at this point in the history
  • Loading branch information
HavokInspiration committed Nov 26, 2015
1 parent 7da0df7 commit cc48233
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/TestCase/Shell/Task/MigrationSnapshotTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function setUp()

$this->Task = $this->getMock(
'Migrations\Shell\Task\MigrationSnapshotTask',
['in', 'err', 'dispatchShell', '_stop'],
['in', 'err', 'dispatchShell', '_stop', 'findTables', 'fetchTableName'],
[$inputOutput]
);
$this->Task->name = 'Migration';
Expand All @@ -59,6 +59,21 @@ public function setUp()
$this->Task->BakeTemplate->interactive = false;
}

public function testGetTableNames()
{
$this->Task->expects($this->any())
->method('findTables')
->with('Blog')
->will($this->returnValue(['ArticlesTable.php', 'TagsTable.php']));

$this->Task->method('fetchTableName')
->will($this->onConsecutiveCalls(['articles_tags', 'articles'], ['articles_tags', 'tags']));

$results = $this->Task->getTableNames('Blog');
$expected = ['articles_tags', 'articles', 'tags'];
$this->assertEquals(array_values($expected), array_values($results));
}

public function testNotEmptySnapshot()
{
$this->Task->params['require-table'] = false;
Expand Down
1 change: 1 addition & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@
Plugin::load('Migrations', [
'path' => dirname(dirname(__FILE__)) . DS,
]);
Plugin::load('Blog');
Empty file.

0 comments on commit cc48233

Please sign in to comment.