Completed
Push — master ( 552173...c8702c )
by Tobias
12:00 queued 43s
created

AccordionTest::placeMeArgumentsProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace BootstrapComponents\Tests\Unit\Components;
4
5
use BootstrapComponents\Components\Accordion as Accordion;
6
use BootstrapComponents\Tests\Unit\ComponentsTestBase;
7
use \MWException;
8
9
/**
10
 * @covers  \BootstrapComponents\Components\Accordion
11
 *
12
 * @ingroup Test
13
 *
14
 * @group extension-bootstrap-components
15
 * @group mediawiki-databaseless
16
 *
17
 * @license GNU GPL v3+
18
 *
19
 * @since   1.0
20
 * @author  Tobias Oetterer
21
 */
22
class AccordionTest extends ComponentsTestBase {
23
24
	private $input = 'Accordion test text';
25
26
	/**
27
	 * @throws \MWException
28
	 */
29
	public function testCanConstruct() {
30
31
		$this->assertInstanceOf(
32
			'\\BootstrapComponents\\Components\\Accordion',
33
			new Accordion(
34
				$this->getComponentLibrary(),
35
				$this->getParserOutputHelper(),
36
				$this->getNestingController()
37
			)
38
		);
39
	}
40
41
	/**
42
	 * @param string $input
43
	 * @param array  $arguments
44
	 * @param string $expectedOutput
45
	 *
46
	 * @dataProvider placeMeArgumentsProvider
47
	 * @throws MWException
48
	 */
49
	public function testCanRender( $input, $arguments, $expectedOutput ) {
50
		$instance = new Accordion(
51
			$this->getComponentLibrary(),
52
			$this->getParserOutputHelper(),
53
			$this->getNestingController()
54
		);
55
56
		$parserRequest = $this->buildParserRequest( $input, $arguments );
57
58
		/** @noinspection PhpParamsInspection */
59
		$generatedOutput = $instance->parseComponent( $parserRequest );
60
		$this->assertEquals(
61
			$expectedOutput,
62
			$generatedOutput
63
		);
64
	}
65
66
	/**
67
	 * @return array
68
	 */
69
	public function placeMeArgumentsProvider() {
70
		return [
71
			'simple'        => [
72
				$this->input,
73
				[],
74
				'<div class="panel-group" id="bsc_accordion_NULL">' . $this->input . '</div>',
75
			],
76
			'add_css_class' => [
77
				$this->input,
78
				[ 'class' => 'test' ],
79
				'<div class="panel-group test" id="bsc_accordion_NULL">' . $this->input . '</div>',
80
			],
81
		];
82
	}
83
}
84