@@ -77,8 +77,16 @@ public function testNull()
77
77
78
78
public function testMissingOp ()
79
79
{
80
- $ this ->setExpectedException (MissingFieldException::class, 'Missing "op" in operation data ' );
81
- JsonPatch::import (array ((object )array ('path ' => '/123 ' )));
80
+ $ operation = (object )array ('path ' => '/123 ' );
81
+ try {
82
+ JsonPatch::import (array ($ operation ));
83
+ $ this ->fail ('Expected exception was not thrown ' );
84
+ } catch (Exception $ exception ) {
85
+ $ this ->assertInstanceOf (MissingFieldException::class, $ exception );
86
+ $ this ->assertSame ('Missing "op" in operation data ' , $ exception ->getMessage ());
87
+ $ this ->assertSame ('op ' , $ exception ->getMissingField ());
88
+ $ this ->assertSame ($ operation , $ exception ->getOperation ());
89
+ }
82
90
}
83
91
84
92
public function testMissingPath ()
@@ -89,8 +97,15 @@ public function testMissingPath()
89
97
90
98
public function testInvalidOp ()
91
99
{
92
- $ this ->setExpectedException (UnknownOperationException::class, 'Unknown "op": wat ' );
93
- JsonPatch::import (array ((object )array ('op ' => 'wat ' , 'path ' => '/123 ' )));
100
+ $ operation = (object )array ('op ' => 'wat ' , 'path ' => '/123 ' );
101
+ try {
102
+ JsonPatch::import (array ($ operation ));
103
+ $ this ->fail ('Expected exception was not thrown ' );
104
+ } catch (Exception $ exception ) {
105
+ $ this ->assertInstanceOf (UnknownOperationException::class, $ exception );
106
+ $ this ->assertSame ('Unknown "op": wat ' , $ exception ->getMessage ());
107
+ $ this ->assertSame ($ operation , $ exception ->getOperation ());
108
+ }
94
109
}
95
110
96
111
public function testMissingFrom ()
@@ -154,4 +169,4 @@ public function testTestOperationFailed()
154
169
$ this ->assertInstanceOf (PatchTestOperationFailedException::class, $ errors [0 ]);
155
170
}
156
171
157
- }
172
+ }
0 commit comments