| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Wikibase\DataModel\Tests\Term; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use InvalidArgumentException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use OutOfBoundsException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Wikibase\DataModel\Term\Term; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Wikibase\DataModel\Term\TermList; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @covers \Wikibase\DataModel\Term\TermList | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @uses \Wikibase\DataModel\Term\Term | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @license GPL-2.0+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @author Jeroen De Dauw < [email protected] > | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class TermListTest extends \PHPUnit_Framework_TestCase { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	public function testIsEmpty() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 		$this->assertTrue( $list->isEmpty() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		$list = new TermList( [ new Term( 'en', 'foo' ) ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		$this->assertFalse( $list->isEmpty() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	public function testGivenNoTerms_sizeIsZero() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 		$this->assertCount( 0, $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	public function testGivenTwoTerms_countReturnsTwo() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 		$list = new TermList( $this->getTwoTerms() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 		$this->assertCount( 2, $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	private function getTwoTerms() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 			'en' => new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 			'de' => new Term( 'de', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	public function testGivenTwoTerms_listContainsThem() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		$array = $this->getTwoTerms(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		$list = new TermList( $array ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		$this->assertEquals( $array, iterator_to_array( $list ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	public function testGivenTermsWithTheSameLanguage_onlyTheLastOnesAreRetained() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		$array = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 			new Term( 'en', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 			new Term( 'de', 'baz' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			new Term( 'nl', 'bah' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 			new Term( 'nl', 'blah' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 			new Term( 'nl', 'spam' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		$list = new TermList( $array ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		$this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 			[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 				'en' => new Term( 'en', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 				'de' => new Term( 'de', 'baz' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 				'nl' => new Term( 'nl', 'spam' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 			], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 			iterator_to_array( $list ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	public function testGivenNoTerms_toTextArrayReturnsEmptyArray() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 		$this->assertEquals( [], $list->toTextArray() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	public function testGivenTerms_toTextArrayReturnsTermsInFormat() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 			new Term( 'de', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		$this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 			[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 				'en' => 'foo', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 				'de' => 'bar', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 			], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 			$list->toTextArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	public function testCanIterateOverList() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		foreach ( $list as $key => $term ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 			$this->assertEquals( 'en', $key ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 			$this->assertEquals( new Term( 'en', 'foo' ), $term ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	public function testGivenSetLanguageCode_getByLanguageReturnsGroup() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		$enTerm = new Term( 'en', 'a' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 			new Term( 'de', 'b' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 			$enTerm, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 			new Term( 'nl', 'c' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 		$this->assertEquals( $enTerm, $list->getByLanguage( 'en' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 	 * @dataProvider invalidLanguageCodeProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	public function testGivenInvalidLanguageCode_getByLanguageThrowsException( $languageCode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 		$this->setExpectedException( OutOfBoundsException::class ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		$list->getByLanguage( $languageCode ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 	public function testGivenNonSetLanguageCode_getByLanguageThrowsException() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 		$this->setExpectedException( OutOfBoundsException::class ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 		$list->getByLanguage( 'en' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	public function testHasTermForLanguage() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 			new Term( 'de', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		$this->assertTrue( $list->hasTermForLanguage( 'en' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		$this->assertTrue( $list->hasTermForLanguage( 'de' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 		$this->assertFalse( $list->hasTermForLanguage( 'nl' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		$this->assertFalse( $list->hasTermForLanguage( 'fr' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		$this->assertFalse( $list->hasTermForLanguage( 'EN' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 		$this->assertFalse( $list->hasTermForLanguage( ' de ' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	 * @dataProvider invalidLanguageCodeProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	public function testGivenInvalidLanguageCode_hasTermForLanguageReturnsFalse( $languageCode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 		$this->assertFalse( $list->hasTermForLanguage( $languageCode ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	public function invalidLanguageCodeProvider() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 		return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 			[ null ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 			[ 21 ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 			[ '' ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	public function testGivenNotSetLanguageCode_removeByLanguageDoesNoOp() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 			new Term( 'de', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 		$list->removeByLanguage( 'nl' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 		$this->assertCount( 2, $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 	public function testGivenSetLanguageCode_removeByLanguageRemovesIt() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 		$deTerm = new Term( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 			$deTerm, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 		$list->removeByLanguage( 'en' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 		$this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 			[ 'de' => $deTerm ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 			iterator_to_array( $list ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 	 * @dataProvider invalidLanguageCodeProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 	public function testGivenInvalidLanguageCode_removeByLanguageDoesNoOp( $languageCode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 		$list = new TermList( [ new Term( 'en', 'foo' ) ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 		$list->removeByLanguage( $languageCode ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 		$this->assertFalse( $list->isEmpty() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 	public function testGivenTermForNewLanguage_setTermAddsTerm() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 		$enTerm = new Term( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 		$deTerm = new Term( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 		$list = new TermList( [ $enTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 		$expectedList = new TermList( [ $enTerm, $deTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 		$list->setTerm( $deTerm ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 		$this->assertEquals( $expectedList, $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 	public function testGivenTermForExistingLanguage_setTermReplacesTerm() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 		$enTerm = new Term( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 		$newEnTerm = new Term( 'en', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 		$list = new TermList( [ $enTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 		$expectedList = new TermList( [ $newEnTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 		$list->setTerm( $newEnTerm ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 		$this->assertEquals( $expectedList, $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 	public function testEmptyListEqualsEmptyList() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 		$this->assertTrue( $list->equals( new TermList() ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  | 	public function testFilledListEqualsItself() { | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  | 		$list = new TermList( [ | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  | 			new Term( 'de', 'bar' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  | 		] ); | 
            
                                                                        
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 238 |  |  | 		$this->assertTrue( $list->equals( $list ) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 239 |  |  | 		$this->assertTrue( $list->equals( clone $list ) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 240 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 	public function testDifferentListsDoNotEqual() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 			new Term( 'de', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 		$this->assertFalse( $list->equals( new TermList() ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 		$this->assertFalse( $list->equals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 			new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 				new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 			] ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 		$this->assertFalse( $list->equals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 			new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 				new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 				new Term( 'de', 'HAX' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 			] ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 		$this->assertFalse( $list->equals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 			new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 				new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 				new Term( 'de', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 				new Term( 'nl', 'baz' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 			] ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 	public function testGivenNonTermList_equalsReturnsFalse() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 		$this->assertFalse( $list->equals( null ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 		$this->assertFalse( $list->equals( new \stdClass() ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 	public function testGivenListsThatOnlyDifferInOrder_equalsReturnsTrue() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 			new Term( 'de', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 		$this->assertTrue( $list->equals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 			new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 				new Term( 'de', 'bar' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 				new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 			] ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 	public function testGivenNonSetLanguageTerm_hasTermReturnsFalse() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 		$this->assertFalse( $list->hasTerm( new Term( 'en', 'kittens' ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 	public function testGivenMismatchingTerm_hasTermReturnsFalse() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 		$list = new TermList( [ new Term( 'en', 'cats' ) ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 		$this->assertFalse( $list->hasTerm( new Term( 'en', 'kittens' ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 	public function testGivenMatchingTerm_hasTermReturnsTrue() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 		$list = new TermList( [ new Term( 'en', 'kittens' ) ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 		$this->assertTrue( $list->hasTerm( new Term( 'en', 'kittens' ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 	public function testGivenValidArgs_setTermTextSetsTerm() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 		$list->setTextForLanguage( 'en', 'kittens' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 		$this->assertTrue( $list->getByLanguage( 'en' )->equals( new Term( 'en', 'kittens' ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 	public function testGivenInvalidLanguageCode_setTermTextThrowsException() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 		$this->setExpectedException( InvalidArgumentException::class ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 		$list->setTextForLanguage( null, 'kittens' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 	public function testGivenInvalidTermText_setTermTextThrowsException() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 		$this->setExpectedException( InvalidArgumentException::class ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 		$list->setTextForLanguage( 'en', null ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 	public function testGivenEmptyList_getWithLanguagesReturnsEmptyList() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 		$this->assertEquals( new TermList(), $list->getWithLanguages( [] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 		$this->assertEquals( new TermList(), $list->getWithLanguages( [ 'en', 'de' ] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 	public function testGivenNoLanguages_getWithLanguagesReturnsEmptyList() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 		$list->setTextForLanguage( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 		$list->setTextForLanguage( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 		$this->assertEquals( new TermList(), $list->getWithLanguages( [] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 	public function testGivenAllLanguages_getWithLanguagesReturnsFullList() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 		$list->setTextForLanguage( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 		$list->setTextForLanguage( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 		$this->assertEquals( $list, $list->getWithLanguages( [ 'en', 'de' ] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 	public function testGivenSomeLanguages_getWithLanguagesReturnsPartialList() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 		$list->setTextForLanguage( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 		$list->setTextForLanguage( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 		$list->setTextForLanguage( 'nl', 'baz' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 		$list->setTextForLanguage( 'fr', 'hax' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 		$expectedList = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 		$expectedList->setTextForLanguage( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 		$expectedList->setTextForLanguage( 'nl', 'baz' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 		$this->assertEquals( $expectedList, $list->getWithLanguages( [ 'en', 'nl' ] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 	public function testGivenEmptyTerms_constructorOnlyAddsNonEmptyTerms() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 		$list = new TermList( [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 			new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 			new Term( 'de', '' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 			new Term( 'nl', 'baz' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 			new Term( 'fr', '' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 		] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 		$this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 			[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 				'en' => new Term( 'en', 'foo' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 				'nl' => new Term( 'nl', 'baz' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 			], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 			iterator_to_array( $list ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 	public function testGivenEmptyTerm_setTermDoesNotAddIt() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 		$list->setTerm( new Term( 'en', '' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 		$this->assertEquals( new TermList(), $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 	public function testGivenEmptyTerm_setTermRemovesExistingOne() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 		$list->setTerm( new Term( 'en', 'foo' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 		$list->setTerm( new Term( 'de', 'bar' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 		$list->setTerm( new Term( 'en', '' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 		$this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 			new TermList( [ new Term( 'de', 'bar' ) ] ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 			$list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 	public function testClear() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 		$list = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 		$list->setTextForLanguage( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 		$list->setTextForLanguage( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 		$list->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 		$this->assertEquals( new TermList(), $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 	public function testWhenAddingTermsToAListThatDoesNotContainThem_theyGetAdded() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 		$enTerm = new Term( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 		$deTerm = new Term( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		$terms = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 		$terms->addAll( [ $enTerm, $deTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 		$this->assertEquals( $enTerm, $terms->getByLanguage( 'en' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 		$this->assertEquals( $deTerm, $terms->getByLanguage( 'de' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 	public function testWhenAddingTermsToAListThatDoesContainThem_theyOverrideTheExistingOnes() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 		$enTerm = new Term( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 		$newEnTerm = new Term( 'en', 'NEW' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 		$terms = new TermList( [ $enTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 		$terms->addAll( [ $newEnTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 		$this->assertEquals( $newEnTerm, $terms->getByLanguage( 'en' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 	public function testWhenAddingTerms_existingOnesAreNotLost() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 		$enTerm = new Term( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 		$deTerm = new Term( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 		$terms = new TermList( [ $enTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 		$terms->addAll( [ $deTerm ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 		$this->assertEquals( $enTerm, $terms->getByLanguage( 'en' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 	public function testCanAddTermIterables() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 		$enTerm = new Term( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 		$terms = new TermList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 		$terms->addAll( new TermList( [ $enTerm ] ) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 		$this->assertEquals( $enTerm, $terms->getByLanguage( 'en' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 	public function testWhenAddingEmptyTerms_theyRemoveExistingOnes() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 		$terms = new TermList( [ new Term( 'en', 'not-empty' ) ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 		$terms->addAll( [ new Term( 'en', '' ) ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 		$this->assertEquals( new TermList(), $terms ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 	public function testCanConstructWithIterables() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 		$enTerm = new Term( 'en', 'foo' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 		$deTerm = new Term( 'de', 'bar' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 		$terms = new TermList( new TermList( [ $enTerm, $deTerm ] ) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 		$this->assertEquals( $enTerm, $terms->getByLanguage( 'en' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 		$this->assertEquals( $deTerm, $terms->getByLanguage( 'de' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 	public function testWhenProvidingNonTerms_constructorThrowsException() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 		$this->setExpectedException( InvalidArgumentException::class ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 		new TermList( [ 'no-a-term' ] ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 	public function testWhenProvidingNonTerms_addAllThrowsException() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 		$list = new TermList( [] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 		$this->setExpectedException( InvalidArgumentException::class ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 		$list->addAll( [ 'no-a-term' ] ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 482 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 483 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: