public function tearDown() { foreach ($this->_models as $key => $class) { $class::reset(); } Fixtures::clear('db'); }
/** * Dropping the test database */ public function tearDown() { Fixtures::clear('db'); }
/** * Prove that two distinct models each having a different connection to a different * database are working independently upon the correct databases. */ public function testSwitchingDatabaseDistinctModels() { $connection1 = $this->_connection; $connection2 = $this->_connection . '_alternative'; $connectionConfig1 = Connections::get($connection1, array('config' => true)); $connectionConfig2 = Connections::get($connection2, array('config' => true)); parent::connect($connection2); $this->skipIf(!$connectionConfig2, "The `'{$connection2}' connection is not available`."); $this->skipIf(!$this->with(array('MySql', 'PostgreSql', 'Sqlite3'))); $bothInMemory = $connectionConfig1['database'] == ':memory:'; $bothInMemory = $bothInMemory && $connectionConfig2['database'] == ':memory:'; $this->skipIf($bothInMemory, 'Cannot use two connections with in memory databases'); Fixtures::save('db_alternative'); Galleries::config(array('meta' => array('connection' => $connection1))); Images::config(array('meta' => array('connection' => $connection1))); $galleriesCountOriginal = Galleries::find('count'); $imagesCountOriginal = Images::find('count'); $gallery = Galleries::create(array('name' => 'record_in_db')); $gallery->save(); $image = Images::find('first', array('conditions' => array('id' => 1))); $image->delete(); Galleries::config(array('meta' => array('connection' => $connection2))); $expected = $galleriesCountOriginal; $result = Galleries::find('count'); $this->assertEqual($expected, $result); $expected = $imagesCountOriginal - 1; $result = Images::find('count'); $this->assertEqual($expected, $result); Fixtures::clear('db_alternative'); }
/** * Dropping the test database */ public function tearDown() { Fixtures::clear('db'); Galleries::reset(); Images::reset(); }
/** * Dropping the test database */ public function tearDown() { Comment::reset(); Image::reset(); Fixtures::clear('db'); }