diff --git a/composer.json b/composer.json index debe210..03a9f8e 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,20 @@ "amphp/amp": "^2" }, "require-dev": { - "amphp/php-cs-fixer-config": "dev-master" + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1", + "phpunit/phpunit": "^6" }, "autoload": { "psr-4": { "Amp\\Sql\\": "src" } }, + "autoload-dev": { + "psr-4": { + "Amp\\Sql\\Test\\": "test" + } + }, "config": { "platform": { "php": "7.0.0" diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..228d633 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,28 @@ + + + + + test + + + + + src + + + + + + diff --git a/src/QueryError.php b/src/QueryError.php index 2a9d460..f3e2a4c 100644 --- a/src/QueryError.php +++ b/src/QueryError.php @@ -8,7 +8,7 @@ class QueryError extends \Error public function __construct(string $message, string $query = "", \Throwable $previous = null) { - if ($query != "") { + if ($query !== "") { $this->query = $query; } parent::__construct($message, 0, $previous); diff --git a/test/QueryErrorTest.php b/test/QueryErrorTest.php new file mode 100644 index 0000000..ea6e04b --- /dev/null +++ b/test/QueryErrorTest.php @@ -0,0 +1,20 @@ +assertSame('SELECT * FROM foo', $error->getQuery()); + $this->assertStringStartsWith("Amp\Sql\QueryError: error\nCurrent query was SELECT * FROM foo", (string) $error); + } +} \ No newline at end of file diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 0000000..991ea43 --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,3 @@ +