diff options
author | Davey Shafik <davey@php.net> | 2020-10-27 08:46:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-27 08:46:49 +0000 |
commit | 88d7a19ea443bb2240910b0788dc7e0c920640b7 (patch) | |
tree | beb9a8c48081081988f0d52ec89c7b9bdc380c46 | |
parent | 8834b6c6d18b57124e45c29011d7fad76698d6b6 (diff) | |
download | php7-mysql-shim-88d7a19ea443bb2240910b0788dc7e0c920640b7.zip php7-mysql-shim-88d7a19ea443bb2240910b0788dc7e0c920640b7.tar.gz php7-mysql-shim-88d7a19ea443bb2240910b0788dc7e0c920640b7.tar.bz2 |
Try to fix mysql_fetch_object() test on PHP 5.6
-rw-r--r-- | tests/MySqlShimTest.php | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/MySqlShimTest.php b/tests/MySqlShimTest.php index 92279a3..2d921f8 100644 --- a/tests/MySqlShimTest.php +++ b/tests/MySqlShimTest.php @@ -758,12 +758,24 @@ class MySqlShimTest extends \Yoast\PHPUnitPolyfills\TestCases\TestCase /** * @dataProvider mysql_fetch_object_dataProvider */ - public function test_mysql_fetch_object($className, $params, $paramsResult) + public function test_mysql_fetch_object($className, $params, $expectedParams) { $this->getConnection('shim_test'); $result = mysql_query("SELECT one, two FROM testing LIMIT 2"); - while ($row = mysql_fetch_object($result, $className, $params)) { + $fetch = function($result) use ($className, $params) { + if ($className === null) { + return mysql_fetch_object($result); + } + + if ($params === array()) { + return mysql_fetch_object($result, $className); + } + + return mysql_fetch_object($result, $className, $params); + }; + + while ($row = $fetch($result)) { if ($className === null) { $this->assertInstanceOf('stdClass', $row); } else { @@ -773,9 +785,9 @@ class MySqlShimTest extends \Yoast\PHPUnitPolyfills\TestCases\TestCase $this->assertNotEmpty($row->one); $this->assertNotEmpty($row->two); - if ($paramsResult !== null) { - $this->assertEquals($paramsResult['foo'], $row->foo); - $this->assertEquals($paramsResult['bar'], $row->bar); + if ($expectedParams !== null) { + $this->assertEquals($expectedParams['foo'], $row->foo); + $this->assertEquals($expectedParams['bar'], $row->bar); } } } @@ -1195,12 +1207,12 @@ class MySqlShimTest extends \Yoast\PHPUnitPolyfills\TestCases\TestCase array( 'class' => null, 'params' => array(), - 'paramsMatch' => null, + 'expectedParams' => null, ), array( 'class' => '\Dshafik\MySQL\Tests\TestResult', 'params' => array(), - 'paramsMatch' => array( + 'expectedParams' => array( 'foo' => TestResult::DEFAULT_PARAM_VALUE, 'bar' => TestResult::DEFAULT_PARAM_VALUE, ) @@ -1208,7 +1220,7 @@ class MySqlShimTest extends \Yoast\PHPUnitPolyfills\TestCases\TestCase array( 'class' => '\Dshafik\MySQL\Tests\TestResult', 'params' => array(TestResult::SET_VALUE, TestResult::SET_VALUE + 1), - 'paramsMatch' => array( + 'expectedParams' => array( 'foo' => TestResult::SET_VALUE, 'bar' => TestResult::SET_VALUE + 1 ) |