mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 14:16:39 +02:00
Postgre: added test for matching by %like
This commit is contained in:
34
tests/dibi/Postgre.like.phpt
Normal file
34
tests/dibi/Postgre.like.phpt
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @dataProvider ../databases.ini
|
||||
*/
|
||||
|
||||
use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
if ($config['system'] !== 'pgsql') {
|
||||
Tester\Environment::skip("Not supported system '$config[system]'.");
|
||||
}
|
||||
|
||||
|
||||
$tests = function($conn) {
|
||||
Assert::false($conn->query("SELECT 'AAxBB' LIKE %~like~", 'A_B')->fetchSingle());
|
||||
Assert::true( $conn->query("SELECT 'AA_BB' LIKE %~like~", 'A_B')->fetchSingle());
|
||||
|
||||
Assert::false($conn->query("SELECT 'AAxBB' LIKE %~like~", 'A%B')->fetchSingle());
|
||||
Assert::true( $conn->query("SELECT 'AA%BB' LIKE %~like~", 'A%B')->fetchSingle());
|
||||
|
||||
Assert::same('AA\\BB', $conn->query("SELECT 'AA\\BB'")->fetchSingle());
|
||||
Assert::false($conn->query("SELECT 'AAxBB' LIKE %~like~", 'A\\B')->fetchSingle());
|
||||
Assert::true( $conn->query("SELECT 'AA\\BB' LIKE %~like~", 'A\\B')->fetchSingle());
|
||||
};
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn->query('SET escape_string_warning = off'); // do not log warnings
|
||||
|
||||
$conn->query('SET standard_conforming_strings = on');
|
||||
$tests($conn);
|
||||
$conn->query('SET standard_conforming_strings = off');
|
||||
$tests($conn);
|
Reference in New Issue
Block a user