These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Wikibase\DataModel\Tests\Term; |
||
| 4 | |||
| 5 | use InvalidArgumentException; |
||
| 6 | use Wikibase\DataModel\Term\Term; |
||
| 7 | use Wikibase\DataModel\Term\TermFallback; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @covers Wikibase\DataModel\Term\Term |
||
| 11 | * |
||
| 12 | * @licence GNU GPL v2+ |
||
| 13 | * @author Jeroen De Dauw < [email protected] > |
||
| 14 | */ |
||
| 15 | class TermTest extends \PHPUnit_Framework_TestCase { |
||
| 16 | |||
| 17 | public function testConstructorSetsFields() { |
||
| 18 | $term = new Term( 'foo', 'bar' ); |
||
| 19 | $this->assertEquals( 'foo', $term->getLanguageCode() ); |
||
| 20 | $this->assertEquals( 'bar', $term->getText() ); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @dataProvider invalidLanguageCodeProvider |
||
| 25 | * @expectedException InvalidArgumentException |
||
| 26 | */ |
||
| 27 | public function testGivenInvalidLanguageCode_constructorThrowsException( $languageCode ) { |
||
| 28 | new Term( $languageCode, 'bar' ); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function invalidLanguageCodeProvider() { |
||
| 32 | return array( |
||
| 33 | array( null ), |
||
| 34 | array( 21 ), |
||
| 35 | array( '' ), |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @dataProvider nonStringProvider |
||
| 41 | */ |
||
| 42 | public function testGivenNonStringText_constructorThrowsException( $nonString ) { |
||
| 43 | $this->setExpectedException( 'InvalidArgumentException' ); |
||
|
0 ignored issues
–
show
|
|||
| 44 | new Term( 'foo', $nonString ); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function nonStringProvider() { |
||
| 48 | return array( |
||
| 49 | array( null ), |
||
| 50 | array( array() ), |
||
| 51 | array( 42 ), |
||
| 52 | array( true ), |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | |||
| 56 | public function testEquality() { |
||
| 57 | $term = new Term( 'foo', 'bar' ); |
||
| 58 | |||
| 59 | $this->assertTrue( $term->equals( $term ) ); |
||
| 60 | $this->assertTrue( $term->equals( clone $term ) ); |
||
| 61 | |||
| 62 | $this->assertFalse( $term->equals( new Term( 'foo', 'spam' ) ) ); |
||
| 63 | $this->assertFalse( $term->equals( new Term( 'spam', 'bar' ) ) ); |
||
| 64 | $this->assertFalse( $term->equals( new Term( 'spam', 'spam' ) ) ); |
||
| 65 | } |
||
| 66 | |||
| 67 | public function testGivenSimilarFallbackObject_equalsReturnsFalse() { |
||
| 68 | $term = new Term( 'de', 'foo' ); |
||
| 69 | $termFallback = new TermFallback( 'de', 'foo', 'en', null ); |
||
| 70 | $this->assertFalse( $term->equals( $termFallback ) ); |
||
| 71 | } |
||
| 72 | |||
| 73 | } |
||
| 74 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.