/** * @test */ public function insertForTableWithoutUidReturnsZero() { $this->testingFramework->markTableAsDirty('tx_phpunit_test_article_mm'); self::assertSame(0, \Tx_Phpunit_Service_Database::insert('tx_phpunit_test_article_mm', array('is_dummy_record' => 1))); }
/** * Creates a relation between two records on different tables (so called * m:n relation). * * @param string $tableName * name of the m:n table to which the record should be added, must * not be empty * @param integer $uidLocal * UID of the local table, must be > 0 * @param integer $uidForeign * UID of the foreign table, must be > 0 * @param integer $sorting * sorting value of the relation, the default value is 0, which * enables automatic sorting, a value >= 0 overwrites the automatic * sorting * * @return void * * @throws InvalidArgumentException */ public function createRelation($tableName, $uidLocal, $uidForeign, $sorting = 0) { if (!$this->isNoneSystemTableNameAllowed($tableName)) { throw new InvalidArgumentException('The table name "' . $tableName . '" is not allowed.', 1334439196); } // Checks that the two given UIDs are valid. if (intval($uidLocal) <= 0) { throw new InvalidArgumentException('$uidLocal must be an integer > 0, but actually is "' . $uidLocal . '"', 1334439206); } if (intval($uidForeign) <= 0) { throw new InvalidArgumentException('$uidForeign must be an integer > 0, but actually is "' . $uidForeign . '"', 1334439213); } $this->markTableAsDirty($tableName); $recordData = array('uid_local' => $uidLocal, 'uid_foreign' => $uidForeign, 'sorting' => $sorting > 0 ? $sorting : $this->getRelationSorting($tableName, $uidLocal), $this->getDummyColumnName($tableName) => 1); Tx_Phpunit_Service_Database::insert($tableName, $recordData); }
/** * @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); }