File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 18
18
use CodeIgniter \Test \CIUnitTestCase ;
19
19
use Config \App ;
20
20
use InvalidArgumentException ;
21
+ use JsonException ;
21
22
use TypeError ;
22
23
23
24
/**
@@ -541,6 +542,19 @@ public function testGetJSONWithInvalidJSONString(): void
541
542
$ request ->getJSON ();
542
543
}
543
544
545
+ public function testGetJSONWithJsonThrowOnErrorAndInvalidJSONString (): void
546
+ {
547
+ $ this ->expectException (JsonException::class);
548
+ $ this ->expectExceptionMessage ('Syntax error ' );
549
+
550
+ $ config = new App ();
551
+ $ config ->baseURL = 'http://example.com/ ' ;
552
+ $ json = 'Invalid JSON string ' ;
553
+ $ request = $ this ->createRequest ($ config , $ json );
554
+
555
+ $ request ->getJSON (false , 512 , JSON_THROW_ON_ERROR );
556
+ }
557
+
544
558
public function testCanGrabGetRawInput (): void
545
559
{
546
560
$ rawstring = 'username=admin001&role=administrator&usepass=0 ' ;
You can’t perform that action at this time.
0 commit comments