UserFieldsCreateTemplateTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 64
rs 10
c 1
b 0
f 0
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 7 1
A testExecuteForEmptyData() 0 18 1
B testExecuteForFalseUseData() 0 33 1
1
<?php
2
3
namespace SES\Tests;
4
5
use SES\UserFieldsCreateTemplate;
6
7
/**
8
 * @covers \SES\UserFieldsCreateTemplate
9
 *
10
 * @group semantic-signup
11
 *
12
 * @license GNU GPL v2+
13
 * @since 1.0
14
 *
15
 * @author mwjames
16
 */
17
class UserFieldsCreateTemplateTest extends \PHPUnit_Framework_TestCase {
18
19
	public function testCanConstruct() {
20
21
		$this->assertInstanceOf(
22
			'\SES\UserFieldsCreateTemplate',
23
			new UserFieldsCreateTemplate()
24
		);
25
	}
26
27
	public function testExecuteForEmptyData() {
28
29
		$instance = new UserFieldsCreateTemplate();
30
31
		$outputPage = $this->getMockBuilder( '\OutputPage' )
32
			->disableOriginalConstructor()
33
			->getMock();
34
35
		$GLOBALS['wgOut'] = $outputPage;
36
37
		ob_start();
38
		$instance->execute();
39
		$text = ob_get_clean();
40
41
		$this->assertEmpty(
42
			$text
43
		);
44
	}
45
46
	public function testExecuteForFalseUseData() {
47
48
		$instance = new UserFieldsCreateTemplate();
49
50
		$instance->set( 'link', 'http:://example.org' );
51
		$instance->set( 'header', 'Foo' );
52
		$instance->set( 'usedomain', false );
53
		$instance->set( 'useemail', false );
54
		$instance->set( 'userealname', false );
55
56
		// MW developers are marvellous creatures
57
		// QuickTemplate::msgWiki is calling `global $wgOut;`
58
59
		$outputPage = $this->getMockBuilder( '\OutputPage' )
60
			->disableOriginalConstructor()
61
			->getMock();
62
63
		$GLOBALS['wgOut'] = $outputPage;
64
65
		ob_start();
66
		$instance->execute();
67
		$text = ob_get_clean();
68
69
		$this->assertInternalType(
70
			'string',
71
			$text
72
		);
73
74
		$this->assertContains(
75
			'http:://example.org',
76
			$text
77
		);
78
	}
79
80
}
81