summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Utils/HtmlTabsTest.php
blob: 89b014506afbff9f4fb9c151248759fd8a303e92 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php

namespace SMW\Tests\Utils;

use SMW\Utils\HtmlTabs;

/**
 * @covers \SMW\Utils\HtmlTabs
 * @group semantic-mediawiki
 *
 * @license GNU GPL v2+
 * @since 3.0
 *
 * @author mwjames
 */
class HtmlTabsTest extends \PHPUnit_Framework_TestCase {

	public function testTab_Contents() {

		$instance = new HtmlTabs();
		$instance->setActiveTab( 'foo' );
		$instance->tab( 'foo', 'FOO' );
		$instance->content( 'foo', '< ... bar ... >' );

		$this->assertContains(
			'<div class="smw-tabs foo-bar">' .
			'<input id="tab-foo" class="nav-tab" type="radio" name="tabs" checked=""/>' .
			'<label id="tab-label-foo" for="tab-foo" class="nav-label">FOO</label>' .
			'<section id="tab-content-foo">< ... bar ... ></section>'.
			'</div>',
			$instance->buildHTML( [ 'class' => 'foo-bar' ] )
		);
	}

	public function testTab_Contents_AutoChecked() {

		$instance = new HtmlTabs();
		$instance->tab( 'foo', 'FOO' );
		$instance->content( 'foo', '< ... bar ... >' );

		$this->assertContains(
			'<div class="smw-tabs foo-bar">' .
			'<input id="tab-foo" class="nav-tab" type="radio" name="tabs" checked=""/>' .
			'<label id="tab-label-foo" for="tab-foo" class="nav-label">FOO</label>' .
			'<section id="tab-content-foo">< ... bar ... ></section>'.
			'</div>',
			$instance->buildHTML( [ 'class' => 'foo-bar' ] )
		);
	}

	public function testTab_Contents_Hidden() {

		$instance = new HtmlTabs();

		$instance->tab( 'foo', 'FOO', [ 'hide' => true ] );
		$instance->content( 'foo', '< ... bar ... >' );

		$this->assertContains(
			'<div class="smw-tabs foo-bar"></div>',
			$instance->buildHTML( [ 'class' => 'foo-bar' ] )
		);
	}

	public function testTab_WithExtraHtml() {

		$instance = new HtmlTabs();

		$instance->tab( 'foo', 'FOO' );
		$instance->content( 'foo', '< ... bar ... >' );
		$instance->html( '<span>Foobar</span>' );

		$this->assertContains(
			'<span>Foobar</span>',
			$instance->buildHTML()
		);
	}

}