/** * @test */ public function removeRelationOnRealRecordNotRemovesRelation() { $uidLocal = $this->subject->createRecord('tx_oelib_test'); $uidForeign = $this->subject->createRecord('tx_oelib_test'); // Create a new record that looks like a real record, i.e. the // is_dummy_record flag is set to 0. Tx_Oelib_Db::insert('tx_oelib_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->subject->removeRelation('tx_oelib_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_Oelib_Db::count('tx_oelib_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_Oelib_Db::delete('tx_oelib_test_article_mm', 'uid_local = ' . $uidLocal . ' AND uid_foreign = ' . $uidForeign . ' AND is_dummy_record = 0'); // Checks whether the relation had been created further up. self::assertSame(1, $numberOfCreatedRelations); }