示例#1
0
 public function testHydratingObjects()
 {
     $this->hydrator->addStrategy('entities', new TestAsset\HydratorStrategy());
     $entityA = new TestAsset\HydratorStrategyEntityA();
     $entityA->addEntity(new TestAsset\HydratorStrategyEntityB(111, 'AAA'));
     $entityA->addEntity(new TestAsset\HydratorStrategyEntityB(222, 'BBB'));
     $attributes = $this->hydrator->extract($entityA);
     $attributes['entities'][] = 333;
     $this->hydrator->hydrate($attributes, $entityA);
     $entities = $entityA->getEntities();
     $this->assertCount(3, $entities);
 }
示例#2
0
 public function testContextAwarenessHydrate()
 {
     $strategy = new TestAsset\HydratorStrategyContextAware();
     $this->hydrator->addStrategy('field2', $strategy);
     $entityB = new TestAsset\HydratorStrategyEntityB('X', 'Y');
     $data = array('field1' => 'A', 'field2' => 'B');
     $attributes = $this->hydrator->hydrate($data, $entityB);
     $this->assertEquals($data, $strategy->data);
 }
 /**
  * InvoiceHydrator constructor.
  * @param HydratorInterface         $wrappedHydrator
  * @param OrderRepositoryInterface  $orderRepository
  */
 public function __construct(HydratorInterface $wrappedHydrator, OrderRepositoryInterface $orderRepository)
 {
     $this->wrappedHydrator = $wrappedHydrator;
     $this->wrappedHydrator->addStrategy('invoice_date', new DateStrategy());
     $this->orderRepository = $orderRepository;
 }