SimpleQueryServiceTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 5
dl 0
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testDoQuery() 0 24 1
1
<?php
2
3
namespace WikidataQueryApi\Services;
4
use Wikibase\DataModel\Entity\ItemId;
5
use Wikibase\DataModel\Entity\PropertyId;
6
use WikidataQueryApi\Query\ClaimQuery;
7
use WikidataQueryApi\Query\Serializers\ClaimQuerySerializer;
8
9
/**
10
 * @covers WikidataQueryApi\Services\SimpleQueryService
11
 *
12
 * @licence GPLv2+
13
 * @author Thomas Pellissier Tanon
14
 */
15
class SimpleQueryServiceTest extends \PHPUnit_Framework_TestCase {
16
17
	public function testDoQuery() {
18
		$apiMock = $this->getMockBuilder( 'WikidataQueryApi\WikidataQueryApi' )
19
			->disableOriginalConstructor()
20
			->getMock();
21
		$apiMock->expects( $this->any() )
22
			->method( 'doQuery' )
23
			->with( $this->equalTo( [
24
				'q' => 'claim[42:42]'
25
			] ) )
26
			->will( $this->returnValue( [
27
				'status' => [ 'error' => 'OK' ],
28
				'items' => [ 42 ]
29
			] ) );
30
31
		$service = new SimpleQueryService( $apiMock, new ClaimQuerySerializer() );
32
		$this->assertEquals(
33
			[
34
				new ItemId( 'Q42' )
35
			],
36
			$service->doQuery(
37
				new ClaimQuery( new PropertyId('P42'), new ItemId( 'Q42' ) )
38
			)
39
		);
40
	}
41
}
42