diff options
Diffstat (limited to 'tests/Lexer/ContextTest.php')
-rw-r--r-- | tests/Lexer/ContextTest.php | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/tests/Lexer/ContextTest.php b/tests/Lexer/ContextTest.php index 980eecd..2a9c8f3 100644 --- a/tests/Lexer/ContextTest.php +++ b/tests/Lexer/ContextTest.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Tests\Lexer; use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Tests\TestCase; +use Throwable; class ContextTest extends TestCase { @@ -29,7 +31,7 @@ class ContextTest extends TestCase public function testLoadClosest($context, $expected) { $this->assertEquals($expected, Context::loadClosest($context)); - if (! is_null($expected)) { + if ($expected !== null) { $this->assertEquals('\\PhpMyAdmin\\SqlParser\\Contexts\\Context' . $expected, Context::$loadedContext); $this->assertTrue(class_exists(Context::$loadedContext)); } @@ -40,42 +42,42 @@ class ContextTest extends TestCase public function contextLoading() { - return array( - 'MySQL match' => array( + return [ + 'MySQL match' => [ 'MySql50500', 'MySql50500', - ), - 'MySQL strip' => array( + ], + 'MySQL strip' => [ 'MySql50712', 'MySql50700', - ), - 'MySQL fallback' => array( + ], + 'MySQL fallback' => [ 'MySql99999', 'MySql50700', - ), - 'MariaDB match' => array( + ], + 'MariaDB match' => [ 'MariaDb100000', 'MariaDb100000', - ), - 'MariaDB stripg' => array( + ], + 'MariaDB stripg' => [ 'MariaDb109900', 'MariaDb100000', - ), - 'MariaDB fallback' => array( + ], + 'MariaDB fallback' => [ 'MariaDb990000', 'MariaDb100300', - ), - 'Invalid' => array( + ], + 'Invalid' => [ 'Sql', null, - ) - ); + ], + ]; } /** - * @dataProvider contextNames - * * @param mixed $context + * + * @dataProvider contextNames */ public function testLoadAll($context) { @@ -88,26 +90,24 @@ class ContextTest extends TestCase public function contextNames() { - return array( - array('MySql50000'), - array('MySql50100'), - array('MySql50500'), - array('MySql50600'), - array('MySql50700'), - array('MySql80000'), - array('MariaDb100000'), - array('MariaDb100100'), - array('MariaDb100200'), - array('MariaDb100300') - ); + return [ + ['MySql50000'], + ['MySql50100'], + ['MySql50500'], + ['MySql50600'], + ['MySql50700'], + ['MySql80000'], + ['MariaDb100000'], + ['MariaDb100100'], + ['MariaDb100200'], + ['MariaDb100300'], + ]; } - /** - * @expectedException \Exception - * @expectedExceptionMessage Specified context ("\PhpMyAdmin\SqlParser\Contexts\ContextFoo") does not exist. - */ public function testLoadError() { + $this->expectExceptionMessage('Specified context ("\PhpMyAdmin\SqlParser\Contexts\ContextFoo") does not exist.'); + $this->expectException(Throwable::class); Context::load('Foo'); } @@ -139,11 +139,11 @@ class ContextTest extends TestCase $this->assertEquals('`test`', Context::escape('test')); $this->assertEquals( - array( + [ '`a`', '`b`', - ), - Context::escape(array('a', 'b')) + ], + Context::escape(['a', 'b']) ); } } |