protected function setUp() { $this->testingFramework = new Tx_Oelib_TestingFramework('tx_oelib'); Tx_Oelib_MapperRegistry::getInstance()->activateTestingMode($this->testingFramework); $this->dataMapper = Tx_Oelib_MapperRegistry::get('Tx_Oelib_Tests_Unit_Fixtures_TestingMapper'); $uid = $this->createTestRecord(); $this->subject = $this->dataMapper->find($uid); }
/** * @test */ public function oneToManyRelationsWithOneRelatedModelReturnsListWithRelatedModelWithData() { $relatedTitle = 'Triss Merrigold'; $uid = $this->testingFramework->createRecord('tx_oelib_test', array('composition' => 1)); $this->testingFramework->createRecord('tx_oelib_testchild', array('parent' => $uid, 'title' => $relatedTitle)); /** @var Tx_Oelib_Tests_Unit_Fixtures_TestingModel $model */ $model = $this->subject->find($uid); /** @var Tx_Oelib_Tests_Unit_Fixtures_TestingModel $firstChildModel */ $firstChildModel = $model->getComposition()->first(); self::assertSame($relatedTitle, $firstChildModel->getTitle()); }
/** * @test */ public function findAllByRelationIgnoresIgnoreList() { $model = $this->subject->find($this->testingFramework->createRecord('tx_oelib_test')); $mapper = Tx_Oelib_MapperRegistry::get('tx_oelib_Tests_Unit_Fixtures_TestingChildMapper'); $relatedModel = $mapper->find($this->testingFramework->createRecord('tx_oelib_testchild', array('parent' => $model->getUid()))); $ignoredRelatedModel = $mapper->find($this->testingFramework->createRecord('tx_oelib_testchild', array('parent' => $model->getUid()))); $ignoreList = new Tx_Oelib_List(); $ignoreList->add($ignoredRelatedModel); $result = Tx_Oelib_MapperRegistry::get('tx_oelib_Tests_Unit_Fixtures_TestingChildMapper')->findAllByRelation($model, 'parent', $ignoreList); self::assertSame(1, $result->count()); self::assertSame($relatedModel, $result->first()); }