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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
<?php
namespace SMW\Test;
use SMW\ExtensionContext;
/**
* @covers \SMW\ExtensionContext
*
* @ingroup Test
*
* @group SMW
* @group SMWExtension
*
* @licence GNU GPL v2+
* @since 1.9
*
* @author mwjames
*/
class ExtensionContextTest extends SemanticMediaWikiTestCase {
/**
* @return string|false
*/
public function getClass() {
return '\SMW\ExtensionContext';
}
/**
* @since 1.9
*
* @return ExtensionContext
*/
private function newInstance( $builder = null ) {
return new ExtensionContext( $builder );
}
/**
* @since 1.9
*/
public function testConstructor() {
$this->assertInstanceOf( $this->getClass(), $this->newInstance() );
}
/**
* @since 1.9
*/
public function testGetSettings() {
$settings = $this->newSettings( array( 'Foo' => 'Bar' ) );
$instance = $this->newInstance();
$instance->getDependencyBuilder()->getContainer()->registerObject( 'Settings', $settings );
$this->assertInstanceOf(
'\SMW\Settings',
$instance->getSettings(),
'Asserts that getSettings() yields a Settings object'
);
$this->assertEquals(
$settings,
$instance->getSettings(),
'Asserts that getSettings() yields an expected result'
);
$this->assertTrue(
$instance->getSettings() === $instance->getDependencyBuilder()->newObject( 'Settings' ),
"Asserts that getSettings() returns the same instance (syncronized object instance)"
);
}
/**
* @since 1.9
*/
public function testGetStore() {
$store = $this->newMockBuilder()->newObject( 'Store' );
$instance = $this->newInstance();
$instance->getDependencyBuilder()->getContainer()->registerObject( 'Store', $store );
$this->assertInstanceOf(
'\SMW\Store',
$instance->getStore(),
'Asserts that getStore() yields a Store object'
);
$this->assertEquals(
$store,
$instance->getStore(),
'Asserts that getSettings() yields an expected result'
);
$this->assertTrue(
$instance->getStore() === $instance->getDependencyBuilder()->newObject( 'Store' ),
"Asserts that getStore() returns the same instance (syncronized object instance)"
);
}
/**
* @since 1.9
*/
public function testSetGetDependencyBuilder() {
$builder = $this->newDependencyBuilder();
$instance = $this->newInstance();
$this->assertInstanceOf(
'\SMW\DependencyBuilder',
$instance->getDependencyBuilder(),
'Asserts that getDependencyBuilder() yields a default DependencyBuilder object'
);
$instance = $this->newInstance( $builder );
$this->assertTrue(
$builder === $instance->getDependencyBuilder(),
'Asserts that getDependencyBuilder() yields the same instance used for constructor injection'
);
}
}
|