Skip to content

Commit ae51a00

Browse files
committed
Fixed upsert test with PHP < 7.0.13
1 parent 91e9af2 commit ae51a00

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/CommandTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,25 @@ public function testCreateView() {
329329
*/
330330
public function testUpsert(array $firstData, array $secondData)
331331
{
332-
$db = $this->getConnection(false);
332+
$db = $this->getConnection();
333333
if ($firstData['params'][1] instanceof \yii\db\Query && version_compare($db->firebird_version, '3.0.0', '<')) {
334334
$this->setExpectedException('\yii\base\NotSupportedException', 'Firebird < 3.0.0 has the "Unstable Cursor" problem');
335335
}
336-
parent::testUpsert($firstData, $secondData);
336+
337+
if (version_compare(phpversion('pdo_firebird'), '7.0.13', '<=')) {
338+
//Change BLOB to VARCHAR(8191)
339+
$db->createCommand()->renameColumn('{{T_upsert}}', 'address', 'address_old')->execute();
340+
$db->createCommand()->addColumn('{{T_upsert}}', 'address', 'string(8191)')->execute();
341+
$db->createCommand()->update('{{T_upsert}}', ['address'=>new Expression('CAST(address_old AS VARCHAR(8191))')])->execute();
342+
$db->createCommand()->dropColumn('{{T_upsert}}', 'address_old')->execute();
343+
$db->close();
344+
$db->open();
345+
}
346+
347+
$this->assertEquals(0, $db->createCommand('SELECT COUNT(*) FROM {{T_upsert}}')->queryScalar());
348+
$this->performAndCompareUpsertResult($db, $firstData);
349+
$this->assertEquals(1, $db->createCommand('SELECT COUNT(*) FROM {{T_upsert}}')->queryScalar());
350+
$this->performAndCompareUpsertResult($db, $secondData);
337351
}
338352

339353
}

0 commit comments

Comments
 (0)