/**
  * Verifies that stopping propagation within a listener in the hydrator allows modifying how the
  * hydrator behaves
  */
 public function testStoppedPropagationInExtraction()
 {
     $object = new ArrayObject(array('president' => 'Zaphod'));
     $callback = function (ExtractEvent $event) {
         $event->setExtractedData(array('Ravenous Bugblatter Beast of Traal'));
         $event->stopPropagation();
     };
     $this->hydrator->add(new ArraySerializable());
     $this->hydrator->getEventManager()->attach(ExtractEvent::EVENT_EXTRACT, $callback, 1000);
     $this->assertSame(array('Ravenous Bugblatter Beast of Traal'), $this->hydrator->extract($object));
 }
Exemplo n.º 2
0
 /**
  * @covers \Zend\Stdlib\Hydrator\Aggregate\AggregateHydrator::extract
  */
 public function testExtract()
 {
     $object = new stdClass();
     $this->eventManager->expects($this->once())->method('trigger')->with($this->isInstanceOf('Zend\\Stdlib\\Hydrator\\Aggregate\\ExtractEvent'));
     $this->assertSame(array(), $this->hydrator->extract($object));
 }