Skip to content
This repository was archived by the owner on Sep 16, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions tests/Integration/IntegrationStoreBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,18 @@ private function buildStore() {
* @return PropertyDataValueTypeLookup
*/
private function getPropertyDataValueTypeLookup() {
$propertyDvTypeLookup = $this->testCase->getMock( 'Wikibase\QueryEngine\PropertyDataValueTypeLookup' );
$testCase = $this->testCase;
$propertyDvTypeLookup = $testCase->getMock( 'Wikibase\QueryEngine\PropertyDataValueTypeLookup' );

$propertyDvTypeLookup->expects( $this->testCase->any() )
$propertyDvTypeLookup->expects( $testCase->any() )
->method( 'getDataValueTypeForProperty' )
->will( $this->testCase->returnValue( 'number' ) );
->will( $testCase->returnCallback( function() use ( $testCase ) {
if ( method_exists( $testCase, 'getDataValueType' ) ) {
return call_user_func( array( $testCase, 'getDataValueType' ) );
}

return 'number';
} ) );

return $propertyDvTypeLookup;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Wikibase\QueryEngine\Tests\Integration\SQLStore\DVHandler;

use DataValues\BooleanValue;
use Wikibase\QueryEngine\Tests\Integration\SQLStore\DataValueHandlerIntegrationTest;

/**
* @group Wikibase
* @group WikibaseQueryEngine
* @group WikibaseQueryEngineIntegration
*
* @group medium
*
* @licence GNU GPL v2+
* @author Thiemo Mättig
*/
class BooleanHandlerIntegrationTest extends DataValueHandlerIntegrationTest {

public function getDataValueType() {
return 'boolean';
}

protected function insertItems() {
$this->insertItem( 'Q10' );

$this->insertItem( 'Q20', new BooleanValue( false ) );

$this->insertItem( 'Q21', new BooleanValue( true ) );
}

public function queryProvider() {
return array(
array(
new BooleanValue( false ),
array( 'Q20' ),
),
array(
new BooleanValue( true ),
array( 'Q21' ),
),
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Wikibase\QueryEngine\Tests\Integration\SQLStore\DVHandler;

use Wikibase\DataModel\Entity\EntityIdValue;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\QueryEngine\Tests\Integration\SQLStore\DataValueHandlerIntegrationTest;

/**
* @group Wikibase
* @group WikibaseQueryEngine
* @group WikibaseQueryEngineIntegration
*
* @group medium
*
* @licence GNU GPL v2+
* @author Thiemo Mättig
*/
class EntityIdHandlerIntegrationTest extends DataValueHandlerIntegrationTest {

public function getDataValueType() {
return 'wikibase-entityid';
}

protected function insertItems() {
$this->insertItem( 'Q10' );

$this->insertItem( 'Q20', new EntityIdValue( new ItemId( 'Q30' ) ) );

$this->insertItem( 'Q21', new EntityIdValue( new ItemId( 'Q31' ) ) );
}

public function queryProvider() {
return array(
array(
new EntityIdValue( new ItemId( 'Q30' ) ),
array( 'Q20' ),
),
array(
new EntityIdValue( new ItemId( 'Q31' ) ),
array( 'Q21' ),
),
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Wikibase\QueryEngine\Tests\Integration\SQLStore\DVHandler;

use DataValues\GlobeCoordinateValue;
use DataValues\LatLongValue;
use Wikibase\QueryEngine\Tests\Integration\SQLStore\DataValueHandlerIntegrationTest;

/**
* @group Wikibase
* @group WikibaseQueryEngine
* @group WikibaseQueryEngineIntegration
*
* @group medium
*
* @licence GNU GPL v2+
* @author Thiemo Mättig
*/
class GlobeCoordinateHandlerIntegrationTest extends DataValueHandlerIntegrationTest {

public function getDataValueType() {
return 'globecoordinate';
}

protected function insertItems() {
$this->insertItem( 'Q10' );

$this->insertItem( 'Q20', new GlobeCoordinateValue( new LatLongValue( 0, 20 ), null ) );

$this->insertItem( 'Q21', new GlobeCoordinateValue( new LatLongValue( 0, 21 ), 10 ) );

$this->insertItem( 'Q22', new GlobeCoordinateValue( new LatLongValue( 0, 22 ), 0.1 ) );

$this->insertItem( 'Q23', new GlobeCoordinateValue( new LatLongValue( 0, 22 ), 0.1, 'Vulcan' ) );
}

public function queryProvider() {
return array(
array(
new GlobeCoordinateValue( new LatLongValue( 0, 20 ), null ),
array( 'Q20' ),
),
array(
new GlobeCoordinateValue( new LatLongValue( 0, 21 ), null ),
array( 'Q21' ),
),
array(
new GlobeCoordinateValue( new LatLongValue( 0, 22 ), 0.1 ),
array( 'Q22' ),
),
array(
new GlobeCoordinateValue( new LatLongValue( 0, 22 ), 1 ),
array( 'Q21', 'Q22' ),
),
array(
new GlobeCoordinateValue( new LatLongValue( 0, 22 ), 0.1, 'Vulcan' ),
array( 'Q23' ),
),
);
}

}
45 changes: 45 additions & 0 deletions tests/Integration/SQLStore/DVHandler/IriHandlerIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Wikibase\QueryEngine\Tests\Integration\SQLStore\DVHandler;

use DataValues\IriValue;
use Wikibase\QueryEngine\Tests\Integration\SQLStore\DataValueHandlerIntegrationTest;

/**
* @group Wikibase
* @group WikibaseQueryEngine
* @group WikibaseQueryEngineIntegration
*
* @group medium
*
* @licence GNU GPL v2+
* @author Thiemo Mättig
*/
class IriHandlerIntegrationTest extends DataValueHandlerIntegrationTest {

public function getDataValueType() {
return 'iri';
}

protected function insertItems() {
$this->insertItem( 'Q10' );

$this->insertItem( 'Q20', new IriValue( 'http', '//www.wikidata.org/' ) );

$this->insertItem( 'Q21', new IriValue( 'http', '//en.wikipedia.org/' ) );
}

public function queryProvider() {
return array(
array(
new IriValue( 'http', '//www.wikidata.org/' ),
array( 'Q20' ),
),
array(
new IriValue( 'http', '//en.wikipedia.org/' ),
array( 'Q21' ),
),
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Wikibase\QueryEngine\Tests\Integration\SQLStore\DVHandler;

use DataValues\MonolingualTextValue;
use Wikibase\QueryEngine\Tests\Integration\SQLStore\DataValueHandlerIntegrationTest;

/**
* @group Wikibase
* @group WikibaseQueryEngine
* @group WikibaseQueryEngineIntegration
*
* @group medium
*
* @licence GNU GPL v2+
* @author Thiemo Mättig
*/
class MonolingualTextHandlerIntegrationTest extends DataValueHandlerIntegrationTest {

public function getDataValueType() {
return 'monolingualtext';
}

protected function insertItems() {
$this->insertItem( 'Q10' );

$this->insertItem( 'Q20', new MonolingualTextValue( 'en', 'A' ) );

$this->insertItem( 'Q21', new MonolingualTextValue( 'en', 'B' ) );
}

public function queryProvider() {
return array(
array(
new MonolingualTextValue( 'en', 'A' ),
array( 'Q20' ),
),
array(
new MonolingualTextValue( 'en', 'B' ),
array( 'Q21' ),
),
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Wikibase\QueryEngine\Tests\Integration\SQLStore\DVHandler;

use DataValues\NumberValue;
use Wikibase\QueryEngine\Tests\Integration\SQLStore\DataValueHandlerIntegrationTest;

/**
* @group Wikibase
* @group WikibaseQueryEngine
* @group WikibaseQueryEngineIntegration
*
* @group medium
*
* @licence GNU GPL v2+
* @author Thiemo Mättig
*/
class NumberHandlerIntegrationTest extends DataValueHandlerIntegrationTest {

public function getDataValueType() {
return 'number';
}

protected function insertItems() {
$this->insertItem( 'Q10' );

$this->insertItem( 'Q20', new NumberValue( 20 ) );

$this->insertItem( 'Q21', new NumberValue( 21 ) );
}

public function queryProvider() {
return array(
array(
new NumberValue( 20 ),
array( 'Q20' ),
),
array(
new NumberValue( 21 ),
array( 'Q21' ),
),
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Wikibase\QueryEngine\Tests\Integration\SQLStore\DVHandler;

use DataValues\DecimalValue;
use DataValues\QuantityValue;
use Wikibase\QueryEngine\Tests\Integration\SQLStore\DataValueHandlerIntegrationTest;

/**
* @group Wikibase
* @group WikibaseQueryEngine
* @group WikibaseQueryEngineIntegration
*
* @group medium
*
* @licence GNU GPL v2+
* @author Thiemo Mättig
*/
class QuantityHandlerIntegrationTest extends DataValueHandlerIntegrationTest {

public function getDataValueType() {
return 'quantity';
}

protected function insertItems() {
$this->insertItem( 'Q10' );

$amount = new DecimalValue( 20 );
$this->insertItem( 'Q20', new QuantityValue( $amount, '1', $amount, $amount ) );

$amount = new DecimalValue( 21 );
$this->insertItem( 'Q21', new QuantityValue( $amount, '1', $amount, $amount ) );
}

public function queryProvider() {
$amount1 = new DecimalValue( 20 );
$amount2 = new DecimalValue( 21 );

return array(
array(
new QuantityValue( $amount1, '1', $amount1, $amount1 ),
array( 'Q20' ),
),
array(
new QuantityValue( $amount2, '1', $amount2, $amount2 ),
array( 'Q21' ),
),
);
}

}
Loading