From deb3a6905d5312c5814cb9c9f798a78a60f3b759 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 15 Oct 2016 22:02:10 +0100 Subject: [PATCH] hhvm workarounds, with xdebug via travis-ci/travis-ci#2980 --- composer.json | 3 +- phpunit.sh | 7 ++++- tests/EscapeIdentifierTest.php | 55 ++++++++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index edcb6ac..0cb7568 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,6 @@ } }, "require": { - "php": "^7.0", - "ext-pdo": "^7.0" + "ext-pdo": "*" } } diff --git a/phpunit.sh b/phpunit.sh index 4afb4e9..a3462f8 100755 --- a/phpunit.sh +++ b/phpunit.sh @@ -36,7 +36,12 @@ if [ $? -eq 0 ]; then echo echo -e "\033[33mBegin Unit Testing\033[0m" # Run the testing suite - php phpunit.phar + if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ]; then + echo 'xdebug.enable = On' >> /etc/hhvm/php.ini; + hhvm -v Eval.EnableHipHopSyntax=true phpunit.phar + else + php phpunit.phar + fi # Cleanup if [ "$clean" -eq 1 ]; then echo -e "\033[32mCleaning Up!\033[0m" diff --git a/tests/EscapeIdentifierTest.php b/tests/EscapeIdentifierTest.php index 3e6004b..88d7851 100644 --- a/tests/EscapeIdentifierTest.php +++ b/tests/EscapeIdentifierTest.php @@ -3,7 +3,10 @@ namespace ParagonIE\EasyDB\Tests; -use Throwable; +use ParagonIE\EasyDB\EasyDB; +use ParagonIE\EasyDB\Exception as Issues; +use PHPUnit_Framework_Error; +use TypeError; class EscapeIdentifierTest extends @@ -110,8 +113,54 @@ public function testEscapeIdentifier(callable $cb, $identifier) public function testEscapeIdentifierThrowsSomething(callable $cb, $identifier) { $db = $this->EasyDBExpectedFromCallable($cb); - $this->expectException(Throwable::class); - $db->escapeIdentifier($identifier); + $thrown = false; + try { + $db->escapeIdentifier($identifier); + } catch (Issues\InvalidIdentifier $e) { + $this->assertTrue(true); + $thrown = true; + } catch (TypeError $e) { + $this->assertTrue(true); + $thrown = true; + } catch (PHPUnit_Framework_Error $e) { + if ( + preg_match( + ( + '/^' . + preg_quote( + ('Argument 1 passed to ' . EasyDB::class . '::escapeIdentifier()'), + '/' + ) . + ' must be an instance of string, [^ ]+ given$/' + ), + $e->getMessage() + ) + ) { + $this->assertTrue(true); + $thrown = true; + } else { + throw $e; + } + } finally { + if (!$thrown) { + $this->assertTrue( + false, + ( + 'Argument 2 of ' . + static::class . + '::' . + __METHOD__ . + '() must cause either ' . + Issues\InvalidIdentifier::class . + ' or ' . + TypeError::class . + ' (' . + var_export($identifier, true) . + ')' + ) + ); + } + } }