ScribuntoLuaLibraryInfoTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 56
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTestModules() 0 5 1
A testInfo() 0 32 1
1
<?php
2
3
namespace SMW\Scribunto\Tests;
4
5
/**
6
 * @covers \SMW\Scribunto\ScribuntoLuaLibrary
7
 * @group semantic-scribunto
8
 *
9
 * @license GNU GPL v2+
10
 * @since 1.0
11
 *
12
 * @author Tobias Oetterer
13
 */
14
class ScribuntoLuaLibraryInfoTest extends ScribuntoLuaEngineTestBase {
15
16
	/**
17
	 * Lua test module
18
	 * @var string
19
	 */
20
	protected static $moduleName = self::class;
21
22
	/**
23
	 * ScribuntoLuaEngineTestBase::getTestModules
24
	 */
25
	public function getTestModules() {
26
		return parent::getTestModules() + [
27
			self::$moduleName => __DIR__ . '/' . 'mw.smw.info.tests.lua',
28
		];
29
	}
30
31
32
	/**
33
	 * Tests method info
34
	 *
35
	 * @return void
36
	 */
37
	public function testInfo() {
38
		$this->assertEmpty(
39
			$this->getScribuntoLuaLibrary()->info( null )
40
		);
41
		$this->assertEmpty(
42
			$this->getScribuntoLuaLibrary()->info( '' )
43
		);
44
		$this->assertInternalType(
45
			'string',
46
			$this->getScribuntoLuaLibrary()->info( 'Test info text' )[0]
47
		);
48
		$this->assertStringStartsWith(
49
			'<span',
50
			$this->getScribuntoLuaLibrary()->info( 'Test info text' )[0]
51
		);
52
		$this->assertStringEndsWith(
53
			'</span>',
54
			$this->getScribuntoLuaLibrary()->info( 'Test info text' )[0]
55
		);
56
		$this->assertEquals(
57
			1,
58
			preg_match('~^<span class=.*<span class="[^"]*info">.*>Test info text<.*</span>$~', $this->getScribuntoLuaLibrary()->info( 'Test info text' )[0])
59
		);
60
		$this->assertEquals(
61
			1,
62
			preg_match('~^<span class=.*<span class="[^"]*warning">.*>Test info text<.*</span>$~', $this->getScribuntoLuaLibrary()->info( 'Test info text', 'warning' )[0])
63
		);
64
		$this->assertEquals(
65
			1,
66
			preg_match('~^<span class=.*<span class="[^"]*info">.*>Test info text<.*</span>$~', $this->getScribuntoLuaLibrary()->info( 'Test info text', 'invalid' )[0])
67
		);
68
	}
69
}