1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Tests\Query\ProfileAnnotators; |
4
|
|
|
|
5
|
|
|
use SMW\DIWikiPage; |
6
|
|
|
use SMW\Query\ProfileAnnotators\FormatProfileAnnotator; |
7
|
|
|
use SMW\Query\ProfileAnnotators\NullProfileAnnotator; |
8
|
|
|
use SMW\Tests\Utils\UtilityFactory; |
9
|
|
|
use SMWContainerSemanticData as ContainerSemanticData; |
10
|
|
|
use SMWDIContainer as DIContainer; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @covers \SMW\Query\ProfileAnnotators\FormatProfileAnnotator |
14
|
|
|
* @group semantic-mediawiki |
15
|
|
|
* |
16
|
|
|
* @license GNU GPL v2+ |
17
|
|
|
* @since 1.9 |
18
|
|
|
* |
19
|
|
|
* @author mwjames |
20
|
|
|
*/ |
21
|
|
|
class FormatProfileAnnotatorTest extends \PHPUnit_Framework_TestCase { |
22
|
|
|
|
23
|
|
|
private $semanticDataValidator; |
24
|
|
|
|
25
|
|
|
protected function setUp() { |
26
|
|
|
parent::setUp(); |
27
|
|
|
|
28
|
|
|
$this->semanticDataValidator = UtilityFactory::getInstance()->newValidatorFactory()->newSemanticDataValidator(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testCanConstruct() { |
32
|
|
|
|
33
|
|
|
$profileAnnotator = $this->getMockBuilder( '\SMW\Query\ProfileAnnotator' ) |
34
|
|
|
->disableOriginalConstructor() |
35
|
|
|
->getMock(); |
36
|
|
|
|
37
|
|
|
$this->assertInstanceOf( |
38
|
|
|
'\SMW\Query\ProfileAnnotators\FormatProfileAnnotator', |
39
|
|
|
new FormatProfileAnnotator( $profileAnnotator, 'table' ) |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testCreateProfile() { |
44
|
|
|
|
45
|
|
|
$subject =new DIWikiPage( __METHOD__, NS_MAIN, '', 'foo' ); |
46
|
|
|
|
47
|
|
|
$container = new DIContainer( |
48
|
|
|
new ContainerSemanticData( $subject ) |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
$instance = new FormatProfileAnnotator( |
52
|
|
|
new NullProfileAnnotator( $container ), |
53
|
|
|
'table' |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
$instance->addAnnotation(); |
57
|
|
|
|
58
|
|
|
$expected = array( |
59
|
|
|
'propertyCount' => 1, |
60
|
|
|
'propertyKeys' => array( '_ASKFO' ), |
61
|
|
|
'propertyValues' => array( 'table' ) |
62
|
|
|
); |
63
|
|
|
|
64
|
|
|
$this->semanticDataValidator->assertThatPropertiesAreSet( |
65
|
|
|
$expected, |
66
|
|
|
$instance->getContainer()->getSemanticData() |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
} |
71
|
|
|
|