Exemplo n.º 1
0
 /**
  * @test
  */
 public function removeRelationOnRealRecordNotRemovesRelation()
 {
     $uidLocal = $this->fixture->createRecord('tx_phpunit_test');
     $uidForeign = $this->fixture->createRecord('tx_phpunit_test');
     // Create a new record that looks like a real record, i.e. the
     // is_dummy_record flag is set to 0.
     Tx_Phpunit_Service_Database::insert('tx_phpunit_test_article_mm', array('uid_local' => $uidLocal, 'uid_foreign' => $uidForeign, 'is_dummy_record' => 0));
     // Runs our delete method which should NOT affect the record created
     // above.
     $this->fixture->removeRelation('tx_phpunit_test_article_mm', $uidLocal, $uidForeign);
     // Caches the value that will be tested for later. We need to use the
     // following order to make sure the test record gets deleted even if
     // this test fails:
     // 1. reads the value to test
     // 2. deletes the test record
     // 3. tests the previously read value (and possibly fails)
     $numberOfCreatedRelations = Tx_Phpunit_Service_Database::count('tx_phpunit_test_article_mm', 'uid_local = ' . $uidLocal . ' AND uid_foreign = ' . $uidForeign);
     // Deletes the record as it will not be caught by the clean up function.
     Tx_Phpunit_Service_Database::delete('tx_phpunit_test_article_mm', 'uid_local = ' . $uidLocal . ' AND uid_foreign = ' . $uidForeign . ' AND is_dummy_record = 0');
     // Checks whether the relation had been created further up.
     $this->assertSame(1, $numberOfCreatedRelations);
 }