/**
  * Resets the auto increment value for a given table to the highest existing
  * UID + 1 if the current auto increment value is higher than a certain
  * threshold over the current maximum UID.
  *
  * The threshold is 100 by default and can be set using
  * setResetAutoIncrementThreshold.
  *
  * @param string $tableName
  *        the name of the table on which we're going to reset the auto
  *        increment entry, must not be empty
  *
  * @see resetAutoIncrement
  *
  * @return void
  *
  * @throws InvalidArgumentException
  */
 public function resetAutoIncrementLazily($tableName)
 {
     if (!$this->isTableNameAllowed($tableName)) {
         throw new InvalidArgumentException('The given table name is invalid. This means it is either empty or not in the list of allowed tables.', 1334439548);
     }
     // Checks whether the current table qualifies for this method. If there
     // is no column "uid" that has the "auto_increment" flag set, we should
     // not try to reset this inexistent auto increment index to avoid
     // database errors.
     if (!Tx_Phpunit_Service_Database::tableHasColumnUid($tableName)) {
         return;
     }
     if ($this->getAutoIncrement($tableName) > $this->getMaximumUidFromTable($tableName) + $this->resetAutoIncrementThreshold) {
         $this->resetAutoIncrement($tableName);
     }
 }
Exemple #2
0
 /**
  * @test
  */
 public function tableHasColumnUidCanReturnDifferentResultsForDifferentTables()
 {
     self::assertNotEquals(\Tx_Phpunit_Service_Database::tableHasColumnUid('tx_phpunit_test'), \Tx_Phpunit_Service_Database::tableHasColumnUid('tx_phpunit_test_article_mm'));
 }