Test Failed
Push — clear ( 90ec73...ed29c3 )
by no
04:02
created

HashArrayTest::testRemoveElement()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 29
Code Lines 15

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 29
rs 8.8571
cc 3
eloc 15
nc 3
nop 1
1
<?php
2
3
namespace Wikibase\DataModel\Tests\HashArray;
4
5
use Wikibase\DataModel\HashArray;
6
7
/**
8
 * @covers Wikibase\DataModel\HashArray
9
 *
10
 * @group Wikibase
11
 * @group WikibaseDataModel
12
 * @group HashArray
13
 *
14
 * @license GPL-2.0+
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
abstract class HashArrayTest extends \PHPUnit_Framework_TestCase {
18
19
	public abstract function constructorProvider();
20
21
	/**
22
	 * Returns the name of the concrete class being tested.
23
	 *
24
	 * @since 0.4
25
	 *
26
	 * @return string
27
	 */
28
	abstract public function getInstanceClass();
29
30
	public function instanceProvider() {
31
		$class = $this->getInstanceClass();
32
33
		$instances = [];
34
35
		foreach ( $this->constructorProvider() as $args ) {
36
			$instances[] = [ new $class( array_key_exists( 0, $args ) ? $args[0] : null ) ];
37
		}
38
39
		return $instances;
40
	}
41
42
	/**
43
	 * @dataProvider instanceProvider
44
	 * @param HashArray $array
45
	 */
46
	public function testEquals( HashArray $array ) {
47
		$this->assertTrue( $array->equals( $array ) );
48
		$this->assertFalse( $array->equals( 42 ) );
49
	}
50
51
	/**
52
	 * @param array $elements
53
	 *
54
	 * @return array[]
55
	 */
56
	protected function arrayWrap( array $elements ) {
57
		return array_map(
58
			function ( $element ) {
59
				return [ $element ];
60
			},
61
			$elements
62
		);
63
	}
64
65
}
66