Completed
Push — master ( 6c0735...dd8543 )
by Dennis
06:47
created

WP_Test_MslsJson   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_add_get_methods() 0 15 1
A test___toString_methods() 0 5 1
1
<?php
2
/**
3
 * Tests for MslsJson
4
 *
5
 * @author Dennis Ploetner <[email protected]>
6
 * @package Msls
7
 */
8
9
use lloc\Msls\MslsJson;
10
11
/**
12
 * WP_Test_MslsJson
13
 */
14
class WP_Test_MslsJson extends Msls_UnitTestCase {
15
16
	/**
17
	 * Verify the add- and the get-methods
18
	 */
19
	function test_add_get_methods() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
20
		$obj = new MslsJson();
21
		$obj->add( null, 'Test 3' )
22
			->add( '2', 'Test 2' )
23
			->add( 1, 'Test 1' );
24
25
		$expected = [
26
			[ 'value' => 1, 'label' => 'Test 1' ],
27
			[ 'value' => 2, 'label' => 'Test 2' ],
28
			[ 'value' => 0, 'label' => 'Test 3' ],
29
		];
30
		$this->assertEquals( $expected, $obj->get() );
31
32
		return $obj;
33
	}
34
35
	/**
36
	 * Verify the encode and the __toString-method
37
	 *
38
	 * @depends test_add_get_methods
39
	 */
40
	function test___toString_methods( $obj ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style introduced by
The function name test___toString_methods is in camel caps, but expected test__to_string_methods instead as per the coding standard.
Loading history...
41
		$string = '[{"value":1,"label":"Test 1"},{"value":2,"label":"Test 2"},{"value":0,"label":"Test 3"}]';
42
		$this->assertEquals( $string, $obj->encode() );
43
		$this->assertEquals( $string, $obj->__toString() );
44
	}
45
46
}
47