|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eZ\Publish\Core\Repository\SiteAccessAware\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use eZ\Publish\API\Repository\ContentService as APIContentService; |
|
6
|
|
|
use eZ\Publish\API\Repository\Values\Content\ContentInfo; |
|
7
|
|
|
use eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct; |
|
8
|
|
|
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct; |
|
9
|
|
|
use eZ\Publish\Core\Repository\SiteAccessAware\ContentService; |
|
10
|
|
|
use eZ\Publish\Core\Repository\Values\Content\ContentCreateStruct; |
|
11
|
|
|
use eZ\Publish\Core\Repository\Values\Content\ContentUpdateStruct; |
|
12
|
|
|
use eZ\Publish\Core\Repository\Values\Content\VersionInfo; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Abstract tests for SiteAccessAware Services. |
|
16
|
|
|
* |
|
17
|
|
|
* Implies convention for methods on these services to either: |
|
18
|
|
|
* - Do nothing, pass-through call and optionally (default:true) return value |
|
19
|
|
|
* - lookup languages [IF not defined by callee] on one of the arguments given and pass it to next one. |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
class ContentServiceTest extends AbstractServiceTest |
|
23
|
|
|
{ |
|
24
|
|
|
public function getAPIServiceClassName(): string |
|
25
|
|
|
{ |
|
26
|
|
|
return APIContentService::class; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function getSiteAccessAwareServiceClassName(): string |
|
30
|
|
|
{ |
|
31
|
|
|
return ContentService::class; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function providerForPassTroughMethods(): array |
|
35
|
|
|
{ |
|
36
|
|
|
$contentInfo = new ContentInfo(); |
|
37
|
|
|
$versionInfo = new VersionInfo(); |
|
38
|
|
|
$contentCreateStruct = new ContentCreateStruct(); |
|
39
|
|
|
$contentUpdateStruct = new ContentUpdateStruct(); |
|
40
|
|
|
$contentMetaStruct = new ContentMetadataUpdateStruct(); |
|
41
|
|
|
$locationCreateStruct = new LocationCreateStruct(); |
|
42
|
|
|
|
|
43
|
|
|
// string $method, array $arguments, bool $return |
|
44
|
|
|
return [ |
|
45
|
|
|
['loadContentInfo', [42], true], |
|
46
|
|
|
|
|
47
|
|
|
['loadContentInfoByRemoteId', ['f348tj4gorgji4'], true], |
|
48
|
|
|
|
|
49
|
|
|
['loadVersionInfo', [$contentInfo], true], |
|
50
|
|
|
['loadVersionInfo', [$contentInfo, 3], true], |
|
51
|
|
|
|
|
52
|
|
|
['loadVersionInfoById', [42], true], |
|
53
|
|
|
['loadVersionInfoById', [42, 3], true], |
|
54
|
|
|
|
|
55
|
|
|
['createContent', [$contentCreateStruct], true], |
|
56
|
|
|
['createContent', [$contentCreateStruct, [44]], true], |
|
57
|
|
|
|
|
58
|
|
|
['updateContentMetadata', [$contentInfo, $contentMetaStruct], true], |
|
59
|
|
|
|
|
60
|
|
|
['deleteContent', [$contentInfo], true], |
|
61
|
|
|
|
|
62
|
|
|
['createContentDraft', [$contentInfo], true], |
|
63
|
|
|
['createContentDraft', [$contentInfo, $versionInfo], true], |
|
64
|
|
|
//['createContentDraft', [$contentInfo, $versionInfo, $user], true], |
|
65
|
|
|
|
|
66
|
|
|
['loadContentDrafts', [], true], |
|
67
|
|
|
//['loadContentDrafts', [$user], true], |
|
68
|
|
|
|
|
69
|
|
|
['updateContent', [$versionInfo, $contentUpdateStruct], true], |
|
70
|
|
|
|
|
71
|
|
|
['publishVersion', [$versionInfo], true], |
|
72
|
|
|
|
|
73
|
|
|
['deleteVersion', [$versionInfo], true], |
|
74
|
|
|
|
|
75
|
|
|
['loadVersions', [$contentInfo], true], |
|
76
|
|
|
|
|
77
|
|
|
['copyContent', [$contentInfo, $locationCreateStruct], true], |
|
78
|
|
|
['copyContent', [$contentInfo, $locationCreateStruct, $versionInfo], true], |
|
79
|
|
|
|
|
80
|
|
|
['loadRelations', [$versionInfo], true], |
|
81
|
|
|
|
|
82
|
|
|
['loadReverseRelations', [$contentInfo], true], |
|
83
|
|
|
|
|
84
|
|
|
['addRelation', [$versionInfo, $contentInfo], true], |
|
85
|
|
|
|
|
86
|
|
|
['deleteRelation', [$versionInfo, $contentInfo], true], |
|
87
|
|
|
|
|
88
|
|
|
['removeTranslation', [$contentInfo, 'eng-GB'], true], |
|
89
|
|
|
|
|
90
|
|
|
//['newContentCreateStruct', [$contentType, 'eng-GB'], true], |
|
91
|
|
|
['newContentMetadataUpdateStruct', [], true], |
|
92
|
|
|
['newContentUpdateStruct', [], true], |
|
93
|
|
|
['newTranslationInfo', [], true], |
|
94
|
|
|
['newTranslationValues', [], true], |
|
95
|
|
|
]; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
public function providerForLanguagesLookupMethods(): array |
|
100
|
|
|
{ |
|
101
|
|
|
$contentInfo = new ContentInfo(); |
|
102
|
|
|
$versionInfo = new VersionInfo(); |
|
103
|
|
|
|
|
104
|
|
|
// string $method, array $arguments, bool $return, int $languageArgumentIndex |
|
105
|
|
|
return [ |
|
106
|
|
|
['loadContentByContentInfo', [$contentInfo], true, 1], |
|
107
|
|
|
['loadContentByContentInfo', [$contentInfo, self::LANG_ARG, 4, false], true, 1], |
|
108
|
|
|
|
|
109
|
|
|
['loadContentByVersionInfo', [$versionInfo], true, 1], |
|
110
|
|
|
['loadContentByVersionInfo', [$versionInfo, self::LANG_ARG, false], true, 1], |
|
111
|
|
|
|
|
112
|
|
|
['loadContent', [42], true, 1], |
|
113
|
|
|
['loadContent', [42, self::LANG_ARG, 4, false], true, 1], |
|
114
|
|
|
|
|
115
|
|
|
['loadContentByRemoteId', ['f348tj4gorgji4'], true, 1], |
|
116
|
|
|
['loadContentByRemoteId', ['f348tj4gorgji4', self::LANG_ARG, 4, false], true, 1], |
|
117
|
|
|
]; |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|