Skip to content

Commit

Permalink
Add a test to the FixtureManager::loadSingle() method
Browse files Browse the repository at this point in the history
  • Loading branch information
HavokInspiration committed Oct 15, 2015
1 parent 61675b7 commit f9e65b0
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/TestCase/TestSuite/FixtureManagerTest.php
Expand Up @@ -156,4 +156,65 @@ public function testFixturizeInvalidType()
$test->fixtures = ['derp.derp'];
$this->manager->fixturize($test);
}

/**
* Test loading fixtures using loadSingle()
*
* @return void
*/
public function testLoadSingle()
{
$test = $this->getMock('Cake\TestSuite\TestCase');
$test->autoFixtures = false;
$test->fixtures = ['core.articles', 'core.articles_tags', 'core.tags'];
$this->manager->fixturize($test);
$this->manager->loadSingle('Articles');
$this->manager->loadSingle('Tags');
$this->manager->loadSingle('ArticlesTags');

$table = TableRegistry::get('ArticlesTags');
$results = $table->find('all')->toArray();
$schema = $table->schema();
$expectedConstraint = [
'type' => 'foreign',
'columns' => [
'tag_id'
],
'references' => [
'tags',
'id'
],
'update' => 'cascade',
'delete' => 'cascade',
'length' => []
];
$this->assertEquals($expectedConstraint, $schema->constraint('tag_id_fk'));
$this->assertCount(4, $results);

$this->manager->unload($test);

$this->manager->loadSingle('Articles');
$this->manager->loadSingle('Tags');
$this->manager->loadSingle('ArticlesTags');

$table = TableRegistry::get('ArticlesTags');
$results = $table->find('all')->toArray();
$schema = $table->schema();
$expectedConstraint = [
'type' => 'foreign',
'columns' => [
'tag_id'
],
'references' => [
'tags',
'id'
],
'update' => 'cascade',
'delete' => 'cascade',
'length' => []
];
$this->assertEquals($expectedConstraint, $schema->constraint('tag_id_fk'));
$this->assertCount(4, $results);
$this->manager->unload($test);
}
}

0 comments on commit f9e65b0

Please sign in to comment.