1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-11 16:44:30 +02:00

used PHP 7.1 features

- ::class
- ... argument unpacking
- removed call_user_func
- operator ??
- list()
- short <?=
This commit is contained in:
David Grudl
2017-06-09 12:21:23 +02:00
parent 750d70c77a
commit 3891625cd1
27 changed files with 100 additions and 109 deletions

View File

@@ -15,27 +15,27 @@ $conn->loadFile(__DIR__ . "/data/$config[system].sql");
$e = Assert::exception(function () use ($conn) {
$conn->query('SELECT');
}, 'Dibi\DriverException', "%a% error in your SQL syntax;%a%", 1064);
}, Dibi\DriverException::class, "%a% error in your SQL syntax;%a%", 1064);
Assert::same('SELECT', $e->getSql());
$e = Assert::exception(function () use ($conn) {
$conn->query('INSERT INTO products (product_id, title) VALUES (1, "New")');
}, 'Dibi\UniqueConstraintViolationException', "%a?%Duplicate entry '1' for key 'PRIMARY'", 1062);
}, Dibi\UniqueConstraintViolationException::class, "%a?%Duplicate entry '1' for key 'PRIMARY'", 1062);
Assert::same("INSERT INTO products (product_id, title) VALUES (1, 'New')", $e->getSql());
$e = Assert::exception(function () use ($conn) {
$conn->query('INSERT INTO products (title) VALUES (NULL)');
}, 'Dibi\NotNullConstraintViolationException', "%a?%Column 'title' cannot be null", 1048);
}, Dibi\NotNullConstraintViolationException::class, "%a?%Column 'title' cannot be null", 1048);
Assert::same('INSERT INTO products (title) VALUES (NULL)', $e->getSql());
$e = Assert::exception(function () use ($conn) {
$conn->query('INSERT INTO orders (customer_id, product_id, amount) VALUES (100, 1, 1)');
}, 'Dibi\ForeignKeyConstraintViolationException', '%a% a foreign key constraint fails %a%', 1452);
}, Dibi\ForeignKeyConstraintViolationException::class, '%a% a foreign key constraint fails %a%', 1452);
Assert::same('INSERT INTO orders (customer_id, product_id, amount) VALUES (100, 1, 1)', $e->getSql());