summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/OutputTest.php
blob: 7f124267341ad86a2b1199f9dec967bb3a21b143 (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
<?php

namespace SFS\Tests;

use SFS\Output;

/**
 * @covers  \SFS\Output
 * @group   semantic-forms-select
 *
 * @license GNU GPL v2+
 * @since   1.3
 *
 * @author  mwjames
 */
class OutputTest extends \PHPUnit_Framework_TestCase {
	private $data;

	protected function setUp() {
		parent::setUp();
		$this->data = [];
		$this->data['Foo'] = 'Bar';
		$this->data['Spam'] = 'Eggs';
	}

	protected function tearDown() {
		unset( $this->data );
		parent::tearDown();
	}

	public function testCanConstruct() {
		$this->assertInstanceOf( '\SFS\Output', new Output() );
	}

	public function testAddToHeadItem() {
		$ret = Output::addToHeadItem( $this->data );

		$this->assertArrayHasKey( 'Foo', $ret );
		$this->assertArrayHasKey( 'Spam', $ret );
	}

	public function testCommitToParserOutput() {
		global $wgOut;
		$expected_result = '[' . json_encode( $this->data ) . ']';
		Output::commitToParserOutput();
		$this->assertEquals(
			$expected_result, $wgOut->getJsConfigVars()['sf_select']
		);
	}
}