Skip to content

Commit

Permalink
Merge pull request #904 from deeky666/fix-functional-exception-test
Browse files Browse the repository at this point in the history
Fix tear down of some functional exception test cases
  • Loading branch information
Bill Schaller committed Sep 10, 2015
2 parents a46556f + 3025878 commit 9ea8b0a
Showing 1 changed file with 49 additions and 9 deletions.
58 changes: 49 additions & 9 deletions tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -74,6 +80,10 @@ public function testForeignKeyConstraintViolationExceptionOnInsert()
} catch (ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
} catch (\Exception $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
}

Expand All @@ -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');

Expand All @@ -98,6 +114,10 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate()
} catch (ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
} catch (\Exception $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
}

Expand All @@ -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');

Expand All @@ -122,6 +148,10 @@ public function testForeignKeyConstraintViolationExceptionOnDelete()
} catch (ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
} catch (\Exception $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
}

Expand All @@ -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');

Expand All @@ -148,6 +184,10 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate()
} catch (ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
} catch (\Exception $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
}

Expand Down

0 comments on commit 9ea8b0a

Please sign in to comment.