mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding tests for r7867
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7868 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
910be6e368
commit
f8b69b10e2
1 changed files with 52 additions and 4 deletions
|
@ -84,11 +84,26 @@ class CakeTestFixtureImportFixture extends CakeTestFixture {
|
|||
/**
|
||||
* Import property
|
||||
*
|
||||
* @var array
|
||||
* @var mixed
|
||||
*/
|
||||
var $import = array('table' => 'fixture_tests', 'connection' => 'test_suite');
|
||||
}
|
||||
|
||||
/**
|
||||
* Import Fixture Test Fixture
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.tests.cases.libs
|
||||
*/
|
||||
class CakeTestFixtureDefaultImportFixture extends CakeTestFixture {
|
||||
/**
|
||||
* Name property
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $name = 'ImportFixture';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixture Test Case Model
|
||||
*
|
||||
|
@ -110,7 +125,6 @@ Mock::generate('DboSource', 'FixtureMockDboSource');
|
|||
* @subpackage cake.cake.tests.cases.libs
|
||||
*/
|
||||
class CakeTestFixtureTest extends CakeTestCase {
|
||||
|
||||
function setUp() {
|
||||
$this->criticDb =& new FixtureMockDboSource();
|
||||
$this->criticDb->fullDebug = true;
|
||||
|
@ -158,12 +172,46 @@ class CakeTestFixtureTest extends CakeTestCase {
|
|||
$Fixture->init();
|
||||
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
|
||||
|
||||
//assert that model has been removed from registry, stops infinite loops.
|
||||
$keys = array_flip(ClassRegistry::keys());
|
||||
$this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
|
||||
|
||||
$Source->drop($this->db);
|
||||
}
|
||||
/**
|
||||
* testImport
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testImport() {
|
||||
$this->_initDb();
|
||||
|
||||
$defaultDb =& ConnectionManager::getDataSource('default');
|
||||
$testSuiteDb =& ConnectionManager::getDataSource('test_suite');
|
||||
$defaultConfig = $defaultDb->config;
|
||||
$testSuiteConfig = $testSuiteDb->config;
|
||||
ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix'])));
|
||||
$newTestSuiteDb =& ConnectionManager::getDataSource('new_test_suite');
|
||||
|
||||
$Source =& new CakeTestFixtureTestFixture();
|
||||
$Source->create($newTestSuiteDb);
|
||||
$Source->insert($newTestSuiteDb);
|
||||
|
||||
$defaultDb->config = $newTestSuiteDb->config;
|
||||
|
||||
$Fixture =& new CakeTestFixtureDefaultImportFixture();
|
||||
$Fixture->fields = $Fixture->records = null;
|
||||
$Fixture->import = 'FixtureImportTestModel';
|
||||
$Fixture->init();
|
||||
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
|
||||
|
||||
$defaultDb->config = $defaultConfig;
|
||||
|
||||
$keys = array_flip(ClassRegistry::keys());
|
||||
$this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
|
||||
|
||||
$Source->drop($newTestSuiteDb);
|
||||
}
|
||||
/**
|
||||
* test create method
|
||||
*
|
||||
|
@ -237,4 +285,4 @@ class CakeTestFixtureTest extends CakeTestCase {
|
|||
unset($this->criticDb);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue