コード例 #1
0
 /**
  * @test
  */
 public function sequenceGeneratorCanTakeAStringToAppendTo()
 {
     $this->factory->defineEntity('SpaceShip', array('name' => FieldDef::sequence("Gamma ")));
     $this->assertEquals('Gamma 1', $this->factory->get('SpaceShip')->getName());
     $this->assertEquals('Gamma 2', $this->factory->get('SpaceShip')->getName());
     $this->assertEquals('Gamma 3', $this->factory->get('SpaceShip')->getName());
     $this->assertEquals('Gamma 4', $this->factory->get('SpaceShip')->getName());
 }
コード例 #2
0
 public function testGetTimeFuture()
 {
     $time = new \DateTime();
     $interval = new \DateInterval('P3Y1M2D');
     $time->add($interval);
     $this->assertEquals($time->getTimestamp(), FieldDef::future()->days(2)->months(1)->years(3)->get());
     $this->assertEquals($time, FieldDef::future()->days(2)->months(1)->years(3)->get(DateIntervalHelper::DATE_TIME));
     $this->assertEquals($time->format('d-m-y'), FieldDef::future()->days(2)->months(1)->years(3)->get(DateIntervalHelper::STRING));
 }
コード例 #3
0
 /**
  * @test
  */
 public function whenTheOneSideIsASingletonItMayGetSeveralChildObjects()
 {
     $this->factory->defineEntity('SpaceShip');
     $this->factory->defineEntity('Person', array('spaceShip' => FieldDef::reference('SpaceShip')));
     $ship = $this->factory->getAsSingleton('SpaceShip');
     $p1 = $this->factory->get('Person');
     $p2 = $this->factory->get('Person');
     $this->assertTrue($ship->getCrew()->contains($p1));
     $this->assertTrue($ship->getCrew()->contains($p2));
 }
コード例 #4
0
 /**
  * @test
  */
 public function arrayElementsAreMappedToCollectionAsscociationFields()
 {
     $this->factory->defineEntity('SpaceShip');
     $this->factory->defineEntity('Person', array('spaceShip' => FieldDef::reference('SpaceShip')));
     $p1 = $this->factory->get('Person');
     $p2 = $this->factory->get('Person');
     $ship = $this->factory->get('SpaceShip', array('name' => 'Battlestar Galaxy', 'crew' => array($p1, $p2)));
     $this->assertTrue($ship->getCrew() instanceof ArrayCollection);
     $this->assertTrue($ship->getCrew()->contains($p1));
     $this->assertTrue($ship->getCrew()->contains($p2));
 }
コード例 #5
0
 private function simpleSetup()
 {
     $this->factory->defineEntity('Person', array('spaceShip' => FieldDef::reference('SpaceShip')));
     $this->factory->defineEntity('Badge', array('owner' => FieldDef::reference('Person')));
     $this->factory->defineEntity('SpaceShip');
 }
コード例 #6
0
 public function setUp()
 {
     parent::setUp();
     $this->factory->defineEntity('SpaceShip');
     $this->factory->defineEntity('Person', array('name' => 'Eve', 'spaceShip' => FieldDef::reference('SpaceShip')));
 }