Skip to content

Commit

Permalink
Revert "Test ArraySubset with indexed arrays."
Browse files Browse the repository at this point in the history
This reverts commit 9b263ed.
  • Loading branch information
sebastianbergmann committed Aug 7, 2018
1 parent 2be8695 commit f771423
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 157 deletions.
37 changes: 0 additions & 37 deletions tests/Framework/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,13 @@ public function testAssertArraySubset(): void
'd' => ['a2' => ['a3' => 'item a3', 'b3' => 'item b3']]
];

$this->assertArraySubset(['a' => 'item a'], $array);
$this->assertArraySubset(['a' => 'item a', 'c' => ['a2' => 'item a2']], $array);
$this->assertArraySubset(['a' => 'item a', 'd' => ['a2' => ['b3' => 'item b3']]], $array);
$this->assertArraySubset(['b' => 'item b', 'd' => ['a2' => ['b3' => 'item b3']]], $array);

$arrayAccessData = new \ArrayObject($array);

$this->assertArraySubset(['a' => 'item a'], $arrayAccessData);
$this->assertArraySubset(['a' => 'item a', 'c' => ['a2' => 'item a2']], $arrayAccessData);
$this->assertArraySubset(['a' => 'item a', 'd' => ['a2' => ['b3' => 'item b3']]], $arrayAccessData);
$this->assertArraySubset(['b' => 'item b', 'd' => ['a2' => ['b3' => 'item b3']]], $arrayAccessData);

try {
$this->assertArraySubset(['a' => 'bad value'], $array);
Expand All @@ -184,39 +180,6 @@ public function testAssertArraySubset(): void
$this->fail();
}

public function testAssertArraySubsetWithIndexedArrays(): void
{
$array = [
'item a',
'item b',
['a2' => 'item a2', 'b2' => 'item b2'],
['a2' => ['a3' => 'item a3', 'b3' => 'item b3']]
];

$this->assertArraySubset(['item a', ['a2' => 'item a2']], $array);
$this->assertArraySubset(['item a', ['a2' => ['b3' => 'item b3']]], $array);
$this->assertArraySubset(['item b', ['a2' => ['b3' => 'item b3']]], $array);

$arrayAccessData = new \ArrayObject($array);

$this->assertArraySubset(['item a', ['a2' => 'item a2']], $arrayAccessData);
$this->assertArraySubset(['item a', ['a2' => ['b3' => 'item b3']]], $arrayAccessData);
$this->assertArraySubset(['item b', ['a2' => ['b3' => 'item b3']]], $arrayAccessData);

try {
$this->assertArraySubset(['bad value'], $array);
} catch (AssertionFailedError $e) {
}

try {
$this->assertArraySubset([['a2' => ['bad index' => 'item b3']]], $array);
} catch (AssertionFailedError $e) {
return;
}

$this->fail();
}

public function testAssertArraySubsetWithDeepNestedArrays(): void
{
$array = [
Expand Down
125 changes: 5 additions & 120 deletions tests/Framework/Constraint/ArraySubsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,146 +16,30 @@ class ArraySubsetTest extends ConstraintTestCase
public static function evaluateDataProvider()
{
return [
'loose associative array subset and array other' => [
'loose array subset and array other' => [
'expected' => true,
'subset' => ['bar' => 0],
'other' => ['foo' => '', 'bar' => '0'],
'strict' => false
],
'strict associative array subset and array other' => [
'strict array subset and array other' => [
'expected' => false,
'subset' => ['bar' => 0],
'other' => ['foo' => '', 'bar' => '0'],
'strict' => true
],
'loose associative array subset and ArrayObject other' => [
'loose array subset and ArrayObject other' => [
'expected' => true,
'subset' => ['bar' => 0],
'other' => new \ArrayObject(['foo' => '', 'bar' => '0']),
'strict' => false
],
'strict associative ArrayObject subset and array other' => [
'strict ArrayObject subset and array other' => [
'expected' => true,
'subset' => new \ArrayObject(['bar' => 0]),
'other' => ['foo' => '', 'bar' => 0],
'strict' => true
],
'loose indexed array subset and array other' => [
'expected' => true,
'subset' => [0],
'other' => ['', '0'],
'strict' => false
],
'strict indexed array subset and array other' => [
'expected' => false,
'subset' => [0],
'other' => ['', '0'],
'strict' => true
],
'loose indexed array subset and ArrayObject other' => [
'expected' => true,
'subset' => [0],
'other' => new \ArrayObject(['', '0']),
'strict' => false
],
'strict indexed ArrayObject subset and array other' => [
'expected' => true,
'subset' => new \ArrayObject([0]),
'other' => ['', 0],
'strict' => true
],
'loose unordered indexed array subset and array other' => [
'expected' => true,
'subset' => [0, '1'],
'other' => ['1', '2', '0'],
'strict' => false
],
'strict unordered indexed array subset and array other' => [
'expected' => false,
'subset' => [0, '1'],
'other' => ['1', '2', '0'],
'strict' => true
],
'loose unordered indexed array subset and ArrayObject other' => [
'expected' => true,
'subset' => [0, '1'],
'other' => new \ArrayObject(['1', '2', '0']),
'strict' => false
],
'strict unordered indexed ArrayObject subset and array other' => [
'expected' => true,
'subset' => new \ArrayObject([0, '1']),
'other' => ['1', '2', 0],
'strict' => true
],
'loose unordered multidimensional indexed array subset and array other' => [
'expected' => true,
'subset' => [
[[3, 4], 2],
'10',
],
'other' => [
0 => '1',
'a' => [
'aa' => '2',
'ab' => [5, 4, 3],
'ac' => 10,
],
'b' => '10',
],
'strict' => false
],
'strict unordered multidimensional indexed array subset and array other' => [
'expected' => false,
'subset' => [
[[3, 4], 2],
'10',
],
'other' => [
0 => '1',
'a' => [
'aa' => '2',
'ab' => [5, 4, 3],
'ac' => 10,
],
'b' => '10',
],
'strict' => true
],
'loose unordered multidimensional indexed array subset and ArrayObject other' => [
'expected' => true,
'subset' => [
[[3, 4], 2],
'10',
],
'other' => new \ArrayObject([
0 => '1',
'a' => [
'aa' => '2',
'ab' => [5, 4, 3],
'ac' => 10,
],
'b' => '10',
]),
'strict' => false
],
'strict unordered multidimensional indexed ArrayObject subset and array other' => [
'expected' => true,
'subset' => new \ArrayObject([
[[3, 4], '2'],
'10',
]),
'other' => [
0 => '1',
'a' => [
'aa' => '2',
'ab' => [5, 4, 3],
'ac' => 10,
],
'b' => '10',
],
'strict' => true
],
];
}

Expand Down Expand Up @@ -200,3 +84,4 @@ public function testEvaluateFailMessage(): void
}
}
}

0 comments on commit f771423

Please sign in to comment.