Passed
Push — currentLimits ( f9050f...3572e3 )
by no
08:17 queued 04:47
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 Hashable;
6
use Wikibase\DataModel\HashArray;
7
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
8
9
/**
10
 * @covers Wikibase\DataModel\HashArray
11
 *
12
 * @group Wikibase
13
 * @group WikibaseDataModel
14
 * @group HashArray
15
 *
16
 * @license GPL-2.0+
17
 * @author Jeroen De Dauw < [email protected] >
18
 */
19
abstract class HashArrayTest extends \PHPUnit_Framework_TestCase {
20
21
	public abstract function constructorProvider();
22
23
	/**
24
	 * Returns the name of the concrete class being tested.
25
	 *
26
	 * @since 0.4
27
	 *
28
	 * @return string
29
	 */
30
	abstract public function getInstanceClass();
31
32
	public function instanceProvider() {
33
		$class = $this->getInstanceClass();
34
35
		$instances = [];
36
37
		foreach ( $this->constructorProvider() as $args ) {
38
			$instances[] = [ new $class( array_key_exists( 0, $args ) ? $args[0] : null ) ];
39
		}
40
41
		return $instances;
42
	}
43
44
	/**
45
	 * @dataProvider instanceProvider
46
	 * @param HashArray $array
47
	 */
48
	public function testEquals( HashArray $array ) {
49
		$this->assertTrue( $array->equals( $array ) );
50
		$this->assertFalse( $array->equals( 42 ) );
51
	}
52
53
	/**
54
	 * @param array $elements
55
	 *
56
	 * @return array[]
57
	 */
58
	protected function arrayWrap( array $elements ) {
59
		return array_map(
60
			function ( $element ) {
61
				return [ $element ];
62
			},
63
			$elements
64
		);
65
	}
66
67
}
68