예제 #1
2
 /**
  * Runs the drop and create commands on the fixtures if necessary.
  *
  * @param \Cake\TestSuite\Fixture\TestFixture $fixture the fixture object to create
  * @param Connection $db the datasource instance to use
  * @param array $sources The existing tables in the datasource.
  * @param bool $drop whether drop the fixture if it is already created or not
  * @return void
  */
 protected function _setupTable(TestFixture $fixture, Connection $db, array $sources, $drop = true)
 {
     if (!empty($fixture->created) && in_array($db->configName(), $fixture->created)) {
         return;
     }
     $table = $fixture->table;
     $exists = in_array($table, $sources);
     if ($drop && $exists) {
         $fixture->drop($db);
         $fixture->create($db);
     } elseif (!$exists) {
         $fixture->create($db);
     } else {
         $fixture->created[] = $db->configName();
         $fixture->truncate($db);
     }
 }
 /**
  * Deletes all table information.
  *
  * This will only happen if the underlying table is modified in any way
  *
  * @param ConnectionInterface $db
  * @return void
  */
 public function truncate(ConnectionInterface $db)
 {
     if ($this->_tableUnmodified($db)) {
         return true;
     }
     return parent::truncate($db);
 }