Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FK exception tests #3800

Merged
merged 1 commit into from
Jan 4, 2020
Merged

Refactor FK exception tests #3800

merged 1 commit into from
Jan 4, 2020

Conversation

BenMorel
Copy link
Contributor

@BenMorel BenMorel commented Dec 30, 2019

Q A
Type improvement
BC Break no
Fixed issues none

Summary

Several tests can be greatly simplified by delegating the tear-down tasks to finally {}, instead of catching and re-throwing exceptions.

This works fine with expectException(), too.

Moved FK exception tests to their own class with proper setUp()/tearDown().

@BenMorel
Copy link
Contributor Author

Note: the SQL Server failure on Travis seems unrelated to this change:

Doctrine\Tests\DBAL\Functional\Platform\DefaultExpressionTest::testCurrentTimestamp
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'2019-12-30 14:14:15.770000'
+'2019-12-30 14:14:15.766667'

Should I force push the previous commit to restart the build?


throw $exception;
} catch (Throwable $exception) {
} finally {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to extract this test to a separate class and let PHPUnit take care of calling it? Or just make this routine part of the shared teardown? Calling it manually and having flow control logic in a test still smells.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does smell, but smells less than before! ;-) That's a good point, though. Moved to their own class with proper setUp()/tearDown() in da3a944.

@BenMorel BenMorel changed the title Refactor catch/rethrow to finally Refactor FK exception tests Dec 30, 2019
SenseException
SenseException previously approved these changes Jan 3, 2020
@SenseException
Copy link
Member

A rebase is probably needed before this can be merged.

@BenMorel
Copy link
Contributor Author

BenMorel commented Jan 4, 2020

Rebased & squashed!

@morozov morozov added this to the 3.0.0 milestone Jan 4, 2020
@morozov morozov merged commit f7f1567 into doctrine:master Jan 4, 2020
@morozov
Copy link
Member

morozov commented Jan 4, 2020

Thanks @BenMorel!

@morozov morozov self-assigned this Jan 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants