|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File contains: eZ\Publish\Core\Persistence\Legacy\Tests\Content\LanguageAwareTestCase 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\Persistence\Legacy\Tests\Content; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Tests\TestCase; |
|
12
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator as LanguageMaskGenerator; |
|
13
|
|
|
use eZ\Publish\Core\Persistence; |
|
14
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Mapper\FullTextMapper; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Test case for Language aware classes. |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class LanguageAwareTestCase extends TestCase |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Language handler. |
|
23
|
|
|
* |
|
24
|
|
|
* @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingLanguageHandler |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $languageHandler; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Language mask generator. |
|
30
|
|
|
* |
|
31
|
|
|
* @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $languageMaskGenerator; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Returns a language handler mock. |
|
37
|
|
|
* |
|
38
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler |
|
39
|
|
|
*/ |
|
40
|
|
|
protected function getLanguageHandler() |
|
41
|
|
|
{ |
|
42
|
|
|
if (!isset($this->languageHandler)) { |
|
43
|
|
|
$this->languageHandler = new LanguageHandlerMock(); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
return $this->languageHandler; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Returns a language mask generator. |
|
51
|
|
|
* |
|
52
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator |
|
53
|
|
|
*/ |
|
54
|
|
|
protected function getLanguageMaskGenerator() |
|
55
|
|
|
{ |
|
56
|
|
|
if (!isset($this->languageMaskGenerator)) { |
|
57
|
|
|
$this->languageMaskGenerator = new LanguageMaskGenerator( |
|
58
|
|
|
$this->getLanguageHandler() |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return $this->languageMaskGenerator; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Return definition-based transformation processor instance. |
|
67
|
|
|
* |
|
68
|
|
|
* @return Persistence\TransformationProcessor\DefinitionBased |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function getDefinitionBasedTransformationProcessor() |
|
71
|
|
|
{ |
|
72
|
|
|
return new Persistence\TransformationProcessor\DefinitionBased( |
|
73
|
|
|
new Persistence\TransformationProcessor\DefinitionBased\Parser(), |
|
74
|
|
|
new Persistence\TransformationProcessor\PcreCompiler( |
|
75
|
|
|
new Persistence\Utf8Converter() |
|
76
|
|
|
), |
|
77
|
|
|
glob(__DIR__ . '/../../../../Persistence/Tests/TransformationProcessor/_fixtures/transformations/*.tr') |
|
78
|
|
|
); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @var \eZ\Publish\Core\Search\Common\FieldNameGenerator|\PHPUnit_Framework_MockObject_MockObject |
|
83
|
|
|
*/ |
|
84
|
|
|
protected $fieldNameGeneratorMock; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return \eZ\Publish\Core\Search\Common\FieldNameGenerator|\PHPUnit_Framework_MockObject_MockObject |
|
88
|
|
|
*/ |
|
89
|
|
View Code Duplication |
protected function getFieldNameGeneratorMock() |
|
90
|
|
|
{ |
|
91
|
|
|
if (!isset($this->fieldNameGeneratorMock)) { |
|
92
|
|
|
$this->fieldNameGeneratorMock = $this |
|
93
|
|
|
->getMockBuilder('eZ\\Publish\\Core\\Search\\Common\\FieldNameGenerator') |
|
94
|
|
|
->disableOriginalConstructor() |
|
95
|
|
|
->getMock(); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
return $this->fieldNameGeneratorMock; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param \eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler $contentTypeHandler |
|
103
|
|
|
* @return \eZ\Publish\Core\Search\Legacy\Content\Mapper\FullTextMapper |
|
104
|
|
|
*/ |
|
105
|
|
|
protected function getFullTextMapper(Persistence\Legacy\Content\Type\Handler $contentTypeHandler) |
|
106
|
|
|
{ |
|
107
|
|
|
return new FullTextMapper( |
|
108
|
|
|
$this->getMock('\\eZ\\Publish\\Core\\Search\\Common\\FieldRegistry'), |
|
109
|
|
|
$contentTypeHandler |
|
110
|
|
|
); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Get FullText search configuration. |
|
115
|
|
|
*/ |
|
116
|
|
|
protected function getFullTextSearchConfiguration() |
|
117
|
|
|
{ |
|
118
|
|
|
return [ |
|
119
|
|
|
'stopWordThresholdFactor' => 0.66, |
|
120
|
|
|
'enableWildcards' => true, |
|
121
|
|
|
'commands' => [ |
|
122
|
|
|
'apostrophe_normalize', |
|
123
|
|
|
'apostrophe_to_doublequote', |
|
124
|
|
|
'ascii_lowercase', |
|
125
|
|
|
'ascii_search_cleanup', |
|
126
|
|
|
'cyrillic_diacritical', |
|
127
|
|
|
'cyrillic_lowercase', |
|
128
|
|
|
'cyrillic_search_cleanup', |
|
129
|
|
|
'cyrillic_transliterate_ascii', |
|
130
|
|
|
'doublequote_normalize', |
|
131
|
|
|
'endline_search_normalize', |
|
132
|
|
|
'greek_diacritical', |
|
133
|
|
|
'greek_lowercase', |
|
134
|
|
|
'greek_normalize', |
|
135
|
|
|
'greek_transliterate_ascii', |
|
136
|
|
|
'hebrew_transliterate_ascii', |
|
137
|
|
|
'hyphen_normalize', |
|
138
|
|
|
'inverted_to_normal', |
|
139
|
|
|
'latin1_diacritical', |
|
140
|
|
|
'latin1_lowercase', |
|
141
|
|
|
'latin1_transliterate_ascii', |
|
142
|
|
|
'latin-exta_diacritical', |
|
143
|
|
|
'latin-exta_lowercase', |
|
144
|
|
|
'latin-exta_transliterate_ascii', |
|
145
|
|
|
'latin_lowercase', |
|
146
|
|
|
'latin_search_cleanup', |
|
147
|
|
|
'latin_search_decompose', |
|
148
|
|
|
'math_to_ascii', |
|
149
|
|
|
'punctuation_normalize', |
|
150
|
|
|
'space_normalize', |
|
151
|
|
|
'special_decompose', |
|
152
|
|
|
'specialwords_search_normalize', |
|
153
|
|
|
'tab_search_normalize', |
|
154
|
|
|
], |
|
155
|
|
|
]; |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..