summaryrefslogtreecommitdiffstats
path: root/tests/MySqlShimTest.php
diff options
context:
space:
mode:
authorDavey Shafik <me@daveyshafik.com>2016-01-28 16:14:56 +0100
committerDavey Shafik <me@daveyshafik.com>2016-02-02 12:50:51 -0500
commite2f4aeb61cae100653b61c10a1424771eb6ff25c (patch)
tree7af810a0babe1d6420c42551bd7044427235616f /tests/MySqlShimTest.php
parent3d5a14dbea4538a87ddbcfc19c3ac1dc00c475e1 (diff)
downloadphp7-mysql-shim-e2f4aeb61cae100653b61c10a1424771eb6ff25c.zip
php7-mysql-shim-e2f4aeb61cae100653b61c10a1424771eb6ff25c.tar.gz
php7-mysql-shim-e2f4aeb61cae100653b61c10a1424771eb6ff25c.tar.bz2
Fix return values for `mysql_fetch_*` functions
The methods `mysql_fetch_* and `mysqli_fetch_*` have different return values, if there is no [more] results to fetch. Therefore the **null** return value of `mysqli` needs to be matched to the **false** return value of `mysql`. Thanks to @muhammedalialat
Diffstat (limited to 'tests/MySqlShimTest.php')
-rw-r--r--tests/MySqlShimTest.php36
1 files changed, 34 insertions, 2 deletions
diff --git a/tests/MySqlShimTest.php b/tests/MySqlShimTest.php
index 2c8adcf..18b7cd2 100644
--- a/tests/MySqlShimTest.php
+++ b/tests/MySqlShimTest.php
@@ -489,6 +489,20 @@ class MySqlShimTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(sizeof($results), $i);
}
+ /**
+ * @param $function
+ * @dataProvider mysql_fetch_no_rows_dataProvider
+ */
+ public function test_mysql_fetch_no_rows($function)
+ {
+ $this->getConnection("shim_test");
+ $result = mysql_query("SELECT * FROM testing WHERE one = 'fail'");
+
+ $this->assertResult($result);
+ $this->assertEquals(0, mysql_num_rows($result));
+ $this->assertFalse($function($result));
+ }
+
public function test_mysql_num_rows()
{
$this->getConnection("shim_test");
@@ -654,8 +668,8 @@ class MySqlShimTest extends \PHPUnit_Framework_TestCase
if (!empty($dm)) {
fwrite(STDERR, "=> Starting Docker Machine\n");
- exec($dm . ' create -d virtualbox mysql-shim');
- exec($dm . ' start mysql-shim');
+ passthru($dm . ' create -d virtualbox mysql-shim');
+ passthru($dm . ' start mysql-shim');
$env = '';
exec($dm . ' env mysql-shim', $env);
@@ -778,6 +792,24 @@ class MySqlShimTest extends \PHPUnit_Framework_TestCase
];
}
+ public function mysql_fetch_no_rows_dataProvider()
+ {
+ return [
+ [
+ 'function' => 'mysql_fetch_array',
+ ],
+ [
+ 'function' => 'mysql_fetch_assoc',
+ ],
+ [
+ 'function' => 'mysql_fetch_row',
+ ],
+ [
+ 'function' => 'mysql_fetch_object',
+ ],
+ ];
+ }
+
public function mysql_function_invalid_result_DataProvider()
{
return [