/** * test reading schema with tables from another database. * * @return void */ function testSchemaReadWithCrossDatabase() { $config = new DATABASE_CONFIG(); $skip = $this->skipIf(!isset($config->test) || !isset($config->test2), '%s Primary and secondary test databases not configured, skipping cross-database ' . 'join tests.' . ' To run these tests, you must define $test and $test2 in your database configuration.'); if ($skip) { return; } $db2 =& ConnectionManager::getDataSource('test2'); $fixture = new SchemaCrossDatabaseFixture(); $fixture->create($db2); $fixture->insert($db2); $read = $this->Schema->read(array('connection' => 'test_suite', 'name' => 'TestApp', 'models' => array('SchemaCrossDatabase', 'SchemaPost'))); $this->assertTrue(isset($read['tables']['posts'])); $this->assertFalse(isset($read['tables']['cross_database']), 'Cross database should not appear'); $this->assertFalse(isset($read['tables']['missing']['cross_database']), 'Cross database should not appear'); $read = $this->Schema->read(array('connection' => 'test2', 'name' => 'TestApp', 'models' => array('SchemaCrossDatabase', 'SchemaPost'))); $this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear'); $this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear'); $this->assertTrue(isset($read['tables']['cross_database'])); $fixture->drop($db2); }
/** * test reading schema with tables from another database. * * @return void */ public function testSchemaReadWithCrossDatabase() { $config = ConnectionManager::enumConnectionObjects(); $this->skipIf(!isset($config['test']) || !isset($config['test2']), 'Primary and secondary test databases not configured, ' . 'skipping cross-database join tests. ' . 'To run these tests, you must define $test and $test2 in your database configuration.'); $db = ConnectionManager::getDataSource('test2'); $fixture = new SchemaCrossDatabaseFixture(); $fixture->create($db); $fixture->insert($db); $read = $this->Schema->read(array('connection' => 'test', 'name' => 'TestApp', 'models' => array('SchemaCrossDatabase', 'SchemaPost'))); $this->assertTrue(isset($read['tables']['posts'])); $this->assertFalse(isset($read['tables']['cross_database']), 'Cross database should not appear'); $this->assertFalse(isset($read['tables']['missing']['cross_database']), 'Cross database should not appear'); $read = $this->Schema->read(array('connection' => 'test2', 'name' => 'TestApp', 'models' => array('SchemaCrossDatabase', 'SchemaPost'))); $this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear'); $this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear'); $this->assertTrue(isset($read['tables']['cross_database'])); $fixture->drop($db); }