Inheritance: use trait NameTrait
Example #1
0
 /**
  * @dataProvider entityManagerDataProvider
  * @param EntityManager $em
  */
 public function testComplexSerialisation(EntityManager $em)
 {
     $serialiser = new JsonSerialiser();
     $time = new \DateTime();
     $product = new Product();
     $product->setCreateTime($time);
     $metadata = $em->getMapper()->getEntityMetadata($product);
     $data = $serialiser->serialise($metadata, $product);
     $new_product = new Product();
     $serialiser->deserialise($metadata, $data, $new_product);
     $this->assertEquals($time->format(self::DATE_FORMAT), $new_product->getCreateTime()->format(self::DATE_FORMAT));
 }
Example #2
0
 /**
  * @dataProvider getCacheServices
  * @param EntityCachingInterface $service
  */
 public function testStrategy(EntityCachingInterface $service)
 {
     $product = new Product();
     $product->setId(1234);
     $this->assertFalse($service->exists(Product::class, 1234));
     $service->store(Product::class, '1234', $product);
     $this->assertTrue($service->exists(Product::class, 1234));
     $r = $service->retrieve(Product::class, '1234');
     $service->purge(Product::class, '1234');
     $this->assertFalse($service->exists(Product::class, 1234));
     $this->assertEquals(1234, $r->getId());
 }
Example #3
0
 /**
  * @dataProvider entityManagerDataProvider
  * @param EntityManager $em
  */
 public function testRebuildSchema(EntityManager $em)
 {
     $create_time = new \DateTime("2015-01-01 12:15:03+0000");
     $product = new Product();
     $product->setId(333)->setName('Test Product')->setDescription("lorem ipsum")->setActive(true)->setCreateTime($create_time)->setPrice(12.45);
     $em->persist($product);
     $em->flush();
     // Rebuild and remove a property
     $maintenance = new Maintenance($em);
     $maintenance->rebuild(ProductLess::class);
     $p1 = $em->retrieve(ProductLess::class, '333', false);
     $this->assertEquals('Test Product', $p1->getName());
     $p2 = $em->retrieve(Product::class, '333', false);
     $this->assertEquals('Test Product', $p2->getName());
     $this->assertEmpty($p2->getDescription());
     // Rebuild and add a property
     $maintenance = new Maintenance($em);
     $maintenance->rebuild(ProductMore::class);
     $p3 = $em->retrieve(ProductMore::class, '333', false);
     $this->assertEquals('Test Product', $p3->getName());
     $this->assertEmpty($p3->getShortDescription());
     $p4 = $em->retrieve(Product::class, '333', false);
     $this->assertEquals('Test Product', $p4->getName());
 }
Example #4
0
 /**
  * @dataProvider entityManagerDataProvider
  * @param EntityManager $em
  */
 public function testNullObjectSerialisation(EntityManager $em)
 {
     $product = new Product();
     $product->setId(701)->setEnum(null);
     $em->persist($product)->flush();
     /** @var Product $r_product */
     $r_product = $em->retrieve(Product::class, '701');
     $this->assertNull($r_product->getEnum());
 }