Ejemplo n.º 1
0
 /**
  * @test
  */
 public function deleteForTwoDeletedRecordsReturnsTwo()
 {
     $uid1 = $this->testingFramework->createRecord('tx_phpunit_test');
     $uid2 = $this->testingFramework->createRecord('tx_phpunit_test');
     self::assertSame(2, \Tx_Phpunit_Service_Database::delete('tx_phpunit_test', 'uid IN(' . $uid1 . ',' . $uid2 . ')'));
 }
Ejemplo n.º 2
0
 /**
  * Deletes a set of records that have been added through this framework for
  * a set of tables (either the test tables or the allowed system tables).
  * For this, all records with the "is_dummy_record" flag set to 1 will be
  * deleted from all tables that have been used within this instance of the
  * testing framework.
  *
  * If you set $performDeepCleanUp to TRUE, it will go through ALL tables to
  * which the current instance of the testing framework has access. Please
  * consider well, whether you want to do this as it's a huge performance
  * issue.
  *
  * @param boolean $useSystemTables
  *        whether to clean up the system tables (TRUE) or the non-system
  *        test tables (FALSE)
  * @param boolean $performDeepCleanUp
  *        whether a deep clean up should be performed
  *
  * @return void
  */
 protected function cleanUpTableSet($useSystemTables, $performDeepCleanUp)
 {
     if ($useSystemTables) {
         $tablesToCleanUp = $performDeepCleanUp ? $this->allowedSystemTables : $this->dirtySystemTables;
     } else {
         $tablesToCleanUp = $performDeepCleanUp ? $this->ownAllowedTables : $this->dirtyTables;
     }
     foreach ($tablesToCleanUp as $currentTable) {
         $dummyColumnName = $this->getDummyColumnName($currentTable);
         // Runs a delete query for each allowed table. A
         // "one-query-deletes-them-all" approach was tested but we did not
         // find a working solution for that.
         Tx_Phpunit_Service_Database::delete($currentTable, $dummyColumnName . ' = 1');
         // Resets the auto increment setting of the current table.
         $this->resetAutoIncrementLazily($currentTable);
     }
     // Resets the list of dirty tables.
     $this->dirtyTables = array();
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function existsExactlyOneRecordIgnoresNonDummyRecords()
 {
     Tx_Phpunit_Service_Database::insert('tx_phpunit_test', array('title' => 'foo'));
     $testResult = $this->fixture->existsExactlyOneRecord('tx_phpunit_test', 'title = "foo"');
     Tx_Phpunit_Service_Database::delete('tx_phpunit_test', 'title = "foo"');
     // We need to do this manually to not confuse the auto_increment counter
     // of the testing framework.
     $this->fixture->resetAutoIncrement('tx_phpunit_test');
     $this->assertFalse($testResult);
 }