1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SG\Tests; |
4
|
|
|
|
5
|
|
|
use SG\PropertyRegistrationHelper; |
6
|
|
|
use SMW\DIProperty; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @covers \SG\PropertyRegistrationHelper |
10
|
|
|
* @group semantic-glossary |
11
|
|
|
* |
12
|
|
|
* @license GNU GPL v2+ |
13
|
|
|
* @since 1.0 |
14
|
|
|
* |
15
|
|
|
* @author mwjames |
16
|
|
|
*/ |
17
|
|
|
class PropertyRegistrationHelperTest extends \PHPUnit_Framework_TestCase { |
18
|
|
|
|
19
|
|
|
public function testCanConstruct() { |
20
|
|
|
|
21
|
|
|
$propertyRegistry = |
22
|
|
|
$this->getMockBuilder( '\SMW\PropertyRegistry' ) |
23
|
|
|
->disableOriginalConstructor() |
24
|
|
|
->getMock(); |
25
|
|
|
|
26
|
|
|
$propertyRegistrationHelper = new PropertyRegistrationHelper( $propertyRegistry ); |
27
|
|
|
|
28
|
|
|
$this->assertInstanceOf( |
29
|
|
|
'\SG\PropertyRegistrationHelper', |
30
|
|
|
$propertyRegistrationHelper |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testRegisterProperties() { |
35
|
|
|
|
36
|
|
|
$propertyRegistry = |
37
|
|
|
$this->getMockBuilder( '\SMW\PropertyRegistry' ) |
38
|
|
|
->disableOriginalConstructor() |
39
|
|
|
->getMock(); |
40
|
|
|
|
41
|
|
|
$propertyRegistry |
42
|
|
|
->expects( $this->exactly( 4 ) ) |
43
|
|
|
->method( 'registerProperty' ); |
44
|
|
|
|
45
|
|
|
$propertyRegistry |
46
|
|
|
->expects( $this->exactly( 4 ) ) |
47
|
|
|
->method( 'registerPropertyAlias' ); |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
$propertyRegistrationHelper = new PropertyRegistrationHelper( $propertyRegistry ); |
51
|
|
|
|
52
|
|
|
$this->assertTrue( |
53
|
|
|
$propertyRegistrationHelper->registerProperties() |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @dataProvider propertyDefinitionDataProvider |
59
|
|
|
* |
60
|
|
|
* @param string $id |
61
|
|
|
* @param string $label |
62
|
|
|
*/ |
63
|
|
|
public function testRegisteredPropertyById( $id, $label ) { |
64
|
|
|
|
65
|
|
|
$property = new DIProperty( $id ); |
66
|
|
|
|
67
|
|
|
$this->assertInstanceOf( '\SMW\DIProperty', $property ); |
68
|
|
|
$this->assertEquals( $label, $property->getLabel() ); |
69
|
|
|
$this->assertTrue( $property->isShown() ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string[][] |
74
|
|
|
*/ |
75
|
|
|
public function propertyDefinitionDataProvider() { |
76
|
|
|
|
77
|
|
|
$provider = array(); |
78
|
|
|
|
79
|
|
|
$provider[] = array( PropertyRegistrationHelper::SG_TERM, SG_PROP_GLT ); |
80
|
|
|
$provider[] = array( PropertyRegistrationHelper::SG_DEFINITION, SG_PROP_GLD ); |
81
|
|
|
$provider[] = array( PropertyRegistrationHelper::SG_LINK, SG_PROP_GLL ); |
82
|
|
|
$provider[] = array( PropertyRegistrationHelper::SG_STYLE, SG_PROP_GLS ); |
83
|
|
|
|
84
|
|
|
return $provider; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
} |
88
|
|
|
|