| @@ 16-110 (lines=95) @@ | ||
| 13 | use eZ\Publish\API\Repository\Values\Content\ContentInfo; |
|
| 14 | use eZ\Publish\Core\MVC\Symfony\Matcher\Tests\ContentBased\BaseTest; |
|
| 15 | ||
| 16 | class LocationTest extends BaseTest |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Location |
|
| 20 | */ |
|
| 21 | private $matcher; |
|
| 22 | ||
| 23 | protected function setUp() |
|
| 24 | { |
|
| 25 | parent::setUp(); |
|
| 26 | $this->matcher = new LocationIdMatcher(); |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @dataProvider matchLocationProvider |
|
| 31 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Location::matchLocation |
|
| 32 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
|
| 33 | * |
|
| 34 | * @param int|int[] $matchingConfig |
|
| 35 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
|
| 36 | * @param bool $expectedResult |
|
| 37 | */ |
|
| 38 | public function testMatchLocation($matchingConfig, Location $location, $expectedResult) |
|
| 39 | { |
|
| 40 | $this->matcher->setMatchingConfig($matchingConfig); |
|
| 41 | $this->assertSame($expectedResult, $this->matcher->matchLocation($location)); |
|
| 42 | } |
|
| 43 | ||
| 44 | public function matchLocationProvider() |
|
| 45 | { |
|
| 46 | return [ |
|
| 47 | [ |
|
| 48 | 123, |
|
| 49 | $this->getLocationMock(['id' => 123]), |
|
| 50 | true, |
|
| 51 | ], |
|
| 52 | [ |
|
| 53 | 123, |
|
| 54 | $this->getLocationMock(['id' => 456]), |
|
| 55 | false, |
|
| 56 | ], |
|
| 57 | [ |
|
| 58 | [123, 789], |
|
| 59 | $this->getLocationMock(['id' => 456]), |
|
| 60 | false, |
|
| 61 | ], |
|
| 62 | [ |
|
| 63 | [123, 789], |
|
| 64 | $this->getLocationMock(['id' => 789]), |
|
| 65 | true, |
|
| 66 | ], |
|
| 67 | ]; |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * @dataProvider matchContentInfoProvider |
|
| 72 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Location::matchContentInfo |
|
| 73 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
|
| 74 | * |
|
| 75 | * @param int|int[] $matchingConfig |
|
| 76 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
|
| 77 | * @param bool $expectedResult |
|
| 78 | */ |
|
| 79 | public function testMatchContentInfo($matchingConfig, ContentInfo $contentInfo, $expectedResult) |
|
| 80 | { |
|
| 81 | $this->matcher->setMatchingConfig($matchingConfig); |
|
| 82 | $this->assertSame($expectedResult, $this->matcher->matchContentInfo($contentInfo)); |
|
| 83 | } |
|
| 84 | ||
| 85 | public function matchContentInfoProvider() |
|
| 86 | { |
|
| 87 | return [ |
|
| 88 | [ |
|
| 89 | 123, |
|
| 90 | $this->getContentInfoMock(['mainLocationId' => 123]), |
|
| 91 | true, |
|
| 92 | ], |
|
| 93 | [ |
|
| 94 | 123, |
|
| 95 | $this->getContentInfoMock(['mainLocationId' => 456]), |
|
| 96 | false, |
|
| 97 | ], |
|
| 98 | [ |
|
| 99 | [123, 789], |
|
| 100 | $this->getContentInfoMock(['mainLocationId' => 456]), |
|
| 101 | false, |
|
| 102 | ], |
|
| 103 | [ |
|
| 104 | [123, 789], |
|
| 105 | $this->getContentInfoMock(['mainLocationId' => 789]), |
|
| 106 | true, |
|
| 107 | ], |
|
| 108 | ]; |
|
| 109 | } |
|
| 110 | } |
|
| 111 | ||
| @@ 16-110 (lines=95) @@ | ||
| 13 | use eZ\Publish\API\Repository\Values\Content\ContentInfo; |
|
| 14 | use eZ\Publish\Core\MVC\Symfony\Matcher\Tests\ContentBased\BaseTest; |
|
| 15 | ||
| 16 | class RemoteTest extends BaseTest |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Remote |
|
| 20 | */ |
|
| 21 | private $matcher; |
|
| 22 | ||
| 23 | protected function setUp() |
|
| 24 | { |
|
| 25 | parent::setUp(); |
|
| 26 | $this->matcher = new RemoteIdMatcher(); |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @dataProvider matchLocationProvider |
|
| 31 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Remote::matchLocation |
|
| 32 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
|
| 33 | * |
|
| 34 | * @param string|string[] $matchingConfig |
|
| 35 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
|
| 36 | * @param bool $expectedResult |
|
| 37 | */ |
|
| 38 | public function testMatchLocation($matchingConfig, Location $location, $expectedResult) |
|
| 39 | { |
|
| 40 | $this->matcher->setMatchingConfig($matchingConfig); |
|
| 41 | $this->assertSame($expectedResult, $this->matcher->matchLocation($location)); |
|
| 42 | } |
|
| 43 | ||
| 44 | public function matchLocationProvider() |
|
| 45 | { |
|
| 46 | return [ |
|
| 47 | [ |
|
| 48 | 'foo', |
|
| 49 | $this->getLocationMock(['remoteId' => 'foo']), |
|
| 50 | true, |
|
| 51 | ], |
|
| 52 | [ |
|
| 53 | 'foo', |
|
| 54 | $this->getLocationMock(['remoteId' => 'bar']), |
|
| 55 | false, |
|
| 56 | ], |
|
| 57 | [ |
|
| 58 | ['foo', 'baz'], |
|
| 59 | $this->getLocationMock(['remoteId' => 'bar']), |
|
| 60 | false, |
|
| 61 | ], |
|
| 62 | [ |
|
| 63 | ['foo', 'baz'], |
|
| 64 | $this->getLocationMock(['remoteId' => 'baz']), |
|
| 65 | true, |
|
| 66 | ], |
|
| 67 | ]; |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * @dataProvider matchContentInfoProvider |
|
| 72 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Remote::matchContentInfo |
|
| 73 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
|
| 74 | * |
|
| 75 | * @param string|string[] $matchingConfig |
|
| 76 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
|
| 77 | * @param bool $expectedResult |
|
| 78 | */ |
|
| 79 | public function testMatchContentInfo($matchingConfig, ContentInfo $contentInfo, $expectedResult) |
|
| 80 | { |
|
| 81 | $this->matcher->setMatchingConfig($matchingConfig); |
|
| 82 | $this->assertSame($expectedResult, $this->matcher->matchContentInfo($contentInfo)); |
|
| 83 | } |
|
| 84 | ||
| 85 | public function matchContentInfoProvider() |
|
| 86 | { |
|
| 87 | return [ |
|
| 88 | [ |
|
| 89 | 'foo', |
|
| 90 | $this->getContentInfoMock(['remoteId' => 'foo']), |
|
| 91 | true, |
|
| 92 | ], |
|
| 93 | [ |
|
| 94 | 'foo', |
|
| 95 | $this->getContentInfoMock(['remoteId' => 'bar']), |
|
| 96 | false, |
|
| 97 | ], |
|
| 98 | [ |
|
| 99 | ['foo', 'baz'], |
|
| 100 | $this->getContentInfoMock(['remoteId' => 'bar']), |
|
| 101 | false, |
|
| 102 | ], |
|
| 103 | [ |
|
| 104 | ['foo', 'baz'], |
|
| 105 | $this->getContentInfoMock(['remoteId' => 'baz']), |
|
| 106 | true, |
|
| 107 | ], |
|
| 108 | ]; |
|
| 109 | } |
|
| 110 | } |
|
| 111 | ||