Exemplo n.º 1
0
 public function testFindByUUID()
 {
     $refTestObj = new RefRefTestObj();
     $refTestObj->id = "/functional/refRefTestObj";
     $refTestObj->name = 'referrer';
     $this->dm->persist($refTestObj);
     $this->dm->flush();
     $this->dm->clear();
     $node = $this->session->getNode($refTestObj->id);
     $document = $this->dm->find($this->referencedType, $node->getIdentifier());
     $this->assertInstanceOf($this->referencedType, $document);
     $documents = $this->dm->findMany($this->referencedType, array($node->getIdentifier()));
     $this->assertInstanceOf($this->referencedType, $documents->first());
 }
Exemplo n.º 2
0
 public function testFetchingMultipleHierarchicalObjectsWithChildIdFirst()
 {
     $parent = new ParentTestObj();
     $parent->nodename = 'parent';
     $parent->name = 'parent';
     $parent->parent = $this->dm->find(null, 'functional');
     $child = new ParentTestObj();
     $child->nodename = 'child';
     $child->name = 'child';
     $child->parent = $parent;
     $this->dm->persist($parent);
     $this->dm->persist($child);
     $parentId = $this->uow->getDocumentId($parent);
     $childId = $this->uow->getDocumentId($child);
     $this->dm->flush();
     $this->dm->clear();
     // this forces the objects to be loaded in an order where the $parent will become a proxy
     $documents = $this->dm->findMany('Doctrine\\Tests\\Models\\References\\ParentTestObj', array($childId, $parentId));
     $this->assertCount(2, $documents);
     /* @var $child ParentTestObj */
     /* @var $parent ParentTestObj */
     $child = $documents->first();
     $parent = $documents->last();
     $this->assertSame($child->parent, $parent);
     $this->assertSame('parent', $parent->nodename);
 }
Exemplo n.º 3
0
 public function testFindManyWithNonExistingUuuid()
 {
     $user = new TestUser();
     $user->username = '******';
     $user->id = '/functional/test';
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $actualUuid = $user->uuid;
     $unusedUuid = UUIDHelper::generateUUID();
     $this->assertNotNull($this->dm->find(get_class($user), $user->id));
     $this->assertNotNull($this->dm->find(get_class($user), $actualUuid));
     $this->assertNull($this->dm->find(get_class($user), $unusedUuid));
     $uuids = array($actualUuid, $unusedUuid);
     $documents = $this->dm->findMany(get_class($user), $uuids);
     $this->assertEquals(1, count($documents));
 }
 /**
  * @param string $path
  *
  * @return \Imagine\Image\ImageInterface
  */
 public function find($path)
 {
     $file = $this->rootPath . '/' . ltrim($path, '/');
     $info = $this->getFileInfo($file);
     $name = $info['dirname'] . '/' . $info['filename'];
     // consider full path as provided (with or without an extension)
     $paths = array($file);
     foreach ($this->formats as $format) {
         // consider all possible alternative extensions
         if (empty($info['extension']) || $info['extension'] !== $format) {
             $paths[] = $name . '.' . $format;
         }
     }
     // if the full path contained an extension, also consider the full path without an extension
     if ($file !== $name) {
         $paths[] = $name;
     }
     $images = $this->manager->findMany($this->class, $paths);
     if (!$images->count()) {
         throw new NotFoundHttpException(sprintf('Source image not found with id "%s"', $path));
     }
     return $this->imagine->load(stream_get_contents($this->getStreamFromImage($images->first())));
 }
 /**
  * Find many document by id
  *
  * The ids may either be PHPCR paths or UUID's, but all must be of the same type
  *
  * @param array $ids document ids
  * @return array of document objects
  */
 public function findMany(array $ids)
 {
     return $this->dm->findMany($this->className, $ids);
 }
Exemplo n.º 6
0
 /**
  * TypeTeamUser is not a superclass of User
  */
 public function testManyNotInstanceOf()
 {
     $users = $this->dm->findMany('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\TypeTeamUser', array('/functional/user'));
     $this->assertCount(0, $users);
 }