/** * @test */ public function getTcaForTableCanLoadFieldsAddedByExtensions() { $tca = \Tx_Phpunit_Service_Database::getTcaForTable('fe_users'); self::assertTrue(isset($tca['columns']['tx_phpunit_is_dummy_record'])); }
/** * Creates a relation between two records based on the rules defined in TCA * regarding the relation. * * @param string $tableName * name of the table from which a relation should be created, must * not be empty * @param integer $uidLocal * UID of the record in the local table, must be > 0 * @param integer $uidForeign * UID of the record in the foreign table, must be > 0 * @param string $columnName * name of the column in which the relation counter should be * updated, must not be empty * * @return void * * @throws InvalidArgumentException * @throws t3lib_exception */ public function createRelationAndUpdateCounter($tableName, $uidLocal, $uidForeign, $columnName) { if (!$this->isTableNameAllowed($tableName)) { throw new InvalidArgumentException('The table name "' . $tableName . '" is not allowed.'); } if ($uidLocal <= 0) { throw new InvalidArgumentException('$uidLocal must be > 0, but actually is "' . $uidLocal . '"', 1334439220); } if ($uidForeign <= 0) { throw new InvalidArgumentException('$uidForeign must be > 0, but actually is "' . $uidForeign . '"', 1334439233); } $tca = Tx_Phpunit_Service_Database::getTcaForTable($tableName); $relationConfiguration = $tca['columns'][$columnName]; if (!isset($relationConfiguration['config']['MM']) || $relationConfiguration['config']['MM'] === '') { throw new t3lib_exception('The column ' . $columnName . ' in the table ' . $tableName . ' is not configured to contain m:n relations using a m:n table.', 1334439257); } if (!isset($relationConfiguration['config']['MM_opposite_field'])) { $this->createRelation($relationConfiguration['config']['MM'], $uidLocal, $uidForeign); } else { // Switches the order of $uidForeign and $uidLocal as the relation // is the reverse part of a bidirectional relation. $this->createRelationAndUpdateCounter($relationConfiguration['config']['foreign_table'], $uidForeign, $uidLocal, $relationConfiguration['config']['MM_opposite_field']); } $this->increaseRelationCounter($tableName, $uidLocal, $columnName); }
/** * @test */ public function getTcaForTableCanLoadFieldsAddedByExtensions() { if (!t3lib_extMgm::isLoaded('sr_feuser_register')) { $this->markTestSkipped('This test is only applicable if sr_feuser_register is loaded.'); } $tca = Tx_Phpunit_Service_Database::getTcaForTable('fe_users'); $this->assertTrue(isset($tca['columns']['gender'])); }