blob: 2bcceb92de0bf9b1c5bd41206380ebe60f8676bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
namespace SMW\Tests\SQLStore\QueryEngine\DescriptionInterpreters;
use SMW\Query\DescriptionFactory;
use SMW\SQLStore\QueryEngine\DescriptionInterpreters\NamespaceDescriptionInterpreter;
use SMW\SQLStore\QueryEngineFactory;
use SMW\Tests\TestEnvironment;
/**
* @covers \SMW\SQLStore\QueryEngine\DescriptionInterpreters\NamespaceDescriptionInterpreter
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 2.2
*
* @author mwjames
*/
class NamespaceDescriptionInterpreterTest extends \PHPUnit_Framework_TestCase {
private $querySegmentValidator;
private $descriptionFactory;
protected function setUp() {
parent::setUp();
$this->descriptionFactory = new DescriptionFactory();
$testEnvironment = new TestEnvironment();
$this->querySegmentValidator = $testEnvironment->getUtilityFactory()->newValidatorFactory()->newQuerySegmentValidator();
}
public function testCanConstruct() {
$querySegmentListBuilder = $this->getMockBuilder( '\SMW\SQLStore\QueryEngine\QuerySegmentListBuilder' )
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->assertInstanceOf(
'\SMW\SQLStore\QueryEngine\DescriptionInterpreters\NamespaceDescriptionInterpreter',
new NamespaceDescriptionInterpreter( $querySegmentListBuilder )
);
}
public function testInterpretDescription() {
$connection = $this->getMockBuilder( '\SMW\MediaWiki\Database' )
->disableOriginalConstructor()
->getMock();
$store = $this->getMockBuilder( '\SMW\SQLStore\SQLStore' )
->disableOriginalConstructor()
->getMock();
$store->expects( $this->any() )
->method( 'getConnection' )
->will( $this->returnValue( $connection ) );
$queryEngineFactory = new QueryEngineFactory( $store );
$description = $this->descriptionFactory->newNamespaceDescription(
NS_HELP
);
$expected = new \stdClass;
$expected->type = 1;
$expected->where = "t0.smw_namespace=";
$instance = new NamespaceDescriptionInterpreter(
$queryEngineFactory->newQuerySegmentListBuilder()
);
$this->assertTrue(
$instance->canInterpretDescription( $description )
);
$this->querySegmentValidator->assertThatContainerHasProperties(
$expected,
$instance->interpretDescription( $description )
);
}
}
|