From 9722bff0c337f015ecda5d072049ca599e2f7e71 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Sun, 29 Jan 2012 04:20:50 +0000 Subject: [PATCH] Missed the test --- .../tests/sqlite3_36_create_collation.phpt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 ext/sqlite3/tests/sqlite3_36_create_collation.phpt diff --git a/ext/sqlite3/tests/sqlite3_36_create_collation.phpt b/ext/sqlite3/tests/sqlite3_36_create_collation.phpt new file mode 100644 index 00000000000..c4d88c69f7b --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_36_create_collation.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test SQLite3::createCollation() by adding strnatcmp() as an SQL COLLATE sequence +--SKIPIF-- + +--FILE-- +createCollation('NAT', 'strnatcmp'); + +$db->exec('CREATE TABLE t (s varchar(4))'); + +$stmt = $db->prepare('INSERT INTO t VALUES (?)'); +foreach(array('a1', 'a10', 'a2') as $s){ + $stmt->bindParam(1, $s); + $stmt->execute(); +} + +$defaultSort = $db->query('SELECT s FROM t ORDER BY s'); //memcmp() sort +$naturalSort = $db->query('SELECT s FROM t ORDER BY s COLLATE NAT'); //strnatcmp() sort + +echo "default\n"; +while ($row = $defaultSort->fetchArray()){ + echo $row['s'], "\n"; +} + +echo "natural\n"; +while ($row = $naturalSort->fetchArray()){ + echo $row['s'], "\n"; +} + +$db->close(); + +?> +--EXPECT-- +default +a1 +a10 +a2 +natural +a1 +a2 +a10