Skip to content

Commit 13096ec

Browse files
committed
add integration test
1 parent 72ccd84 commit 13096ec

File tree

1 file changed

+31
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo

1 file changed

+31
-0
lines changed

dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,37 @@ protected function tearDown(): void
3434
restore_error_handler();
3535
}
3636

37+
/**
38+
* Check PDO stringify fetches options
39+
*/
40+
public function testStringifyFetches(): void
41+
{
42+
$tableName = $this->resourceConnection->getTableName('table_with_int_column');
43+
$columnId = 'integer_column';
44+
$adapter = $this->getDbAdapter();
45+
46+
$table = $adapter
47+
->newTable($tableName)
48+
->addColumn($columnId, Table::TYPE_INTEGER);
49+
$adapter->createTable($table);
50+
$adapter->insert($tableName, [$columnId => 100]);
51+
52+
$select = $adapter->select()
53+
->from($tableName)
54+
->columns([$columnId])
55+
->limit(1);
56+
$result = $adapter->fetchOne($select);
57+
58+
$isStringify = $adapter->getConfig()['driver_options'][\PDO::ATTR_STRINGIFY_FETCHES] ?? null;
59+
if ($isStringify || $isStringify === null) {
60+
$this->assertIsString($result);
61+
} else { // option is set to False
62+
$this->assertIsInt($result);
63+
}
64+
65+
$adapter->dropTable($tableName);
66+
}
67+
3768
/**
3869
* Test lost connection re-initializing
3970
*

0 commit comments

Comments
 (0)