php-sqlsrv/test/pdo_sqlsrv/pdo_connection_quote.phpt
2017-03-07 16:47:38 -08:00

75 lines
1.6 KiB
PHP

--TEST--
testing the quote method with different inputs and then test with a empty query
--SKIPIF--
--FILE--
<?php
include 'pdo_tools.inc';
function Quote()
{
require("autonomous_setup.php");
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
$output1 = $conn->quote("1'2'3'4'5'6'7'8", PDO::PARAM_INT);
var_dump($output1);
$output2 = $conn->quote("{ABCD}'{EFGH}", PDO::PARAM_STR);
var_dump($output2);
$output3 = $conn->quote("<XmlTestData><Letters>The quick brown fox jumps over the lazy dog</Letters><Digits>0123456789</Digits></XmlTestData>");
var_dump($output3);
$stmt = $conn->query("");
if ($stmt != false)
{
echo("Empty query was expected to fail!\n");
}
$stmt1 = $conn->prepare($output2);
$result = $stmt1->execute();
if ($result != false)
{
echo("This query was expected to fail!\n");
}
$stmt1 = null;
$stmt2 = $conn->query($output3);
if ($stmt2 != false)
{
echo("This query was expected to fail!\n");
}
$conn = null;
}
function Repro()
{
StartTest("pdo_connection_quote");
try
{
Quote();
}
catch (Exception $e)
{
echo $e->getMessage();
}
echo "\nDone\n";
EndTest("pdo_connection_quote");
}
Repro();
?>
--EXPECT--
...Starting 'pdo_connection_quote' test...
string(24) "'1''2''3''4''5''6''7''8'"
string(16) "'{ABCD}''{EFGH}'"
string(118) "'<XmlTestData><Letters>The quick brown fox jumps over the lazy dog</Letters><Digits>0123456789</Digits></XmlTestData>'"
Done
...Test 'pdo_connection_quote' completed successfully.