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\API\Repository\Tests; |
8
|
|
|
|
9
|
|
|
use eZ\Publish\API\Repository\Values\URL\SearchResult; |
10
|
|
|
use eZ\Publish\API\Repository\Values\URL\URLQuery; |
11
|
|
|
use eZ\Publish\API\Repository\Values\URL\UsageSearchResult; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Base class for URLService tests. |
15
|
|
|
*/ |
16
|
|
|
abstract class BaseURLServiceTest extends BaseTest |
17
|
|
|
{ |
18
|
|
|
protected function doTestFindUrls(URLQuery $query, array $expectedUrls, $exectedTotalCount = null, $ignoreOrder = true) |
19
|
|
|
{ |
20
|
|
|
$repository = $this->getRepository(); |
21
|
|
|
|
22
|
|
|
/* BEGIN: Use Case */ |
23
|
|
|
$searchResult = $repository->getURLService()->findUrls($query); |
24
|
|
|
/* END: Use Case */ |
25
|
|
|
|
26
|
|
|
if ($exectedTotalCount === null) { |
27
|
|
|
$exectedTotalCount = count($expectedUrls); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
$this->assertInstanceOf(SearchResult::class, $searchResult); |
31
|
|
|
$this->assertEquals($exectedTotalCount, $searchResult->totalCount); |
32
|
|
|
$this->assertSearchResultItems($searchResult, $expectedUrls, $ignoreOrder); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
protected function assertSearchResultItems(SearchResult $searchResult, array $expectedUrls, $ignoreOrder) |
36
|
|
|
{ |
37
|
|
|
$this->assertCount(count($expectedUrls), $searchResult->items); |
38
|
|
|
|
39
|
|
|
foreach ($searchResult->items as $i => $item) { |
40
|
|
|
if ($ignoreOrder) { |
41
|
|
|
$this->assertContains($item->url, $expectedUrls); |
|
|
|
|
42
|
|
|
} else { |
43
|
|
|
$this->assertEquals($expectedUrls[$i], $item->url); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function assertUsagesSearchResultItems(UsageSearchResult $searchResult, array $expectedContentInfoIds) |
49
|
|
|
{ |
50
|
|
|
$this->assertCount(count($expectedContentInfoIds), $searchResult->items); |
51
|
|
|
foreach ($searchResult->items as $contentInfo) { |
52
|
|
|
$this->assertContains($contentInfo->id, $expectedContentInfoIds); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.