Passed
Pull Request — master (#136)
by None
03:40
created

PreTextFormatterTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 64
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SCI\Tests;
4
5
use SCI\PreTextFormatter;
6
use Title;
7
use Parser;
8
use ParserOptions;
9
use SMW\Tests\PHPUnitCompat;
10
11
/**
12
 * @covers \SCI\PreTextFormatter
13
 * @group semantic-cite
14
 *
15
 * @license GNU GPL v2+
16
 * @since 1.4
17
 *
18
 * @author mwjames
19
 */
20
class PreTextFormatterTest extends \PHPUnit_Framework_TestCase {
21
22
	use PHPUnitCompat;
23
24
	const LF = "\n";
25
26
	public function testCanConstruct() {
27
28
		$this->assertInstanceOf(
29
			'\SCI\PreTextFormatter',
30
			new PreTextFormatter()
31
		);
32
	}
33
34
	/**
35
	 * @dataProvider parametersProvider
36
	 */
37
	public function testFormat( $params ) {
38
39
		$instance = new PreTextFormatter();
40
41
		$this->assertInternalType(
42
			'array',
43
			$instance->format( $params )
44
		);
45
	}
46
47
	/**
48
	 * @dataProvider parametersProvider
49
	 */
50
	public function testGetFormattedSciteFuncFrom( $params, $expected ) {
51
52
		$instance = new PreTextFormatter();
53
54
		$this->assertSame(
55
			$expected,
56
			$instance->getFormattedSciteFuncFrom( $params )
57
		);
58
	}
59
60
	public function parametersProvider() {
61
62
		$provider[] = [
63
			[
64
				'Bar',
65
				'@Foobar'
66
			],
67
			"<pre>{{#scite:" . self::LF . " |Bar" . self::LF . "}}</pre>"
68
		];
69
70
		$provider[] = [
71
			[
72
				'Bar',
73
				'+sep=,',
74
				'@Foobar',
75
				'Foo'
76
			],
77
			"<pre>{{#scite:" . self::LF . " |Bar|+sep=," . self::LF . " |Foo" . self::LF . "}}</pre>"
78
		];
79
80
		return $provider;
81
	}
82
83
}
84