File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818use CodeIgniter \Test \CIUnitTestCase ;
1919use Config \App ;
2020use InvalidArgumentException ;
21+ use JsonException ;
2122use TypeError ;
2223
2324/**
@@ -541,6 +542,19 @@ public function testGetJSONWithInvalidJSONString(): void
541542 $ request ->getJSON ();
542543 }
543544
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+
544558 public function testCanGrabGetRawInput (): void
545559 {
546560 $ rawstring = 'username=admin001&role=administrator&usepass=0 ' ;
You can’t perform that action at this time.
0 commit comments