Created
September 27, 2018 15:19
-
-
Save odinuv/1a5563fc33921dfbff792f4d69b69de4 to your computer and use it in GitHub Desktop.
Testing the untestable: Test network kill during execute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testNetworkKillerExecute() | |
{ | |
$conn = $this->getConnection(); | |
// sleep 1 second before killing, then kill it for 3 seconds | |
exec('php killNetwork.php 1 3 > /dev/null &'); | |
ErrorHandler::register(null, true); | |
// sleep a while to make sure the connection is terminated | |
sleep(2); | |
$stmt = $conn->query('SELECT NOW();'); | |
self::expectException(\ErrorException::class); | |
self::expectExceptionMessage('Warning: PDOStatement::execute(): MySQL server has gone away'); | |
$stmt->execute(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment