/**
  * @test
  * @dataProvider data_getSubscribedSystems
  */
 public function test_getSubscribedSystems($event, $hasListeners, array $doc, array $lc, $expected)
 {
     $md = new ClassMetadata('Test');
     $md->documentListeners = $doc;
     $md->lifecycleCallbacks = $lc;
     /** @var EventManager|ObjectProphecy $em */
     $em = $this->prophesize(EventManager::class);
     $em->hasListeners(Arg::any())->willReturn($hasListeners);
     $lr = $this->prophesize(ListenerResolverInterface::class);
     $li = new ListenersInvoker($em->reveal(), $lr->reveal());
     $actual = $li->getSubscribedSystems($md, $event);
     $this->assertEquals($expected, $actual);
     $actual = $li->getSubscribedSystems2($md, $event);
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 /**
  * Computes the changes that happened to a single document.
  *
  * Modifies/populates the following properties:
  *
  * {@link originalDocumentData}
  * If the document is NEW or MANAGED but not yet fully persisted (only has an id)
  * then it was not fetched from the database and therefore we have no original
  * document data yet. All of the current document data is stored as the original document data.
  *
  * {@link documentChangeSets}
  * The changes detected on all properties of the document are stored there.
  * A change is a tuple array where the first entry is the old value and the second
  * entry is the new value of the property. Changesets are used by persisters
  * to INSERT/UPDATE the persistent document state.
  *
  * {@link documentUpdates}
  * If the document is already fully MANAGED (has been fetched from the database before)
  * and any changes to its properties are detected, then a reference to the document is stored
  * there to mark it for an update.
  *
  * @param ClassMetadata $class    The class descriptor of the document.
  * @param object        $document The document for which to compute the changes.
  */
 public function computeChangeSet(ClassMetadata $class, $document)
 {
     $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preFlush) & ~ListenersInvoker::INVOKE_MANAGER;
     if ($invoke !== ListenersInvoker::INVOKE_NONE) {
         $this->listenersInvoker->invoke($class, Events::preFlush, $document, new PreFlushEventArgs($this->dm), $invoke);
     }
     $this->computeOrRecomputeChangeSet($class, $document);
 }
 /**
  * @iterations 10000
  */
 public function getSubscribedSystems2_short()
 {
     $this->li->getSubscribedSystems2($this->md, Events::prePersist);
 }