1 | <?php |
||
16 | class TermListTest extends \PHPUnit_Framework_TestCase { |
||
17 | |||
18 | public function testIsEmpty() { |
||
19 | $list = new TermList(); |
||
20 | $this->assertTrue( $list->isEmpty() ); |
||
21 | |||
22 | $list = new TermList( array( new Term( 'en', 'foo' ) ) ); |
||
23 | $this->assertFalse( $list->isEmpty() ); |
||
24 | } |
||
25 | |||
26 | public function testGivenNoTerms_sizeIsZero() { |
||
30 | |||
31 | public function testGivenTwoTerms_countReturnsTwo() { |
||
32 | $list = new TermList( $this->getTwoTerms() ); |
||
33 | |||
34 | $this->assertCount( 2, $list ); |
||
35 | } |
||
36 | |||
37 | private function getTwoTerms() { |
||
38 | return array( |
||
39 | 'en' => new Term( 'en', 'foo' ), |
||
40 | 'de' => new Term( 'de', 'bar' ), |
||
41 | ); |
||
42 | } |
||
43 | |||
44 | public function testGivenTwoTerms_listContainsThem() { |
||
45 | $array = $this->getTwoTerms(); |
||
46 | |||
47 | $list = new TermList( $array ); |
||
48 | |||
49 | $this->assertEquals( $array, iterator_to_array( $list ) ); |
||
50 | } |
||
51 | |||
52 | public function testGivenTermsWithTheSameLanguage_onlyTheLastOnesAreRetained() { |
||
53 | $array = array( |
||
54 | new Term( 'en', 'foo' ), |
||
55 | new Term( 'en', 'bar' ), |
||
56 | |||
57 | new Term( 'de', 'baz' ), |
||
58 | |||
59 | new Term( 'nl', 'bah' ), |
||
60 | new Term( 'nl', 'blah' ), |
||
61 | new Term( 'nl', 'spam' ), |
||
62 | ); |
||
63 | |||
64 | $list = new TermList( $array ); |
||
65 | |||
66 | $this->assertEquals( |
||
67 | array( |
||
68 | 'en' => new Term( 'en', 'bar' ), |
||
69 | 'de' => new Term( 'de', 'baz' ), |
||
70 | 'nl' => new Term( 'nl', 'spam' ), |
||
71 | ), |
||
72 | iterator_to_array( $list ) |
||
73 | ); |
||
74 | } |
||
75 | |||
76 | public function testGivenNoTerms_toTextArrayReturnsEmptyArray() { |
||
80 | |||
81 | public function testGivenTerms_toTextArrayReturnsTermsInFormat() { |
||
82 | $list = new TermList( array( |
||
83 | new Term( 'en', 'foo' ), |
||
84 | new Term( 'de', 'bar' ), |
||
85 | ) ); |
||
95 | |||
96 | public function testCanIterateOverList() { |
||
106 | |||
107 | public function testGivenSetLanguageCode_getByLanguageReturnsGroup() { |
||
118 | |||
119 | /** |
||
120 | * @dataProvider invalidLanguageCodeProvider |
||
121 | */ |
||
122 | public function testGivenInvalidLanguageCode_getByLanguageThrowsException( $languageCode ) { |
||
123 | $list = new TermList(); |
||
124 | $this->setExpectedException( 'OutOfBoundsException' ); |
||
|
|||
125 | $list->getByLanguage( $languageCode ); |
||
126 | } |
||
127 | |||
128 | public function testGivenNonSetLanguageCode_getByLanguageThrowsException() { |
||
134 | |||
135 | public function testHasTermForLanguage() { |
||
150 | |||
151 | /** |
||
152 | * @dataProvider invalidLanguageCodeProvider |
||
153 | */ |
||
154 | public function testGivenInvalidLanguageCode_hasTermForLanguageReturnsFalse( $languageCode ) { |
||
158 | |||
159 | public function invalidLanguageCodeProvider() { |
||
166 | |||
167 | public function testGivenNotSetLanguageCode_removeByLanguageDoesNoOp() { |
||
177 | |||
178 | public function testGivenSetLanguageCode_removeByLanguageRemovesIt() { |
||
193 | |||
194 | /** |
||
195 | * @dataProvider invalidLanguageCodeProvider |
||
196 | */ |
||
197 | public function testGivenInvalidLanguageCode_removeByLanguageDoesNoOp( $languageCode ) { |
||
202 | |||
203 | public function testGivenTermForNewLanguage_setTermAddsTerm() { |
||
214 | |||
215 | public function testGivenTermForExistingLanguage_setTermReplacesTerm() { |
||
225 | |||
226 | public function testEmptyListEqualsEmptyList() { |
||
230 | |||
231 | public function testFilledListEqualsItself() { |
||
240 | |||
241 | public function testDifferentListsDoNotEqual() { |
||
270 | |||
271 | public function testGivenNonTermList_equalsReturnsFalse() { |
||
276 | |||
277 | public function testGivenListsThatOnlyDifferInOrder_equalsReturnsTrue() { |
||
290 | |||
291 | public function testGivenNonSetLanguageTerm_hasTermReturnsFalse() { |
||
295 | |||
296 | public function testGivenMismatchingTerm_hasTermReturnsFalse() { |
||
300 | |||
301 | public function testGivenMatchingTerm_hasTermReturnsTrue() { |
||
305 | |||
306 | public function testGivenValidArgs_setTermTextSetsTerm() { |
||
313 | |||
314 | public function testGivenInvalidLanguageCode_setTermTextThrowsException() { |
||
320 | |||
321 | public function testGivenInvalidTermText_setTermTextThrowsException() { |
||
327 | |||
328 | public function testGivenEmptyList_getWithLanguagesReturnsEmptyList() { |
||
333 | |||
334 | public function testGivenNoLanguages_getWithLanguagesReturnsEmptyList() { |
||
341 | |||
342 | public function testGivenAllLanguages_getWithLanguagesReturnsFullList() { |
||
349 | |||
350 | public function testGivenSomeLanguages_getWithLanguagesReturnsPartialList() { |
||
363 | |||
364 | public function testGivenEmptyTerms_constructorOnlyAddsNonEmptyTerms() { |
||
380 | |||
381 | public function testGivenEmptyTerm_setTermDoesNotAddIt() { |
||
387 | |||
388 | public function testGivenEmptyTerm_setTermRemovesExistingOne() { |
||
399 | |||
400 | } |
||
401 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.