mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 22:26:43 +02:00
used safe casting to int (BC break)
This commit is contained in:
@@ -144,10 +144,9 @@ if ($config['system'] === 'mysql') {
|
||||
->limit(' 1; DROP TABLE users')
|
||||
->offset(' 1; DROP TABLE users');
|
||||
|
||||
Assert::same(
|
||||
reformat(' SELECT * LIMIT 1 OFFSET 1'),
|
||||
(string) $fluent
|
||||
);
|
||||
Assert::error(function () use ($fluent) {
|
||||
(string) $fluent;
|
||||
}, E_USER_ERROR, "Expected number, ' 1; DROP TABLE users' given.");
|
||||
}
|
||||
|
||||
|
||||
|
32
tests/dibi/Helpers.intVal().phpt
Normal file
32
tests/dibi/Helpers.intVal().phpt
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Dibi\Helpers;
|
||||
use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
Assert::same(0, Helpers::intVal(0));
|
||||
Assert::same(0, Helpers::intVal('0'));
|
||||
Assert::same(-10, Helpers::intVal('-10'));
|
||||
|
||||
Assert::exception(function () {
|
||||
Helpers::intVal('12345678901234567890123456879');
|
||||
}, Dibi\Exception::class, 'Number 12345678901234567890123456879 is greater than integer.');
|
||||
|
||||
Assert::exception(function () {
|
||||
Helpers::intVal('-12345678901234567890123456879');
|
||||
}, Dibi\Exception::class, 'Number -12345678901234567890123456879 is greater than integer.');
|
||||
|
||||
Assert::exception(function () {
|
||||
Helpers::intVal('');
|
||||
}, Dibi\Exception::class, "Expected number, '' given.");
|
||||
|
||||
Assert::exception(function () {
|
||||
Helpers::intVal('not number');
|
||||
}, Dibi\Exception::class, "Expected number, 'not number' given.");
|
||||
|
||||
Assert::exception(function () {
|
||||
Helpers::intVal(null);
|
||||
}, Dibi\Exception::class, "Expected number, '' given.");
|
Reference in New Issue
Block a user