blob: 1ce9d3c00c6c6fa4ad6e06d474c0bc55ad5a3802 (
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<?php
namespace SMW\Tests;
use SMW\NamespaceExaminer;
/**
* @covers \SMW\NamespaceExaminer
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 1.9
*
* @author mwjames
*/
class NamespaceExaminerTest extends \PHPUnit_Framework_TestCase {
use PHPUnitCompat;
public function testCanConstruct() {
$this->assertInstanceOf(
'\SMW\NamespaceExaminer',
new NamespaceExaminer( [] )
);
$this->assertInstanceOf(
'\SMW\NamespaceExaminer',
NamespaceExaminer::newFromArray( [] )
);
$this->assertInstanceOf(
'\SMW\NamespaceExaminer',
NamespaceExaminer::getInstance()
);
}
public function testIsSemanticEnabled() {
$instance = new NamespaceExaminer( [ NS_MAIN => true ] );
$this->assertTrue(
$instance->isSemanticEnabled( NS_MAIN )
);
$instance = new NamespaceExaminer( [ NS_MAIN => false ] );
$this->assertFalse(
$instance->isSemanticEnabled( NS_MAIN )
);
}
public function testNoNumberNamespaceThrowsException() {
$instance = new NamespaceExaminer( [ NS_MAIN => true ] );
$this->setExpectedException( 'InvalidArgumentException' );
$instance->isSemanticEnabled( 'ichi' );
}
/**
* Bug 51435; return false instead of an Exception
*/
public function testNoValidNamespaceException() {
$instance = new NamespaceExaminer( [ NS_MAIN => true ] );
$this->assertFalse(
$instance->isSemanticEnabled( 99991001 )
);
}
public function testGetInstance() {
$instance = NamespaceExaminer::getInstance();
$this->assertSame(
$instance,
NamespaceExaminer::getInstance()
);
NamespaceExaminer::clear();
$this->assertNotSame(
$instance,
NamespaceExaminer::getInstance()
);
}
public function testNewFromArray() {
$instance = NamespaceExaminer::newFromArray( [ NS_MAIN => true ] );
$this->assertTrue(
$instance->isSemanticEnabled( NS_MAIN )
);
}
}
|