diff options
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php')
-rw-r--r-- | vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php | 223 |
1 files changed, 0 insertions, 223 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php deleted file mode 100644 index 600236eb..00000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php +++ /dev/null | |||
@@ -1,223 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle\Reader; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReader; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class StructuredBundleReaderTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | const RES_DIR = '/res/dir'; | ||
22 | |||
23 | /** | ||
24 | * @var StructuredBundleReader | ||
25 | */ | ||
26 | private $reader; | ||
27 | |||
28 | /** | ||
29 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
30 | */ | ||
31 | private $readerImpl; | ||
32 | |||
33 | protected function setUp() | ||
34 | { | ||
35 | $this->readerImpl = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface'); | ||
36 | $this->reader = new StructuredBundleReader($this->readerImpl); | ||
37 | } | ||
38 | |||
39 | public function testGetLocales() | ||
40 | { | ||
41 | $locales = array('en', 'de', 'fr'); | ||
42 | |||
43 | $this->readerImpl->expects($this->once()) | ||
44 | ->method('getLocales') | ||
45 | ->with(self::RES_DIR) | ||
46 | ->will($this->returnValue($locales)); | ||
47 | |||
48 | $this->assertSame($locales, $this->reader->getLocales(self::RES_DIR)); | ||
49 | } | ||
50 | |||
51 | public function testRead() | ||
52 | { | ||
53 | $data = array('foo', 'bar'); | ||
54 | |||
55 | $this->readerImpl->expects($this->once()) | ||
56 | ->method('read') | ||
57 | ->with(self::RES_DIR, 'en') | ||
58 | ->will($this->returnValue($data)); | ||
59 | |||
60 | $this->assertSame($data, $this->reader->read(self::RES_DIR, 'en')); | ||
61 | } | ||
62 | |||
63 | public function testReadEntryNoParams() | ||
64 | { | ||
65 | $data = array('foo', 'bar'); | ||
66 | |||
67 | $this->readerImpl->expects($this->once()) | ||
68 | ->method('read') | ||
69 | ->with(self::RES_DIR, 'en') | ||
70 | ->will($this->returnValue($data)); | ||
71 | |||
72 | $this->assertSame($data, $this->reader->readEntry(self::RES_DIR, 'en', array())); | ||
73 | } | ||
74 | |||
75 | public function testReadEntryWithParam() | ||
76 | { | ||
77 | $data = array('Foo' => array('Bar' => 'Baz')); | ||
78 | |||
79 | $this->readerImpl->expects($this->once()) | ||
80 | ->method('read') | ||
81 | ->with(self::RES_DIR, 'en') | ||
82 | ->will($this->returnValue($data)); | ||
83 | |||
84 | $this->assertSame('Baz', $this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar'))); | ||
85 | } | ||
86 | |||
87 | public function testReadEntryWithUnresolvablePath() | ||
88 | { | ||
89 | $data = array('Foo' => 'Baz'); | ||
90 | |||
91 | $this->readerImpl->expects($this->once()) | ||
92 | ->method('read') | ||
93 | ->with(self::RES_DIR, 'en') | ||
94 | ->will($this->returnValue($data)); | ||
95 | |||
96 | $this->assertNull($this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar'))); | ||
97 | } | ||
98 | |||
99 | public function readMergedEntryProvider() | ||
100 | { | ||
101 | return array( | ||
102 | array('foo', null, 'foo'), | ||
103 | array(null, 'foo', 'foo'), | ||
104 | array(array('foo', 'bar'), null, array('foo', 'bar')), | ||
105 | array(array('foo', 'bar'), array(), array('foo', 'bar')), | ||
106 | array(null, array('baz'), array('baz')), | ||
107 | array(array(), array('baz'), array('baz')), | ||
108 | array(array('foo', 'bar'), array('baz'), array('baz', 'foo', 'bar')), | ||
109 | ); | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * @dataProvider readMergedEntryProvider | ||
114 | */ | ||
115 | public function testReadMergedEntryNoParams($childData, $parentData, $result) | ||
116 | { | ||
117 | $this->readerImpl->expects($this->at(0)) | ||
118 | ->method('read') | ||
119 | ->with(self::RES_DIR, 'en_GB') | ||
120 | ->will($this->returnValue($childData)); | ||
121 | |||
122 | if (null === $childData || is_array($childData)) { | ||
123 | $this->readerImpl->expects($this->at(1)) | ||
124 | ->method('read') | ||
125 | ->with(self::RES_DIR, 'en') | ||
126 | ->will($this->returnValue($parentData)); | ||
127 | } | ||
128 | |||
129 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array(), true)); | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * @dataProvider readMergedEntryProvider | ||
134 | */ | ||
135 | public function testReadMergedEntryWithParams($childData, $parentData, $result) | ||
136 | { | ||
137 | $this->readerImpl->expects($this->at(0)) | ||
138 | ->method('read') | ||
139 | ->with(self::RES_DIR, 'en_GB') | ||
140 | ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); | ||
141 | |||
142 | if (null === $childData || is_array($childData)) { | ||
143 | $this->readerImpl->expects($this->at(1)) | ||
144 | ->method('read') | ||
145 | ->with(self::RES_DIR, 'en') | ||
146 | ->will($this->returnValue(array('Foo' => array('Bar' => $parentData)))); | ||
147 | } | ||
148 | |||
149 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
150 | } | ||
151 | |||
152 | public function testReadMergedEntryWithUnresolvablePath() | ||
153 | { | ||
154 | $this->readerImpl->expects($this->at(0)) | ||
155 | ->method('read') | ||
156 | ->with(self::RES_DIR, 'en_GB') | ||
157 | ->will($this->returnValue(array('Foo' => 'Baz'))); | ||
158 | |||
159 | $this->readerImpl->expects($this->at(1)) | ||
160 | ->method('read') | ||
161 | ->with(self::RES_DIR, 'en') | ||
162 | ->will($this->returnValue(array('Foo' => 'Bar'))); | ||
163 | |||
164 | $this->assertNull($this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
165 | } | ||
166 | |||
167 | public function testReadMergedEntryWithUnresolvablePathInParent() | ||
168 | { | ||
169 | $this->readerImpl->expects($this->at(0)) | ||
170 | ->method('read') | ||
171 | ->with(self::RES_DIR, 'en_GB') | ||
172 | ->will($this->returnValue(array('Foo' => array('Bar' => array('three'))))); | ||
173 | |||
174 | $this->readerImpl->expects($this->at(1)) | ||
175 | ->method('read') | ||
176 | ->with(self::RES_DIR, 'en') | ||
177 | ->will($this->returnValue(array('Foo' => 'Bar'))); | ||
178 | |||
179 | $result = array('three'); | ||
180 | |||
181 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
182 | } | ||
183 | |||
184 | public function testReadMergedEntryWithUnresolvablePathInChild() | ||
185 | { | ||
186 | $this->readerImpl->expects($this->at(0)) | ||
187 | ->method('read') | ||
188 | ->with(self::RES_DIR, 'en_GB') | ||
189 | ->will($this->returnValue(array('Foo' => 'Baz'))); | ||
190 | |||
191 | $this->readerImpl->expects($this->at(1)) | ||
192 | ->method('read') | ||
193 | ->with(self::RES_DIR, 'en') | ||
194 | ->will($this->returnValue(array('Foo' => array('Bar' => array('one', 'two'))))); | ||
195 | |||
196 | $result = array('one', 'two'); | ||
197 | |||
198 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * @dataProvider readMergedEntryProvider | ||
203 | */ | ||
204 | public function testReadMergedEntryWithTraversables($childData, $parentData, $result) | ||
205 | { | ||
206 | $parentData = is_array($parentData) ? new \ArrayObject($parentData) : $parentData; | ||
207 | $childData = is_array($childData) ? new \ArrayObject($childData) : $childData; | ||
208 | |||
209 | $this->readerImpl->expects($this->at(0)) | ||
210 | ->method('read') | ||
211 | ->with(self::RES_DIR, 'en_GB') | ||
212 | ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); | ||
213 | |||
214 | if (null === $childData || $childData instanceof \ArrayObject) { | ||
215 | $this->readerImpl->expects($this->at(1)) | ||
216 | ->method('read') | ||
217 | ->with(self::RES_DIR, 'en') | ||
218 | ->will($this->returnValue(array('Foo' => array('Bar' => $parentData)))); | ||
219 | } | ||
220 | |||
221 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
222 | } | ||
223 | } | ||