|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SIL\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use SIL\InterlanguageLink; |
|
6
|
|
|
use SIL\PropertyRegistry; |
|
7
|
|
|
|
|
8
|
|
|
use Title; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @covers \SIL\InterlanguageLink |
|
12
|
|
|
* |
|
13
|
|
|
* @group semantic-interlanguage-links |
|
14
|
|
|
* |
|
15
|
|
|
* @license GNU GPL v2+ |
|
16
|
|
|
* @since 1.0 |
|
17
|
|
|
* |
|
18
|
|
|
* @author mwjames |
|
19
|
|
|
*/ |
|
20
|
|
|
class InterlanguageLinkTest extends \PHPUnit_Framework_TestCase { |
|
21
|
|
|
|
|
22
|
|
|
public function testCanConstruct() { |
|
23
|
|
|
|
|
24
|
|
|
$this->assertInstanceOf( |
|
25
|
|
|
'\SIL\InterlanguageLink', |
|
26
|
|
|
new InterlanguageLink( 'en', 'Foo' ) |
|
27
|
|
|
); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testConstructorArgumentGetter() { |
|
31
|
|
|
|
|
32
|
|
|
$instance = new InterlanguageLink( 'en', 'Foo' ); |
|
33
|
|
|
|
|
34
|
|
|
$this->assertEquals( |
|
35
|
|
|
'en', |
|
36
|
|
|
$instance->getLanguageCode() |
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
$this->assertInstanceOf( |
|
40
|
|
|
'\Title', |
|
41
|
|
|
$instance->getLinkReference() |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testConstructDataValue() { |
|
46
|
|
|
|
|
47
|
|
|
$instance = new InterlanguageLink( 'en', 'Foo' ); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertInstanceOf( |
|
50
|
|
|
'\SMWDataValue', |
|
51
|
|
|
$instance->newLanguageDataValue() |
|
52
|
|
|
); |
|
53
|
|
|
|
|
54
|
|
|
$this->assertEquals( |
|
55
|
|
|
PropertyRegistry::SIL_ILL_LANG, |
|
56
|
|
|
$instance->newLanguageDataValue()->getProperty()->getKey() |
|
57
|
|
|
); |
|
58
|
|
|
|
|
59
|
|
|
$this->assertInstanceOf( |
|
60
|
|
|
'\SMWDataValue', |
|
61
|
|
|
$instance->newLinkReferenceDataValue() |
|
62
|
|
|
); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertEquals( |
|
65
|
|
|
PropertyRegistry::SIL_ILL_REF, |
|
66
|
|
|
$instance->newLinkReferenceDataValue()->getProperty()->getKey() |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertInstanceOf( |
|
70
|
|
|
'\SMW\DIProperty', |
|
71
|
|
|
$instance->newContainerProperty() |
|
72
|
|
|
); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertEquals( |
|
75
|
|
|
PropertyRegistry::SIL_CONTAINER, |
|
76
|
|
|
$instance->newContainerProperty()->getKey() |
|
77
|
|
|
); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function testGetHash() { |
|
81
|
|
|
|
|
82
|
|
|
$instance = new InterlanguageLink( 'en', 'Foo' ); |
|
83
|
|
|
|
|
84
|
|
|
$this->assertContains( |
|
85
|
|
|
'en#Foo', |
|
86
|
|
|
$instance->getHash() |
|
87
|
|
|
); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function testGetContainerId() { |
|
91
|
|
|
|
|
92
|
|
|
$instance = new InterlanguageLink( 'en', 'Foo' ); |
|
93
|
|
|
|
|
94
|
|
|
$this->assertContains( |
|
95
|
|
|
'ill.en', |
|
96
|
|
|
$instance->getContainerId() |
|
97
|
|
|
); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function testGetLinkReference() { |
|
101
|
|
|
|
|
102
|
|
|
$linkReference = Title::newFromText( __METHOD__ ); |
|
103
|
|
|
|
|
104
|
|
|
$instance = new InterlanguageLink( 'en', $linkReference ); |
|
105
|
|
|
|
|
106
|
|
|
$this->assertSame( |
|
107
|
|
|
$linkReference, |
|
108
|
|
|
$instance->getLinkReference() |
|
109
|
|
|
); |
|
110
|
|
|
|
|
111
|
|
|
$instance = new InterlanguageLink( 'en', __METHOD__ ); |
|
112
|
|
|
|
|
113
|
|
|
$this->assertEquals( |
|
114
|
|
|
$linkReference, |
|
115
|
|
|
$instance->getLinkReference() |
|
116
|
|
|
); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
} |
|
120
|
|
|
|