| @@ 32-70 (lines=39) @@ | ||
| 29 | /** |
|
| 30 | * {@inheritdoc} |
|
| 31 | */ |
|
| 32 | public function testHandle() |
|
| 33 | { |
|
| 34 | $foo = $this->createMock(Criterion::class); |
|
| 35 | $bar = $this->createMock(Criterion::class); |
|
| 36 | ||
| 37 | $fooExpr = 'FOO'; |
|
| 38 | $barExpr = 'BAR'; |
|
| 39 | ||
| 40 | $expected = 'FOO AND BAR'; |
|
| 41 | ||
| 42 | $expr = $this->createMock(Expression::class); |
|
| 43 | $expr |
|
| 44 | ->expects($this->once()) |
|
| 45 | ->method('lAnd') |
|
| 46 | ->with([$fooExpr, $barExpr]) |
|
| 47 | ->willReturn($expected); |
|
| 48 | ||
| 49 | $query = $this->createMock(SelectQuery::class); |
|
| 50 | $query->expr = $expr; |
|
| 51 | ||
| 52 | $converter = $this->createMock(CriteriaConverter::class); |
|
| 53 | $converter |
|
| 54 | ->expects($this->at(0)) |
|
| 55 | ->method('convertCriteria') |
|
| 56 | ->with($query, $foo) |
|
| 57 | ->willReturn($fooExpr); |
|
| 58 | $converter |
|
| 59 | ->expects($this->at(1)) |
|
| 60 | ->method('convertCriteria') |
|
| 61 | ->with($query, $bar) |
|
| 62 | ->willReturn($barExpr); |
|
| 63 | ||
| 64 | $handler = new LogicalAndHandler(); |
|
| 65 | $actual = $handler->handle( |
|
| 66 | $converter, $query, new LogicalAnd([$foo, $bar]) |
|
| 67 | ); |
|
| 68 | ||
| 69 | $this->assertEquals($expected, $actual); |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||
| @@ 32-70 (lines=39) @@ | ||
| 29 | /** |
|
| 30 | * {@inheritdoc} |
|
| 31 | */ |
|
| 32 | public function testHandle() |
|
| 33 | { |
|
| 34 | $foo = $this->createMock(Criterion::class); |
|
| 35 | $bar = $this->createMock(Criterion::class); |
|
| 36 | ||
| 37 | $fooExpr = 'FOO'; |
|
| 38 | $barExpr = 'BAR'; |
|
| 39 | ||
| 40 | $expected = 'FOO OR BAR'; |
|
| 41 | ||
| 42 | $expr = $this->createMock(Expression::class); |
|
| 43 | $expr |
|
| 44 | ->expects($this->once()) |
|
| 45 | ->method('lOr') |
|
| 46 | ->with([$fooExpr, $barExpr]) |
|
| 47 | ->willReturn($expected); |
|
| 48 | ||
| 49 | $query = $this->createMock(SelectQuery::class); |
|
| 50 | $query->expr = $expr; |
|
| 51 | ||
| 52 | $converter = $this->createMock(CriteriaConverter::class); |
|
| 53 | $converter |
|
| 54 | ->expects($this->at(0)) |
|
| 55 | ->method('convertCriteria') |
|
| 56 | ->with($query, $foo) |
|
| 57 | ->willReturn($fooExpr); |
|
| 58 | $converter |
|
| 59 | ->expects($this->at(1)) |
|
| 60 | ->method('convertCriteria') |
|
| 61 | ->with($query, $bar) |
|
| 62 | ->willReturn($barExpr); |
|
| 63 | ||
| 64 | $handler = new LogicalOrHandler(); |
|
| 65 | $actual = $handler->handle( |
|
| 66 | $converter, $query, new LogicalOr([$foo, $bar]) |
|
| 67 | ); |
|
| 68 | ||
| 69 | $this->assertEquals($expected, $actual); |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||