Completed
Push — master ( cfe8d7...fcc746 )
by André
19:36 queued 06:48
created

MatchNoneTest::testHandle()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 20

Duplication

Lines 27
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 20
nc 1
nop 0
dl 27
loc 27
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Persistence\Legacy\Tests\URL\Query\CriterionHandler;
8
9
use eZ\Publish\API\Repository\Values\URL\Query\Criterion;
10
use eZ\Publish\API\Repository\Values\URL\Query\Criterion\MatchNone;
11
use eZ\Publish\Core\Persistence\Database\Expression;
12
use eZ\Publish\Core\Persistence\Database\SelectQuery;
13
use eZ\Publish\Core\Persistence\Legacy\URL\Query\CriteriaConverter;
14
use eZ\Publish\Core\Persistence\Legacy\URL\Query\CriterionHandler\MatchNone as MatchNoneHandler;
15
16 View Code Duplication
class MatchNoneTest extends CriterionHandlerTest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function testAccept()
22
    {
23
        $handler = new MatchNoneHandler();
24
25
        $this->assertHandlerAcceptsCriterion($handler, MatchNone::class);
26
        $this->assertHandlerRejectsCriterion($handler, Criterion::class);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function testHandle()
33
    {
34
        $criterion = new MatchNone();
35
        $expected = 'NOT :value';
36
37
        $expr = $this->createMock(Expression::class);
38
        $expr
39
            ->expects($this->once())
40
            ->method('not')
41
            ->with(':value')
42
            ->willReturn($expected);
43
44
        $query = $this->createMock(SelectQuery::class);
45
        $query->expr = $expr;
46
        $query
47
            ->expects($this->once())
48
            ->method('bindValue')
49
            ->with('1')
50
            ->willReturn(':value');
51
52
        $converter = $this->createMock(CriteriaConverter::class);
53
54
        $handler = new MatchNoneHandler();
55
        $actual = $handler->handle($converter, $query, $criterion);
56
57
        $this->assertEquals($expected, $actual);
58
    }
59
}
60