diff --git a/test/classes/ConfigTest.php b/test/classes/ConfigTest.php index 7f32e3c670..8382fbadb7 100644 --- a/test/classes/ConfigTest.php +++ b/test/classes/ConfigTest.php @@ -12,7 +12,6 @@ use PhpMyAdmin\Config; use PhpMyAdmin\Tests\PmaTestCase; use PhpMyAdmin\Theme; use PHPUnit\Framework\Assert; -use PHPUnit\Framework\Exception; /** * Tests behaviour of PhpMyAdmin\Config class @@ -1338,18 +1337,25 @@ class ConfigTest extends PmaTestCase */ public function testCheckServers($settings, $expected, $error = false) { - if ($error) { - $this->expectException(Exception::class); + try { + $this->object->settings['Servers'] = $settings; + $this->object->checkServers(); + if (is_null($expected)) { + $expected = $this->object->default_server; + } else { + $expected = array_merge($this->object->default_server, $expected); + } + $this->assertEquals($expected, $this->object->settings['Servers'][1]); + if ($error) { + $this->assertTrue(false); + } + } catch (\Exception $e) { + if ($error) { + $this->assertTrue(true); + } else { + throw $e; + } } - - $this->object->settings['Servers'] = $settings; - $this->object->checkServers(); - if (is_null($expected)) { - $expected = $this->object->default_server; - } else { - $expected = array_merge($this->object->default_server, $expected); - } - $this->assertEquals($expected, $this->object->settings['Servers'][1]); } /** diff --git a/test/classes/Di/ContainerTest.php b/test/classes/Di/ContainerTest.php index 4500ffc3bf..2837cd8259 100644 --- a/test/classes/Di/ContainerTest.php +++ b/test/classes/Di/ContainerTest.php @@ -65,8 +65,12 @@ class ContainerTest extends PmaTestCase */ public function testGetThrowsNotFoundException() { - $this->expectException(NotFoundExceptionInterface::class); - $this->container->get('name'); + try { + $this->container->get('name'); + $this->assertTrue(false); + } catch (NotFoundExceptionInterface $e) { + $this->assertTrue(true); + } } /** diff --git a/test/classes/Navigation/NodeFactoryTest.php b/test/classes/Navigation/NodeFactoryTest.php index 13ee166ccb..adbfc431ad 100644 --- a/test/classes/Navigation/NodeFactoryTest.php +++ b/test/classes/Navigation/NodeFactoryTest.php @@ -10,8 +10,6 @@ namespace PhpMyAdmin\Tests\Navigation; use PhpMyAdmin\Navigation\NodeFactory; use PhpMyAdmin\Navigation\Nodes\Node; use PhpMyAdmin\Tests\PmaTestCase; -use PhpMyAdmin\Theme; -use PHPUnit\Framework\Exception; /** * Tests for NodeFactory class @@ -85,8 +83,12 @@ class NodeFactoryTest extends PmaTestCase */ public function testFileError() { - $this->expectException(Exception::class); - NodeFactory::getInstance('NodeDoesNotExist'); + try { + NodeFactory::getInstance('NodeDoesNotExist'); + $this->assertTrue(false); + } catch (\Exception $e) { + $this->assertTrue(true); + } } /** @@ -96,7 +98,11 @@ class NodeFactoryTest extends PmaTestCase */ public function testClassNameError() { - $this->expectException(Exception::class); - NodeFactory::getInstance('Invalid'); + try { + NodeFactory::getInstance('Invalid'); + $this->assertTrue(false); + } catch (\Exception $e) { + $this->assertTrue(true); + } } } diff --git a/test/classes/TemplateTest.php b/test/classes/TemplateTest.php index 9fa13ee216..7087c030c7 100644 --- a/test/classes/TemplateTest.php +++ b/test/classes/TemplateTest.php @@ -90,8 +90,12 @@ class TemplateTest extends PmaTestCase */ public function testRenderTemplateNotFound() { - $this->expectException(LoaderError::class); - Template::get('template not found')->render(); + try { + Template::get('template not found')->render(); + $this->assertTrue(false); + } catch (LoaderError $e) { + $this->assertTrue(true); + } } /**