QueryTest::testQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 9.312
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\ODM\CouchDB\Functional;
4
5
class QueryTest extends \Doctrine\Tests\ODM\CouchDB\CouchDBFunctionalTestCase
6
{
7
    private $dm;
8
9
    public function testQuery()
10
    {
11
        $designDocPath = __DIR__ . "/../../../Models/CMS/_files";
12
        $this->dm = $this->createDocumentManager();
13
        $this->dm->getConfiguration()
14
                 ->addDesignDocument('cms', 'Doctrine\CouchDB\View\FolderDesignDocument', $designDocPath);
0 ignored issues
show
Documentation introduced by
$designDocPath is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
15
16
        $user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
17
        $user1->username = "beberlei";
18
        $user1->status = "active";
19
        $user1->name = "Benjamin";
20
21
        $user2 = new \Doctrine\Tests\Models\CMS\CmsUser();
22
        $user2->username = "lsmith";
23
        $user2->status = "active";
24
        $user2->name = "Lukas";
25
26
        $this->dm->persist($user1);
27
        $this->dm->persist($user2);
28
        $this->dm->flush();
29
        $this->dm->clear();
30
31
        $result = $this->dm->createQuery('cms', 'username')
32
                           ->onlyDocs(true)
33
                           ->setKey('lsmith')
34
                           ->execute();
35
36
        $this->assertCount(1, $result);
37
        $this->assertEquals('lsmith', $result[0]->username);
38
39
        $result = $this->dm->createQuery('cms', 'username')
40
                           ->onlyDocs(true)
41
                           ->setKey('beberlei')
42
                           ->execute();
43
44
        $this->assertCount(1, $result);
45
        $this->assertEquals('beberlei', $result[0]->username);
46
    }
47
}