Skip to content

Commit

Permalink
WithoutErrorHandler on the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Aug 29, 2024
1 parent b0cb24b commit 89db034
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Yiisoft\Db\Mysql\Tests;

use PDO;
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
use Throwable;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Exception\Exception;
Expand Down Expand Up @@ -127,6 +128,7 @@ static function (ConnectionInterface $db) {
}

/** @link https://github.com/yiisoft/db-mysql/issues/348 */
#[WithoutErrorHandler]
public function testRestartConnectionOnTimeout(): void
{
$db = $this->getConnection();
Expand All @@ -135,17 +137,14 @@ public function testRestartConnectionOnTimeout(): void

sleep(2);

$previousErrorLevel = error_reporting(E_ALL & ~E_WARNING);

$result = $db->createCommand("SELECT '1'")->queryScalar();

error_reporting($previousErrorLevel);

$this->assertSame('1', $result);

$db->close();
}

#[WithoutErrorHandler]
public function testNotRestartConnectionOnTimeoutInTransaction(): void
{
$db = $this->getConnection();
Expand All @@ -158,12 +157,6 @@ public function testNotRestartConnectionOnTimeoutInTransaction(): void
$this->expectException(IntegrityException::class);
$this->expectExceptionMessage('SQLSTATE[HY000]: General error: 2006 MySQL server has gone away');

$previousErrorLevel = error_reporting(E_ALL & ~E_WARNING);

try {
$db->createCommand("SELECT '1'")->queryScalar();
} finally {
error_reporting($previousErrorLevel);
}
$db->createCommand("SELECT '1'")->queryScalar();
}
}

0 comments on commit 89db034

Please sign in to comment.