/** * @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()); }
/** * @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()); }
/** * @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()); }
/** * @test */ public function deleteForDeadModelDoesNotThrowException() { $model = new Tx_Oelib_Tests_Unit_Fixtures_TestingModel(); $model->markAsDead(); $this->subject->delete($model); }
/** * @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()); }
/** * @test * @param string $status * @dataProvider uncloneableStatusDataProvider * @expectedException \BadMethodCallException */ public function cloneWithInvalidStatusThrowsException($status) { $this->subject->setLoadStatus($status); clone $this->subject; }