From 30258780317fc25fe12faf37202404e6d6b59cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20M=C3=BCller?= Date: Thu, 10 Sep 2015 18:41:15 +0200 Subject: [PATCH] fix tear down of some test cases --- .../Tests/DBAL/Functional/ExceptionTest.php | 58 ++++++++++++++++--- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php index c63409eba72..27f1e0490dd 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php @@ -64,8 +64,14 @@ public function testForeignKeyConstraintViolationExceptionOnInsert() $this->setUpForeignKeyConstraintViolationExceptionTest(); - $this->_conn->insert("constraint_error_table", array('id' => 1)); - $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1)); + try { + $this->_conn->insert("constraint_error_table", array('id' => 1)); + $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1)); + } catch (\Exception $exception) { + $this->tearDownForeignKeyConstraintViolationExceptionTest(); + + throw $exception; + } $this->setExpectedException('\Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException'); @@ -74,6 +80,10 @@ public function testForeignKeyConstraintViolationExceptionOnInsert() } catch (ForeignKeyConstraintViolationException $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); + throw $exception; + } catch (\Exception $exception) { + $this->tearDownForeignKeyConstraintViolationExceptionTest(); + throw $exception; } @@ -88,8 +98,14 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate() $this->setUpForeignKeyConstraintViolationExceptionTest(); - $this->_conn->insert("constraint_error_table", array('id' => 1)); - $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1)); + try { + $this->_conn->insert("constraint_error_table", array('id' => 1)); + $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1)); + } catch (\Exception $exception) { + $this->tearDownForeignKeyConstraintViolationExceptionTest(); + + throw $exception; + } $this->setExpectedException('\Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException'); @@ -98,6 +114,10 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate() } catch (ForeignKeyConstraintViolationException $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); + throw $exception; + } catch (\Exception $exception) { + $this->tearDownForeignKeyConstraintViolationExceptionTest(); + throw $exception; } @@ -112,8 +132,14 @@ public function testForeignKeyConstraintViolationExceptionOnDelete() $this->setUpForeignKeyConstraintViolationExceptionTest(); - $this->_conn->insert("constraint_error_table", array('id' => 1)); - $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1)); + try { + $this->_conn->insert("constraint_error_table", array('id' => 1)); + $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1)); + } catch (\Exception $exception) { + $this->tearDownForeignKeyConstraintViolationExceptionTest(); + + throw $exception; + } $this->setExpectedException('\Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException'); @@ -122,6 +148,10 @@ public function testForeignKeyConstraintViolationExceptionOnDelete() } catch (ForeignKeyConstraintViolationException $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); + throw $exception; + } catch (\Exception $exception) { + $this->tearDownForeignKeyConstraintViolationExceptionTest(); + throw $exception; } @@ -132,14 +162,20 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate() { $platform = $this->_conn->getDatabasePlatform(); - if ( ! $platform->supportsForeignKeyConstraints()) { + if (!$platform->supportsForeignKeyConstraints()) { $this->markTestSkipped("Only fails on platforms with foreign key constraints."); } $this->setUpForeignKeyConstraintViolationExceptionTest(); - $this->_conn->insert("constraint_error_table", array('id' => 1)); - $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1)); + try { + $this->_conn->insert("constraint_error_table", array('id' => 1)); + $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1)); + } catch (\Exception $exception) { + $this->tearDownForeignKeyConstraintViolationExceptionTest(); + + throw $exception; + } $this->setExpectedException('\Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException'); @@ -148,6 +184,10 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate() } catch (ForeignKeyConstraintViolationException $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); + throw $exception; + } catch (\Exception $exception) { + $this->tearDownForeignKeyConstraintViolationExceptionTest(); + throw $exception; }