Example #1
0
 /**
  * @test
  */
 public function saveForModelWith1NRelationSavesNewRelatedRecordWithPrefixInForeignKey()
 {
     /** @var Tx_Oelib_Tests_Unit_Fixtures_TestingModel $model */
     $model = $this->subject->find($this->testingFramework->createRecord('tx_oelib_test'));
     $model->setTitle('bar');
     $component = new Tx_Oelib_Tests_Unit_Fixtures_TestingChildModel();
     $component->markAsDummyModel();
     $model->getComposition2()->add($component);
     $this->subject->save($model);
     self::assertTrue($this->testingFramework->existsRecord('tx_oelib_testchild', 'uid = ' . $component->getUid() . ' AND tx_oelib_parent2 = ' . $model->getUid()));
 }
Example #2
0
 /**
  * @test
  */
 public function clonedModelHas1toNRelationWithCloneAsParentModel()
 {
     $childRecord = new Tx_Oelib_Tests_Unit_Fixtures_TestingChildModel();
     $childRecord->setData(array());
     $this->subject->addCompositionRecord($childRecord);
     $this->dataMapper->save($this->subject);
     self::assertSame($this->subject, $this->subject->getRelatedRecords()->getParentModel());
     $clone = clone $this->subject;
     self::assertSame($clone, $clone->getComposition()->getParentModel());
 }
Example #3
0
 /**
  * @test
  */
 public function sortBySortingMovesItemWithHigherSortingValueAfterItemWithLowerSortingValue()
 {
     $model1 = new Tx_Oelib_Tests_Unit_Fixtures_TestingChildModel();
     $model1->setSorting(2);
     $this->subject->add($model1);
     $model2 = new Tx_Oelib_Tests_Unit_Fixtures_TestingChildModel();
     $model2->setSorting(1);
     $this->subject->add($model2);
     $this->subject->sortBySorting();
     self::assertSame($model2, $this->subject->first());
 }