Skip to content

Commit 3ce0e84

Browse files
authored
Merge pull request #727 from wmde/abstractTestStuff
Inline all abstract stuff from HashArrayTest to the implementations
2 parents c145f77 + 4ded0b3 commit 3ce0e84

3 files changed

Lines changed: 13 additions & 50 deletions

File tree

tests/unit/HashArray/HashArrayTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,6 @@
1414
*/
1515
abstract class HashArrayTest extends \PHPUnit_Framework_TestCase {
1616

17-
public abstract function constructorProvider();
18-
19-
/**
20-
* Returns the name of the concrete class being tested.
21-
*
22-
* @since 0.4
23-
*
24-
* @return string
25-
*/
26-
abstract public function getInstanceClass();
27-
28-
public function instanceProvider() {
29-
$class = $this->getInstanceClass();
30-
31-
$instances = [];
32-
33-
foreach ( $this->constructorProvider() as $args ) {
34-
$instances[] = [ new $class( array_key_exists( 0, $args ) ? $args[0] : [] ) ];
35-
}
36-
37-
return $instances;
38-
}
39-
4017
/**
4118
* @param array $elements
4219
*

tests/unit/HashArray/HashArrayWithoutDuplicatesTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Hashable;
66
use Wikibase\DataModel\Fixtures\HashArrayElement;
7+
use Wikibase\DataModel\Fixtures\HashArrayWithoutDuplicates;
78
use Wikibase\DataModel\HashArray;
89
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
910

@@ -19,17 +20,10 @@
1920
*/
2021
class HashArrayWithoutDuplicatesTest extends HashArrayTest {
2122

22-
public function constructorProvider() {
23-
$argLists = [];
24-
25-
$argLists[] = [ HashArrayElement::getInstances() ];
26-
$argLists[] = [ array_merge( HashArrayElement::getInstances(), HashArrayElement::getInstances() ) ];
27-
28-
return $argLists;
29-
}
30-
31-
public function getInstanceClass() {
32-
return 'Wikibase\DataModel\Fixtures\HashArrayWithoutDuplicates';
23+
public function instanceProvider() {
24+
return [
25+
[ new HashArrayWithoutDuplicates( HashArrayElement::getInstances() ) ],
26+
];
3327
}
3428

3529
public function elementInstancesProvider() {

tests/unit/Snak/SnakListTest.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@
3333
*/
3434
class SnakListTest extends HashArrayTest {
3535

36-
/**
37-
* @see HashArrayTest::getInstanceClass
38-
*/
39-
public function getInstanceClass() {
40-
return 'Wikibase\DataModel\Snak\SnakList';
41-
}
42-
4336
public function elementInstancesProvider() {
4437
$id42 = new PropertyId( 'P42' );
4538

@@ -52,25 +45,24 @@ public function elementInstancesProvider() {
5245
return $argLists;
5346
}
5447

55-
public function constructorProvider() {
48+
public function instanceProvider() {
5649
$id42 = new PropertyId( 'P42' );
5750
$id9001 = new PropertyId( 'P9001' );
5851

5952
return [
60-
[],
61-
[ [] ],
62-
[ [
53+
[ new SnakList() ],
54+
[ new SnakList( [
6355
new PropertyNoValueSnak( $id42 )
64-
] ],
65-
[ [
56+
] ) ],
57+
[ new SnakList( [
6658
new PropertyNoValueSnak( $id42 ),
6759
new PropertyNoValueSnak( $id9001 ),
68-
] ],
69-
[ [
60+
] ) ],
61+
[ new SnakList( [
7062
new PropertyNoValueSnak( $id42 ),
7163
new PropertyNoValueSnak( $id9001 ),
7264
new PropertyValueSnak( $id42, new StringValue( 'a' ) ),
73-
] ],
65+
] ) ],
7466
];
7567
}
7668

0 commit comments

Comments
 (0)