Completed
Push — 7.0_master_link_manager_merge ( e446e3 )
by André
77:34 queued 60:56
created

LogicalNotTest::testAccept()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
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\LogicalNot;
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\LogicalNot as LogicalNotHandler;
15
16
class LogicalNotTest extends CriterionHandlerTest
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function testAccept()
22
    {
23
        $handler = new LogicalNotHandler();
24
25
        $this->assertHandlerAcceptsCriterion($handler, LogicalNot::class);
26
        $this->assertHandlerRejectsCriterion($handler, Criterion::class);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function testHandle()
33
    {
34
        $foo = $this->createMock(Criterion::class);
35
        $fooExpr = 'FOO';
36
        $expected = 'NOT FOO';
37
38
        $expr = $this->createMock(Expression::class);
39
        $expr
40
            ->expects($this->once())
41
            ->method('not')
42
            ->with($fooExpr)
43
            ->willReturn($expected);
44
45
        $query = $this->createMock(SelectQuery::class);
46
        $query->expr = $expr;
47
48
        $converter = $this->createMock(CriteriaConverter::class);
49
        $converter
50
            ->expects($this->at(0))
51
            ->method('convertCriteria')
52
            ->with($query, $foo)
53
            ->willReturn($fooExpr);
54
55
        $handler = new LogicalNotHandler();
56
        $actual = $handler->handle(
57
            $converter, $query, new LogicalNot($foo)
58
        );
59
60
        $this->assertEquals($expected, $actual);
61
    }
62
}
63