示例#1
0
 /**
  * @test
  */
 public function loadWithModelWithExistingUidFillsModelWithData()
 {
     $title = 'Assassin of Kings';
     $uid = $this->testingFramework->createRecord('tx_oelib_test', array('title' => $title));
     $model = new Tx_Oelib_Tests_Unit_Fixtures_TestingModel();
     $model->setUid($uid);
     $this->subject->load($model);
     self::assertSame($title, $model->getTitle());
 }
示例#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());
 }
示例#3
0
 /**
  * @test
  */
 public function getNewUidForMapWithTwoItemsInReverseOrderReturnsUidGreaterThanTheGreatesUid()
 {
     $model2 = new Tx_Oelib_Tests_Unit_Fixtures_TestingModel();
     $model2->setUid(2);
     $this->subject->add($model2);
     $model1 = new Tx_Oelib_Tests_Unit_Fixtures_TestingModel();
     $model1->setUid(1);
     $this->subject->add($model1);
     self::assertGreaterThan(2, $this->subject->getNewUid());
 }
示例#4
0
 /**
  * @test
  */
 public function deleteForDeadModelDoesNotThrowException()
 {
     $model = new Tx_Oelib_Tests_Unit_Fixtures_TestingModel();
     $model->markAsDead();
     $this->subject->delete($model);
 }
示例#5
0
 /**
  * @test
  */
 public function addWithoutParentModelMarksParentModelAsDirty()
 {
     $parentModel = new Tx_Oelib_Tests_Unit_Fixtures_TestingModel();
     self::assertFalse($parentModel->isDirty());
     $this->subject->setParentModel($parentModel);
     $model = new Tx_Oelib_Tests_Unit_Fixtures_TestingModel();
     $this->subject->add($model);
     self::assertTrue($parentModel->isDirty());
 }
示例#6
0
 /**
  * @test
  * @param string $status
  * @dataProvider uncloneableStatusDataProvider
  * @expectedException \BadMethodCallException
  */
 public function cloneWithInvalidStatusThrowsException($status)
 {
     $this->subject->setLoadStatus($status);
     clone $this->subject;
 }