Completed
Push — master ( a3d65b...b0c920 )
by André
87:29 queued 62:17
created

searchContentQueryWithInvalidDataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 14
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the EZP22958SearchSubtreePathstringFormatTest class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\API\Repository\Tests\Regression;
10
11
use eZ\Publish\API\Repository\Tests\BaseTest;
12
use eZ\Publish\API\Repository\Values\Content\Query;
13
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
14
15
/**
16
 * Issue EZP-21906.
17
 */
18
class EZP22958SearchSubtreePathstringFormatTest extends BaseTest
19
{
20
    protected function setUp()
21
    {
22
        parent::setUp();
23
    }
24
25
    /**
26
     * Tests that invalid path string provided for subtree criterion result in exception.
27
     *
28
     * @dataProvider searchContentQueryWithInvalidDataProvider
29
     * @expectedException \InvalidArgumentException
30
     */
31 View Code Duplication
    public function testSearchContentSubtreeShouldThrowException($pathString)
32
    {
33
        $query = new Query(
34
            array(
35
                'filter' => new Criterion\Subtree($pathString),
36
            )
37
        );
38
39
        $result = $this->getRepository()->getSearchService()->findContent($query);
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
40
    }
41
42
    /**
43
     * Tests that path string provided for subtree criterion is valid.
44
     *
45
     * @dataProvider searchContentQueryProvider
46
     */
47 View Code Duplication
    public function testSearchContentSubtree($pathString)
48
    {
49
        $query = new Query(
50
            array(
51
                'filter' => new Criterion\Subtree($pathString),
52
            )
53
        );
54
55
        $result = $this->getRepository()->getSearchService()->findContent($query);
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
56
    }
57
58 View Code Duplication
    public function searchContentQueryProvider()
59
    {
60
        return array(
61
            array(
62
                '/1/2/',
63
            ),
64
            array(
65
                array('/1/2/', '/1/2/4/'),
66
            ),
67
            array(
68
                '/1/id0/',
69
            ),
70
        );
71
    }
72
73 View Code Duplication
    public function searchContentQueryWithInvalidDataProvider()
74
    {
75
        return array(
76
            array(
77
                '/1/2',
78
            ),
79
            array(
80
                array('/1/2/', '/1/2/4'),
81
            ),
82
            array(
83
                '/1/id0',
84
            ),
85
        );
86
    }
87
}
88