GH71Test   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testMetadata() 0 6 1
A testIssue() 0 17 1
1
<?php
2
3
namespace Doctrine\Tests\ODM\CouchDB\Functional\Ticket;
4
5
class GH71Test extends \Doctrine\Tests\ODM\CouchDB\CouchDBFunctionalTestCase
6
{
7
    private $dm;
8
9
    public function setUp()
10
    {
11
        $this->dm = $this->createDocumentManager();
12
    }
13
14
    public function testMetadata()
15
    {
16
        $metadata = $this->dm->getClassMetadata(__NAMESPACE__ . '\\GH71Invoice');
17
18
        $this->assertEquals(array('user'), $metadata->indexes);
19
    }
20
21
    public function testIssue()
22
    {
23
        $user = new GH71User();
24
        $invoice = new GH71Invoice();
25
        $invoice->user = $user;
26
27
        $this->dm->persist($user);
28
        $this->dm->persist($invoice);
29
        $this->dm->flush();
30
        $this->dm->clear();
31
32
        $repository = $this->dm->getRepository(__NAMESPACE__ . '\\GH71Invoice');
33
        $invoices = $repository->findBy(array('user' => $user->id));
34
35
        $this->assertCount(1, $invoices);
36
        $this->assertEquals($invoice->id, $invoices[0]->id);
37
    }
38
}
39
40
/**
41
 * @Document
42
 */
43
class GH71Invoice
44
{
45
    /**
46
     * @Id
47
     */
48
    public $id;
49
50
    /**
51
     * @ReferenceOne(targetDocument="GH71User")
52
     * @Index
53
     */
54
    public $user;
55
}
56
57
/**
58
 * @Document
59
 */
60
class GH71User
61
{
62
    /**
63
     * @Id
64
     */
65
    public $id;
66
}
67