예제 #1
0
 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);
 }
예제 #2
0
 /**
  * @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());
 }
예제 #3
0
 /**
  * @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());
 }