blob: 89f42abf5f02f448f94f5d3a6de85a1b37b21c53 (
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
100
|
<?php
namespace SMW\Test;
use SMW\Profiler;
use ReflectionClass;
/**
* Tests for the Profiler class
*
* @file
*
* @license GNU GPL v2+
* @since 1.9
*
* @author mwjames
*/
/**
* @covers \SMW\Profiler
*
* @ingroup Test
*
* @group SMW
* @group SMWExtension
*/
class ProfilerTest extends SemanticMediaWikiTestCase {
/**
* Holds original values of MediaWiki configuration settings
* @var array
*/
private $mwGlobals = array();
/** Set-up */
protected function setUp() {
parent::setUp();
$this->mwGlobals['wgProfiler'] = $GLOBALS['wgProfiler'];
$GLOBALS['wgProfiler']['class'] = '\ProfilerStub';
}
/** Tear down */
protected function tearDown() {
$GLOBALS['wgProfiler'] = $this->mwGlobals['wgProfiler'];
$this->mwGlobals = array();
parent::tearDown();
}
/**
* Returns the name of the class to be tested
*
* @return string|false
*/
public function getClass() {
return '\SMW\Profiler';
}
/**
* @test Profiler::getInstance
* @test Profiler::reset
*
* @since 1.9
*/
public function testGetInstance() {
// Never mind the unset here because setup/tearDown
// stores the original setting
unset( $GLOBALS['wgProfiler'] );
$this->assertEquals( null, Profiler::getInstance() );
$GLOBALS['wgProfiler']['class'] = '\ProfilerStub';
Profiler::reset();
$instance = Profiler::getInstance();
$this->assertInstanceOf( '\ProfilerStub', $instance );
$this->assertTrue( $instance === Profiler::getInstance(), 'Failed asserting that the instance is identical' );
}
/**
* @test Profiler::In
* @test Profiler::Out
*
* @since 1.9
*/
public function testInOut() {
Profiler::reset();
$this->assertInstanceOf( '\ProfilerStub', Profiler::In( 'Lala' ) );
$this->assertInstanceOf( '\ProfilerStub', Profiler::Out( 'Lala' ) );
$this->assertInstanceOf( '\ProfilerStub', Profiler::In( 'Lila', true ) );
$this->assertInstanceOf( '\ProfilerStub', Profiler::Out( 'Lila', true ) );
}
}
|