rasmus Sun, 29 Jan 2012 04:20:50 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=322915
Log:
Missed the test
Changed paths:
A
php/php-src/branches/PHP_5_3/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
A
php/php-src/branches/PHP_5_4/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
A php/php-src/trunk/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
Added:
php/php-src/branches/PHP_5_3/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
===================================================================
---
php/php-src/branches/PHP_5_3/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
(rev 0)
+++
php/php-src/branches/PHP_5_3/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
2012-01-29 04:20:50 UTC (rev 322915)
@@ -0,0 +1,44 @@
+--TEST--
+Test SQLite3::createCollation() by adding strnatcmp() as an SQL COLLATE
sequence
+--SKIPIF--
+<?php require_once dirname(__FILE__) . '/skipif.inc'; ?>
+--FILE--
+<?php
+
+require_once dirname(__FILE__) . '/new_db.inc';
+
+$db->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
Added:
php/php-src/branches/PHP_5_4/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
===================================================================
---
php/php-src/branches/PHP_5_4/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
(rev 0)
+++
php/php-src/branches/PHP_5_4/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
2012-01-29 04:20:50 UTC (rev 322915)
@@ -0,0 +1,44 @@
+--TEST--
+Test SQLite3::createCollation() by adding strnatcmp() as an SQL COLLATE
sequence
+--SKIPIF--
+<?php require_once dirname(__FILE__) . '/skipif.inc'; ?>
+--FILE--
+<?php
+
+require_once dirname(__FILE__) . '/new_db.inc';
+
+$db->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
Added: php/php-src/trunk/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
===================================================================
--- php/php-src/trunk/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
(rev 0)
+++ php/php-src/trunk/ext/sqlite3/tests/sqlite3_36_create_collation.phpt
2012-01-29 04:20:50 UTC (rev 322915)
@@ -0,0 +1,44 @@
+--TEST--
+Test SQLite3::createCollation() by adding strnatcmp() as an SQL COLLATE
sequence
+--SKIPIF--
+<?php require_once dirname(__FILE__) . '/skipif.inc'; ?>
+--FILE--
+<?php
+
+require_once dirname(__FILE__) . '/new_db.inc';
+
+$db->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
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php