Skip to content

Commit 358bbfc

Browse files
committed
Test operation uses new reader test method.
1 parent 9a2beae commit 358bbfc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Patch.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Remorhaz\JSON\Patch;
44

5+
use Remorhaz\JSON\Data\Exception as DataException;
56
use Remorhaz\JSON\Data\SelectorInterface;
67
use Remorhaz\JSON\Pointer\Pointer;
78

@@ -70,8 +71,11 @@ protected function performOperation(int $index)
7071
case 'test':
7172
$expectedValueReader = $this->getPatchPointer()->read("/{$index}/value");
7273
$actualValueReader = $this->getDataPointer()->read($path);
73-
if ($expectedValueReader->getAsStruct() !== $actualValueReader->getAsStruct()) {
74-
throw new \RuntimeException("Test operation failed");
74+
try {
75+
// TODO: Make reader's test() method boolean and refactor pointer's test().
76+
$expectedValueReader->test($actualValueReader);
77+
} catch (DataException $e) {
78+
throw new \RuntimeException("Test operation failed", 0, $e);
7579
}
7680
break;
7781

0 commit comments

Comments
 (0)