|
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\SignalSlot\Tests; |
|
8
|
|
|
|
|
9
|
|
|
use eZ\Publish\API\Repository\URLService as APIURLService; |
|
10
|
|
|
use eZ\Publish\API\Repository\Values\URL\SearchResult; |
|
11
|
|
|
use eZ\Publish\API\Repository\Values\URL\URL; |
|
12
|
|
|
use eZ\Publish\API\Repository\Values\URL\URLQuery; |
|
13
|
|
|
use eZ\Publish\API\Repository\Values\URL\URLUpdateStruct; |
|
14
|
|
|
use eZ\Publish\Core\SignalSlot\SignalDispatcher; |
|
15
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\URLService\UpdateUrlSignal; |
|
16
|
|
|
use eZ\Publish\Core\SignalSlot\URLService; |
|
17
|
|
|
|
|
18
|
|
|
class URLServiceTest extends ServiceTest |
|
19
|
|
|
{ |
|
20
|
|
|
public function serviceProvider() |
|
21
|
|
|
{ |
|
22
|
|
|
$url = $this->getApiUrl(12, 'http://ez.no'); |
|
23
|
|
|
|
|
24
|
|
|
return [ |
|
25
|
|
|
[ |
|
26
|
|
|
'updateUrl', |
|
27
|
|
|
[ |
|
28
|
|
|
$url, |
|
29
|
|
|
new URLUpdateStruct([ |
|
30
|
|
|
'url' => 'http://ezplatform.com', |
|
31
|
|
|
]), |
|
32
|
|
|
], |
|
33
|
|
|
$this->getApiUrl(12, 'http://ezplatform.com', true), |
|
34
|
|
|
1, |
|
35
|
|
|
UpdateUrlSignal::class, |
|
36
|
|
|
['urlId' => $url->id, 'urlChanged' => true], |
|
37
|
|
|
], |
|
38
|
|
|
[ |
|
39
|
|
|
'updateUrl', |
|
40
|
|
|
[ |
|
41
|
|
|
$url, |
|
42
|
|
|
new URLUpdateStruct([ |
|
43
|
|
|
'isValid' => false, |
|
44
|
|
|
]), |
|
45
|
|
|
], |
|
46
|
|
|
$this->getApiUrl(12, 'http://ez.no', false), |
|
47
|
|
|
1, |
|
48
|
|
|
UpdateUrlSignal::class, |
|
49
|
|
|
['urlId' => $url->id, 'urlChanged' => false], |
|
50
|
|
|
], |
|
51
|
|
|
[ |
|
52
|
|
|
'createUpdateStruct', |
|
53
|
|
|
[], |
|
54
|
|
|
new URLUpdateStruct(), |
|
55
|
|
|
0, |
|
56
|
|
|
], |
|
57
|
|
|
[ |
|
58
|
|
|
'findUrls', |
|
59
|
|
|
[new URLQuery()], |
|
60
|
|
|
new SearchResult(), |
|
61
|
|
|
0, |
|
62
|
|
|
], |
|
63
|
|
|
[ |
|
64
|
|
|
'loadById', |
|
65
|
|
|
[12], |
|
66
|
|
|
$url, |
|
67
|
|
|
0, |
|
68
|
|
|
], |
|
69
|
|
|
[ |
|
70
|
|
|
'loadByUrl', |
|
71
|
|
|
['http://ez.no'], |
|
72
|
|
|
$url, |
|
73
|
|
|
0, |
|
74
|
|
|
], |
|
75
|
|
|
]; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
protected function getServiceMock() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->createMock(APIURLService::class); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
protected function getSignalSlotService($innerService, SignalDispatcher $dispatcher) |
|
84
|
|
|
{ |
|
85
|
|
|
return new URLService($innerService, $dispatcher); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
private function getApiUrl($id = null, $url = null, $isValid = false) |
|
89
|
|
|
{ |
|
90
|
|
|
return new URL([ |
|
91
|
|
|
'id' => $id, |
|
92
|
|
|
'url' => $url, |
|
93
|
|
|
'isValid' => $isValid, |
|
94
|
|
|
]); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|