public function setUp() { $tableName = 'user'; parent::setUp(); // table instance is always the same $this->table = self::createDefaultRecordManager()->getTable($tableName); // repository instance is always the same, too, and therefore is must be cleared in setUp() $this->repository = $this->table->getRepository(); $this->repository->clear(); $this->assertEquals($tableName, $this->repository->getTable()->getTableName()); }
/** * @param array|string $identifier * @param array|string $oldIdentifier * @throws Record\RecordException */ public function assignIdentifier($identifier, $oldIdentifier = null) { $identifierFields = $this->_table->getIdentifierFields(); $identifier = array_combine($identifierFields, (array) $identifier); if (count($identifier) != count($identifierFields)) { throw new RecordException("Identifier '" . implode(self::COMPOSITE_ID_SEPARATOR, $identifier) . "' does not match table identifier!"); } foreach ($identifier as $fieldName => $id) { $this->_data[$fieldName] = $id; } $newIdentifierAsString = implode(self::COMPOSITE_ID_SEPARATOR, $identifier); $oldIdentifierAsString = is_string($oldIdentifier) ? $oldIdentifier : implode(self::COMPOSITE_ID_SEPARATOR, $oldIdentifier); $relations = $this->_table->getRelations(); foreach ($relations as $relationName => $relation) { $relation->updateRecordIdentifier($this, $relationName, $newIdentifierAsString, $oldIdentifierAsString); } $this->_modifiedFields = array(); $this->_exists = true; $repository = $this->_table->getRepository(); $repository->refreshIdentity($this, $oldIdentifierAsString); }