diff --git a/src/Adapter/Driver/Mysqli/Result.php b/src/Adapter/Driver/Mysqli/Result.php index e83b3c0831..eb388eebc4 100644 --- a/src/Adapter/Driver/Mysqli/Result.php +++ b/src/Adapter/Driver/Mysqli/Result.php @@ -51,9 +51,9 @@ class Result implements protected $nextComplete = false; /** - * @var bool + * @var mixed */ - protected $currentData = false; + protected $currentData = null; /** * diff --git a/test/integration/Adapter/Driver/Mysqli/ConnectionTest.php b/test/integration/Adapter/Driver/Mysqli/ConnectionTest.php index 5282f0e029..2bb4c3aeae 100644 --- a/test/integration/Adapter/Driver/Mysqli/ConnectionTest.php +++ b/test/integration/Adapter/Driver/Mysqli/ConnectionTest.php @@ -12,37 +12,7 @@ class ConnectionTest extends TestCase { - protected $variables = [ - 'hostname' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL_HOSTNAME', - 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL_USERNAME', - 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL_PASSWORD', - 'database' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL_DATABASE', - ]; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { - if (! getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL')) { - $this->markTestSkipped('Mysqli integration test disabled'); - } - - if (! extension_loaded('mysqli')) { - $this->fail('The phpunit group integration-mysqli was enabled, but the extension is not loaded.'); - } - - foreach ($this->variables as $name => $value) { - if (! getenv($value)) { - $this->markTestSkipped(sprintf( - 'Missing required variable %s from phpunit.xml for this integration test', - $value - )); - } - $this->variables[$name] = getenv($value); - } - } + use TraitSetup; public function testConnectionOk() { diff --git a/test/integration/Adapter/Driver/Mysqli/TableGatewayTest.php b/test/integration/Adapter/Driver/Mysqli/TableGatewayTest.php new file mode 100644 index 0000000000..d46b83bfe6 --- /dev/null +++ b/test/integration/Adapter/Driver/Mysqli/TableGatewayTest.php @@ -0,0 +1,50 @@ + 'mysqli', + 'database' => $this->variables['database'], + 'hostname' => $this->variables['hostname'], + 'username' => $this->variables['username'], + 'password' => $this->variables['password'], + 'options' => ['buffer_results' => true] + ]); + $tableGateway = new TableGateway('test', $adapter); + $rowset = $tableGateway->select('id = 0'); + + $this->assertNull($rowset->current()); + } + + /** + * @see https://github.com/zendframework/zend-db/issues/330 + */ + public function testSelectWithEmptyCurrentWithoutBufferResult() + { + $adapter = new Adapter([ + 'driver' => 'mysqli', + 'database' => $this->variables['database'], + 'hostname' => $this->variables['hostname'], + 'username' => $this->variables['username'], + 'password' => $this->variables['password'], + 'options' => ['buffer_results' => false] + ]); + $tableGateway = new TableGateway('test', $adapter); + $rowset = $tableGateway->select('id = 0'); + + $this->assertNull($rowset->current()); + } +} diff --git a/test/integration/Adapter/Driver/Mysqli/TraitSetup.php b/test/integration/Adapter/Driver/Mysqli/TraitSetup.php new file mode 100644 index 0000000000..a5ee41a591 --- /dev/null +++ b/test/integration/Adapter/Driver/Mysqli/TraitSetup.php @@ -0,0 +1,43 @@ + 'TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL_HOSTNAME', + 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL_USERNAME', + 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL_PASSWORD', + 'database' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL_DATABASE', + ]; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + if (! getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL')) { + $this->markTestSkipped('Mysqli integration test disabled'); + } + + if (! extension_loaded('mysqli')) { + $this->fail('The phpunit group integration-mysqli was enabled, but the extension is not loaded.'); + } + + foreach ($this->variables as $name => $value) { + if (! getenv($value)) { + $this->markTestSkipped(sprintf( + 'Missing required variable %s from phpunit.xml for this integration test', + $value + )); + } + $this->variables[$name] = getenv($value); + } + } +}