added autonomous setup to test

This commit is contained in:
Hadis Kakanejadi Fard 2017-02-21 16:54:47 -08:00
parent 72e7efbaf6
commit a5983ef546

View file

@ -1,24 +1,24 @@
--TEST-- --TEST--
Test fetch from binary columns, without setting binary encoding. Test fetch from binary, varbinary, varbinary(max), image columns, without setting binary encoding.
--Description--
--DESCRIPTION--
Verifies GitHub issue 270 is fixed, users could not retrieve the data as inserted in binary columns without setting the binary encoding either on stmt or using bindCoulmn encoding. Verifies GitHub issue 270 is fixed, users could not retrieve the data as inserted in binary columns without setting the binary encoding either on stmt or using bindCoulmn encoding.
This test versifies that the data inserted in binary columns can be retrieved using fetch, fetchColumn, fetchObject, and fetchALL functions. This test versifies that the data inserted in binary columns can be retrieved using fetch, fetchColumn, fetchObject, and fetchALL functions.
--FILE-- --FILE--
<?php <?php
$server = "HADISF-W541";
$databaseName = "myTest";
$uid = 'sa';
$pwd = 'Moonshine4me'; require_once("autonomous_setup.php");
$tableName = 'test_binary'; $tableName = 'test_binary';
$columns = array( 'col1', 'col2', 'col3', 'col4'); $columns = array( 'col1', 'col2', 'col3', 'col4');
$conn = new PDO( "sqlsrv:server=$server ; Database = $databaseName", "$uid", "$pwd"); // Connect
$conn = new PDO( "sqlsrv:server=$serverName", "$username", "$password" );
// CREATE database
$sql = "DROP TABLE $tableName"; $conn->query("CREATE DATABASE ". $dbName) ?: die();
$conn->exec($sql);
$sql = "CREATE TABLE $tableName ( $columns[0] binary(50), $columns[1] VARBINARY(50) ,$columns[2] VARBINARY(MAX), $columns[3] image)"; $sql = "CREATE TABLE $tableName ( $columns[0] binary(50), $columns[1] VARBINARY(50) ,$columns[2] VARBINARY(MAX), $columns[3] image)";
$conn->exec($sql); $conn->exec($sql);
@ -39,6 +39,12 @@ $stmt->execute();
foreach ($columns as $col){ foreach ($columns as $col){
test_fetch($conn, $tableName, $col, $icon); test_fetch($conn, $tableName, $col, $icon);
} }
// DROP database
$conn->query("DROP DATABASE ". $dbName) ?: die();
//free connection
$conn=null;
print_r("Test finished successfully"); print_r("Test finished successfully");
//calls various fetch methods //calls various fetch methods
@ -86,9 +92,6 @@ function test_fetch($conn, $tableName, $columnName, $input){
} }
} }
?> ?>
--EXPECT-- --EXPECT--
Test finished successfully Test finished successfully