forked from zendframework/zend-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes zendframework#330 current NULL for mysqli
- Loading branch information
1 parent
6df64e0
commit dd6b251
Showing
4 changed files
with
96 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
test/integration/Adapter/Driver/Mysqli/TableGatewayTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace ZendIntegrationTest\Db\Adapter\Driver\Mysqli; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Zend\Db\Adapter\Adapter; | ||
use Zend\Db\TableGateway\TableGateway; | ||
|
||
class TableGatewayTest extends TestCase | ||
{ | ||
use TraitSetup; | ||
|
||
/** | ||
* @see https://github.com/zendframework/zend-db/issues/330 | ||
*/ | ||
public function testSelectWithEmptyCurrentWithBufferResult() | ||
{ | ||
$adapter = new Adapter([ | ||
'driver' => '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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-db for the canonical source repository | ||
* @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com) | ||
* @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
namespace ZendIntegrationTest\Db\Adapter\Driver\Mysqli; | ||
|
||
trait TraitSetup | ||
{ | ||
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); | ||
} | ||
} | ||
} |