/**
  * Will figure out if a reference is still scheduled inside the UoW or just mapped
  * as an referenced object.
  *
  * @param $referencedObject
  * @return bool
  */
 public function isReferenced($referencedObject)
 {
     $allScheduledReferences = $this->unitOfWork->getAllScheduledReferences();
     $reflection = new \ReflectionClass($referencedObject);
     foreach ($allScheduledReferences as $references) {
         foreach ($references as $reference) {
             if ($reflection->isInstance($reference)) {
                 return true;
             }
         }
     }
     return $this->unitOfWork->hasReferencedObject($referencedObject);
 }
 private function assertThatItsClear($reference = 'phpcr')
 {
     if ('phpcr' === $reference) {
         $this->documentManager->expects($this->once())->method('clear');
     } elseif ('dbal-orm' === $reference) {
         $this->objectManager->expects($this->once())->method('clear');
     }
     $this->UoW->clear();
     $this->assertCount(0, $this->UoW->getScheduledReferencesForUpdate());
     $this->assertCount(0, $this->UoW->getScheduledReferencesForRemove());
     $this->assertCount(0, $this->UoW->getScheduledReferencesForInsert());
     $this->assertCount(0, $this->UoW->getScheduledReferencesByManager());
 }