|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the URLAliasTest class. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Publish\Core\SignalSlot\Tests; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\URLAliasService as APIURLAliasService; |
|
12
|
|
|
use eZ\Publish\Core\Repository\Values\Content\Location; |
|
13
|
|
|
use eZ\Publish\API\Repository\Values\Content\URLAlias; |
|
14
|
|
|
use eZ\Publish\Core\SignalSlot\SignalDispatcher; |
|
15
|
|
|
use eZ\Publish\Core\SignalSlot\URLAliasService; |
|
16
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\URLAliasService as URLAliasServiceSignals; |
|
17
|
|
|
|
|
18
|
|
|
class URLAliasServiceTest extends ServiceTest |
|
19
|
|
|
{ |
|
20
|
|
|
protected function getServiceMock() |
|
21
|
|
|
{ |
|
22
|
|
|
return $this->createMock(APIURLAliasService::class); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
protected function getSignalSlotService($coreService, SignalDispatcher $dispatcher) |
|
26
|
|
|
{ |
|
27
|
|
|
return new URLAliasService($coreService, $dispatcher); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function serviceProvider() |
|
31
|
|
|
{ |
|
32
|
|
|
$locationId = 60; |
|
33
|
|
|
$locationPath = '/bugs-bunny'; |
|
34
|
|
|
$locationRemoteId = md5('bugs bunny'); |
|
35
|
|
|
|
|
36
|
|
|
$urlAliasId = '42-foobar'; |
|
37
|
|
|
$globalUrlAliasId = 'rabbit'; |
|
38
|
|
|
$path = '/lapin'; |
|
39
|
|
|
$globalPath = '/lapins'; |
|
40
|
|
|
$globalDestination = '/characters/rabbits'; |
|
41
|
|
|
$languageCode = 'fre-FR'; |
|
42
|
|
|
$forward = true; |
|
43
|
|
|
$alwaysAvailable = true; |
|
44
|
|
|
|
|
45
|
|
|
$contentInfo = $this->getContentInfo(59, md5('bugs bunny contnet')); |
|
46
|
|
|
|
|
47
|
|
|
$location = new Location( |
|
48
|
|
|
array( |
|
49
|
|
|
'id' => $locationId, |
|
50
|
|
|
'path' => $locationPath, |
|
51
|
|
|
'remoteId' => $locationRemoteId, |
|
52
|
|
|
'contentInfo' => $contentInfo, |
|
53
|
|
|
) |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
$locationUrlAlias = new URLAlias( |
|
57
|
|
|
array( |
|
58
|
|
|
'id' => $urlAliasId, |
|
59
|
|
|
'type' => URLAlias::LOCATION, |
|
60
|
|
|
'destination' => $locationId, |
|
61
|
|
|
'path' => $path, |
|
62
|
|
|
'languageCodes' => array($languageCode), |
|
63
|
|
|
'forward' => $forward, |
|
64
|
|
|
) |
|
65
|
|
|
); |
|
66
|
|
|
|
|
67
|
|
|
$globalUrlAlias = new URLAlias( |
|
68
|
|
|
array( |
|
69
|
|
|
'id' => $globalUrlAliasId, |
|
70
|
|
|
'type' => URLAlias::RESOURCE, |
|
71
|
|
|
'destination' => $globalDestination, |
|
72
|
|
|
'path' => $globalPath, |
|
73
|
|
|
'languageCodes' => array($languageCode), |
|
74
|
|
|
'forward' => $forward, |
|
75
|
|
|
) |
|
76
|
|
|
); |
|
77
|
|
|
|
|
78
|
|
|
$aliasList = array($globalUrlAlias, $locationUrlAlias); |
|
79
|
|
|
|
|
80
|
|
|
return array( |
|
81
|
|
|
array( |
|
82
|
|
|
'createUrlAlias', |
|
83
|
|
|
array( |
|
84
|
|
|
$location, $path, $languageCode, $forward, $alwaysAvailable, |
|
85
|
|
|
), |
|
86
|
|
|
$locationUrlAlias, |
|
87
|
|
|
1, |
|
88
|
|
|
URLAliasServiceSignals\CreateUrlAliasSignal::class, |
|
89
|
|
|
array('urlAliasId' => $urlAliasId), |
|
90
|
|
|
), |
|
91
|
|
|
array( |
|
92
|
|
|
'createGlobalUrlAlias', |
|
93
|
|
|
array( |
|
94
|
|
|
$globalPath, |
|
95
|
|
|
$globalDestination, |
|
96
|
|
|
$languageCode, |
|
97
|
|
|
$forward, |
|
98
|
|
|
$alwaysAvailable, |
|
99
|
|
|
), |
|
100
|
|
|
$globalUrlAlias, |
|
101
|
|
|
1, |
|
102
|
|
|
URLAliasServiceSignals\CreateGlobalUrlAliasSignal::class, |
|
103
|
|
|
array('urlAliasId' => $globalUrlAliasId), |
|
104
|
|
|
), |
|
105
|
|
|
array( |
|
106
|
|
|
'listLocationAliases', |
|
107
|
|
|
array($location, false, $languageCode, false, array()), |
|
108
|
|
|
array($locationUrlAlias), |
|
109
|
|
|
0, |
|
110
|
|
|
), |
|
111
|
|
|
array( |
|
112
|
|
|
'listGlobalAliases', |
|
113
|
|
|
array($languageCode, 1, 2), |
|
114
|
|
|
array($globalUrlAlias), |
|
115
|
|
|
0, |
|
116
|
|
|
), |
|
117
|
|
|
array( |
|
118
|
|
|
'removeAliases', |
|
119
|
|
|
array($aliasList), |
|
120
|
|
|
null, |
|
121
|
|
|
1, |
|
122
|
|
|
URLAliasServiceSignals\RemoveAliasesSignal::class, |
|
123
|
|
|
array( |
|
124
|
|
|
'aliasList' => $aliasList, |
|
125
|
|
|
), |
|
126
|
|
|
), |
|
127
|
|
|
array( |
|
128
|
|
|
'lookup', |
|
129
|
|
|
array($path, $languageCode), |
|
130
|
|
|
$locationUrlAlias, |
|
131
|
|
|
0, |
|
132
|
|
|
), |
|
133
|
|
|
array( |
|
134
|
|
|
'reverseLookup', |
|
135
|
|
|
array($location, $languageCode, false, array()), |
|
136
|
|
|
$locationUrlAlias, |
|
137
|
|
|
0, |
|
138
|
|
|
), |
|
139
|
|
|
array( |
|
140
|
|
|
'load', |
|
141
|
|
|
array($urlAliasId), |
|
142
|
|
|
$locationUrlAlias, |
|
143
|
|
|
0, |
|
144
|
|
|
), |
|
145
|
|
|
); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|