/**
  * test init with a model that has a tablePrefix declared.
  *
  * @return void
  */
 public function testInitModelTablePrefix()
 {
     $this->skipIf($this->db instanceof Sqlite, 'Cannot open 2 connections to Sqlite');
     $this->skipIf(!empty($this->db->config['prefix']), 'Cannot run this test, you have a database connection prefix.');
     $Source = new CakeTestFixtureTestFixture();
     $Source->create($this->db);
     $Source->insert($this->db);
     $Fixture = new CakeTestFixtureTestFixture();
     unset($Fixture->table);
     $Fixture->fields = $Fixture->records = null;
     $Fixture->import = array('model' => 'FixturePrefixTest', 'connection' => 'test', 'records' => false);
     $Fixture->init();
     $this->assertEquals('fixture_tests', $Fixture->table);
     $keys = array_flip(ClassRegistry::keys());
     $this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
     $Source->drop($this->db);
 }
예제 #2
0
 /**
  * testInit
  *
  * @access public
  * @return void
  */
 function testInit()
 {
     $Fixture = new CakeTestFixtureTestFixture();
     unset($Fixture->table);
     $Fixture->init();
     $this->assertEqual($Fixture->table, 'fixture_tests');
     $this->assertEqual($Fixture->primaryKey, 'id');
     $Fixture = new CakeTestFixtureTestFixture();
     $Fixture->primaryKey = 'my_random_key';
     $Fixture->init();
     $this->assertEqual($Fixture->primaryKey, 'my_random_key');
     $this->_initDb();
     $Source = new CakeTestFixtureTestFixture();
     $Source->create($this->db);
     $Source->insert($this->db);
     $Fixture = new CakeTestFixtureImportFixture();
     $expected = array('id', 'name', 'created');
     $this->assertEqual(array_keys($Fixture->fields), $expected);
     $db = ConnectionManager::getDataSource('test_suite');
     $config = $db->config;
     $config['prefix'] = 'fixture_test_suite_';
     ConnectionManager::create('fixture_test_suite', $config);
     $Fixture->fields = $Fixture->records = null;
     $Fixture->import = array('table' => 'fixture_tests', 'connection' => 'test_suite', 'records' => true);
     $Fixture->init();
     $this->assertEqual(count($Fixture->records), count($Source->records));
     $Fixture = new CakeTestFixtureImportFixture();
     $Fixture->fields = $Fixture->records = null;
     $Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test_suite');
     $Fixture->init();
     $this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
     $keys = array_flip(ClassRegistry::keys());
     $this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
     $Source->drop($this->db);
 }