Skip to content

Commit

Permalink
laminas#214 @fix: "MySQL integration test fail in section testNamedPa…
Browse files Browse the repository at this point in the history
…rameters"/change failure test to any exception (because github-ci messages different of local messages)
  • Loading branch information
ZVanoZ committed Sep 24, 2021
1 parent 1bef71c commit b460583
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions test/integration/Adapter/Driver/Pdo/Mysql/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,17 @@ protected function getStatementForTestBinding()
public function testBindParamByIndexIsFail()
{
$stmt = $this->getStatementForTestBinding();
$this->expectExceptionMessage('Statement could not be executed (22007 - 1292 - Truncated incorrect DOUBLE value: \'bar\')');
//positional parameters - is invalid
$stmt->execute([
1, //FAIL -- 0 ":c_0" "name" varchar(255)
'foo', //OK -- 1 ":c_1" "value" varchar(255)
'bar', //FAIL -- 2 ":where1" "id" int
]);
try {
//positional parameters - is invalid
$stmt->execute([
1, //FAIL -- 0 ":c_0" "name" varchar(255)
'foo', //OK -- 1 ":c_1" "value" varchar(255)
'bar', //FAIL -- 2 ":where1" "id" int
]);
$this->assertTrue(false, __METHOD__, "/Fail. Extect exception.");
} catch (\Exception $e) {
$this->assertTrue(true, __METHOD__, "/Success. We have an exception: " . $e->getMessage());
}
}

/**
Expand All @@ -136,13 +140,17 @@ public function testBindParamByIndexIsSuccess()
public function testBindParamByNameIsFail()
{
$stmt = $this->getStatementForTestBinding();
$this->expectExceptionMessage('Statement could not be executed (22007 - 1292 - Truncated incorrect DOUBLE value: \'bar\')');
//"mapped" named parameters
$stmt->execute([
'c_0' => 1, //FAIL -- 0 ":c_0" "name" varchar(255)
'c_1' => 'foo', //OK -- 1 ":c_1" "value" varchar(255)
'where1' => 'bar', //FAIL -- 2 ":where1" "id" int
]);
try {
//"mapped" named parameters
$stmt->execute([
'c_0' => 1, //FAIL -- 0 ":c_0" "name" varchar(255)
'c_1' => 'foo', //OK -- 1 ":c_1" "value" varchar(255)
'where1' => 'bar', //FAIL -- 2 ":where1" "id" int
]);
$this->assertTrue(false, __METHOD__, "/Fail. Extect exception.");
} catch (\Exception $e) {
$this->assertTrue(true, __METHOD__, "/Success. We have an exception: " . $e->getMessage());
}
}

/**
Expand All @@ -167,13 +175,17 @@ public function testBindParamByNameIsSuccess()
public function testBindParamByFieldNameIsFail()
{
$stmt = $this->getStatementForTestBinding();
$this->expectExceptionMessage('Statement could not be executed (22007 - 1292 - Truncated incorrect DOUBLE value: \'bar\')');
//real named parameters
$stmt->execute([
'name' => 1, //FAIL -- 0 ":c_0" "name" varchar(255)
'value' => 'foo', //OK -- 1 ":c_1" "value" varchar(255)
'id' => 'bar', //FAIL -- 2 ":where1" "id" int
]);
try {
//real named parameters
$stmt->execute([
'name' => 1, //FAIL -- 0 ":c_0" "name" varchar(255)
'value' => 'foo', //OK -- 1 ":c_1" "value" varchar(255)
'id' => 'bar', //FAIL -- 2 ":where1" "id" int
]);
$this->assertTrue(false, __METHOD__, "/Fail. Extect exception.");
} catch (\Exception $e) {
$this->assertTrue(true, __METHOD__, "/Success. We have an exception: " . $e->getMessage());
}
}

/**
Expand Down

0 comments on commit b460583

Please sign in to comment.