summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/ResultPrinters/ListResultPrinter/ParameterDictionaryTest.php
blob: 15a9d80749c3669e350e1d05c848c02f83c0db09 (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
<?php

namespace SMW\Tests\Query\ResultPrinters\ListResultPrinter;

use SMW\Query\ResultPrinters\ListResultPrinter\ParameterDictionary;

/**
 * @covers \SMW\Query\ResultPrinters\ListResultPrinter\ParameterDictionary
 * @group semantic-mediawiki
 *
 * @license GNU GPL v2+
 * @since 3.0
 *
 * @author Stephan Gambke
 */
class ParameterDictionaryTest extends \PHPUnit_Framework_TestCase {

	public function testSetGet() {

		$dict = new ParameterDictionary();

		$dict->set( 'foo', 'Derek' );
		$dict->set( 'bar', 'Devin' );
		$dict->set( 'foo', 'Chelsea' );

		$this->assertEquals( 'Chelsea', $dict->get( 'foo' ) );
		$this->assertEquals( 'Devin', $dict->get( 'bar' ) );
	}

	public function testSetArrayGet() {

		$dict = new ParameterDictionary();

		$dict->set( ['foo' => 'Derek', 'bar' => 'Devin' ] );
		$dict->set( ['foo' => 'Chelsea', 'baz' => 'Carolynn' ] );

		$this->assertEquals( 'Chelsea', $dict->get( 'foo' ) );
		$this->assertEquals( 'Devin', $dict->get( 'bar' ) );
		$this->assertEquals( 'Carolynn', $dict->get( 'baz' ) );
	}

	public function testSetDefaultGet() {

		$dict = new ParameterDictionary();

		$dict->setDefault( 'foo', 'Derek' );
		$dict->setDefault( 'bar', 'Devin' );
		$dict->setDefault( 'foo', 'Chelsea' );

		$this->assertEquals( 'Derek', $dict->get( 'foo' ) );
		$this->assertEquals( 'Devin', $dict->get( 'bar' ) );
	}

	public function testSetDefaultArrayGet() {

		$dict = new ParameterDictionary();

		$dict->set( ['foo' => 'Derek', 'bar' => 'Devin' ] );
		$dict->setDefault( ['foo' => 'Chelsea', 'baz' => 'Carolynn' ] );

		$this->assertEquals( 'Derek', $dict->get( 'foo' ) );
		$this->assertEquals( 'Devin', $dict->get( 'bar' ) );
		$this->assertEquals( 'Carolynn', $dict->get( 'baz' ) );
	}

}