forked from doctrine/phpcr-odm
/
DocumentManagerTest.php
76 lines (60 loc) · 1.69 KB
/
DocumentManagerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Doctrine\Tests\ODM\PHPCR\Functional;
use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase;
use PHPCR\NodeInterface;
use PHPCR\Util\UUIDHelper;
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
class DocumentManagerTest extends PHPCRFunctionalTestCase
{
/**
* @var DocumentManager
*/
private $dm;
/**
* Class name of the document class
* @var string
*/
private $type;
/**
* @var NodeInterface
*/
private $node;
public function setUp()
{
$this->dm = $this->createDocumentManager(array(__DIR__));
$this->node = $this->resetFunctionalNode($this->dm);
}
public function testFindManyWithNonExistingUuuid()
{
$user = new TestUser();
$user->username = 'test-name';
$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));
}
}
/**
* @PHPCRODM\Document(referenceable=true)
*
*/
class TestUser
{
/** @PHPCRODM\Id */
public $id;
/** @PHPCRODM\Node */
public $node;
/** @PHPCRODM\Field(type="string") */
public $username;
/** @PHPCRODM\Uuid */
public $uuid;
}