| Conditions | 1 |
| Paths | 1 |
| Total Lines | 44 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function testGetEntityIdsForTerm() { |
||
| 19 | $mediawikiApiMock = $this->getMockBuilder( 'Mediawiki\Api\MediawikiApi' ) |
||
| 20 | ->disableOriginalConstructor() |
||
| 21 | ->getMock(); |
||
| 22 | $mediawikiApiMock->expects( $this->once() ) |
||
| 23 | ->method( 'getRequest' ) |
||
| 24 | ->with( $this->equalTo( |
||
| 25 | new SimpleRequest( |
||
| 26 | 'wbsearchentities', |
||
| 27 | [ |
||
| 28 | 'search' => 'foo', |
||
| 29 | 'language' => 'en', |
||
| 30 | 'type' => 'item', |
||
| 31 | 'limit' => 50 |
||
| 32 | ] |
||
| 33 | ) |
||
| 34 | ) ) |
||
| 35 | ->will( $this->returnValue( [ |
||
| 36 | 'search' => [ |
||
| 37 | [ |
||
| 38 | 'id' => 'Q1', |
||
| 39 | 'label' => 'foo', |
||
| 40 | 'aliases' => [ 'bar', 'baz' ] |
||
| 41 | ], |
||
| 42 | [ |
||
| 43 | 'id' => 'Q2', |
||
| 44 | 'label' => 'bar', |
||
| 45 | 'aliases' => [ 'baz', 'foo' ] |
||
| 46 | ], |
||
| 47 | [ |
||
| 48 | 'id' => 'Q3', |
||
| 49 | 'label' => 'bar', |
||
| 50 | 'aliases' => [ 'baz' ] |
||
| 51 | ] |
||
| 52 | ] |
||
| 53 | ] ) ); |
||
| 54 | |||
| 55 | $lookup = new ApiEntityIdForTermLookup( $mediawikiApiMock, new BasicEntityIdParser() ); |
||
| 56 | |||
| 57 | $this->assertEquals( |
||
| 58 | [ new ItemId( 'Q1' ), new ItemId( 'Q2' ) ], |
||
| 59 | $lookup->getEntityIdsForTerm( new Term( 'en', 'foo' ), 'item' ) |
||
| 60 | ); |
||
| 61 | } |
||
| 62 | } |
||
| 63 |