testDefaultOptionWithValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Wikibase\EntityStore;
4
5
/**
6
 * @covers Wikibase\EntityStore\EntityStoreOptions
7
 *
8
 * @licence GNU GPL v2+
9
 * @author Thomas Pellissier Tanon
10
 */
11
class EntityStoreOptionsTest extends \PHPUnit_Framework_TestCase {
12
13
	public function testGetOption() {
14
		$options = new EntityStoreOptions( [ 'foo' => 'bar' ] );
15
		$this->assertEquals(
16
			'bar',
17
			$options->getOption( 'foo' )
18
		);
19
	}
20
21
	public function testGetOptionWithException() {
22
		$options = new EntityStoreOptions();
23
24
		$this->setExpectedException( 'InvalidArgumentException' );
25
		$options->getOption( 'foo' );
26
	}
27
28
	public function testSetOption() {
29
		$options = new EntityStoreOptions();
30
		$options->setOption( 'foo', 'bar' );
31
32
		$this->assertEquals(
33
			'bar',
34
			$options->getOption( 'foo' )
35
		);
36
	}
37
38
	public function testHasOption() {
39
		$options = new EntityStoreOptions( [ 'foo' => 'bar' ] );
40
41
		$this->assertTrue( $options->hasOption( 'foo' ) );
42
		$this->assertFalse( $options->hasOption( 'bar' ) );
43
	}
44
45
	public function testDefaultOptionWithoutValue() {
46
		$options = new EntityStoreOptions();
47
		$options->defaultOption( 'foo', 'bar' );
48
49
		$this->assertEquals(
50
			'bar',
51
			$options->getOption( 'foo' )
52
		);
53
	}
54
55
	public function testDefaultOptionWithValue() {
56
		$options = new EntityStoreOptions( [ 'foo' => 'bar'] );
57
		$options->defaultOption( 'foo', 'baz' );
58
59
		$this->assertEquals(
60
			'bar',
61
			$options->getOption( 'foo' )
62
		);
63
	}
64
}
65