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
|
|
|
|
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..