diff --git a/tests/system/Cache/Handlers/MemcachedHandlerTest.php b/tests/system/Cache/Handlers/MemcachedHandlerTest.php index bbb91bf6a8de..e6bba9432cf2 100644 --- a/tests/system/Cache/Handlers/MemcachedHandlerTest.php +++ b/tests/system/Cache/Handlers/MemcachedHandlerTest.php @@ -14,9 +14,9 @@ namespace CodeIgniter\Cache\Handlers; use CodeIgniter\CLI\CLI; +use CodeIgniter\Exceptions\BadMethodCallException; use CodeIgniter\I18n\Time; use Config\Cache; -use Exception; /** * @group CacheLive @@ -125,7 +125,7 @@ public function testDelete(): void public function testDeleteMatching(): void { // Not implemented for Memcached, should throw an exception - $this->expectException(Exception::class); + $this->expectException(BadMethodCallException::class); $this->handler->deleteMatching('key*'); } diff --git a/tests/system/Cache/ResponseCacheTest.php b/tests/system/Cache/ResponseCacheTest.php index b973bff2c2d1..a5b26990f6d1 100644 --- a/tests/system/Cache/ResponseCacheTest.php +++ b/tests/system/Cache/ResponseCacheTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Cache; +use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\HTTP\CLIRequest; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\Response; @@ -23,7 +24,6 @@ use Config\App as AppConfig; use Config\Cache as CacheConfig; use ErrorException; -use Exception; /** * @backupGlobals enabled @@ -245,7 +245,7 @@ public function testUnserializeError() public function testInvalidCacheError() { - $this->expectException(Exception::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Error unserializing page cache'); $cache = mock(CacheFactory::class); diff --git a/tests/system/Log/LoggerTest.php b/tests/system/Log/LoggerTest.php index e76e60cbd4c3..c8a3ad1d2ec6 100644 --- a/tests/system/Log/LoggerTest.php +++ b/tests/system/Log/LoggerTest.php @@ -14,11 +14,11 @@ namespace CodeIgniter\Log; use CodeIgniter\Exceptions\FrameworkException; +use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\I18n\Time; use CodeIgniter\Log\Exceptions\LogException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; -use Exception; use Tests\Support\Log\Handlers\TestHandler; use TypeError; @@ -241,8 +241,8 @@ public function testLogInterpolatesExceptions(): void $expected = 'ERROR - ' . Time::now()->format('Y-m-d') . ' --> [ERROR] These are not the droids you are looking for'; try { - throw new Exception('These are not the droids you are looking for'); - } catch (Exception $e) { + throw new RuntimeException('These are not the droids you are looking for'); + } catch (RuntimeException $e) { $logger->log('error', '[ERROR] {exception}', ['exception' => $e]); } diff --git a/tests/system/Test/ControllerTestTraitTest.php b/tests/system/Test/ControllerTestTraitTest.php index fae14d2629a9..680a2a31a4b1 100644 --- a/tests/system/Test/ControllerTestTraitTest.php +++ b/tests/system/Test/ControllerTestTraitTest.php @@ -16,11 +16,12 @@ use App\Controllers\Home; use App\Controllers\NeverHeardOfIt; use CodeIgniter\Controller; +use CodeIgniter\Exceptions\InvalidArgumentException; +use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\Log\Logger; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use Config\App; use Config\Services; -use Exception; use Tests\Support\Controllers\Newautorouting; use Tests\Support\Controllers\Popcorn; @@ -41,7 +42,8 @@ final class ControllerTestTraitTest extends CIUnitTestCase public function testBadController(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); + $logger = new Logger(new LoggerConfig()); $this->withURI('http://example.com') ->withLogger($logger) @@ -51,7 +53,8 @@ public function testBadController(): void public function testBadControllerMethod(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); + $logger = new Logger(new LoggerConfig()); $this->withURI('http://example.com') ->withLogger($logger) @@ -252,12 +255,12 @@ public function testUsesRequestBody(): void $this->controller = new class () extends Controller { public function throwsBody(): void { - throw new Exception($this->request->getBody()); + throw new RuntimeException($this->request->getBody()); } }; $this->controller->initController($this->request, $this->response, $this->logger); - $this->expectException(Exception::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('banana'); $this->withBody('banana')->execute('throwsBody');