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

Convert some unit tests to integration tests #6820

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

morozov
Copy link
Member

@morozov morozov commented Mar 5, 2025

The new test is loaded with exceptions but it is what it is. We may address the underlying issues separately.

The code coverage has slightly dropped, which I anticipated. The original unit tests produced coverage for the code that generates DDL for MySQL, but didn't validate its correctness. Now these code paths may be not covered, because they are incorrect and would fail the test (see the tests marked as incomplete on MySQL).

We have to skip the majority of the tests on the majority of the platforms because DBAL doesn't support dropping primary key constraints there (the same issue is documented #6819).

@morozov morozov force-pushed the alter-table-integration-testing branch from e7837c9 to 31849c1 Compare March 5, 2025 07:06
@morozov morozov added this to the 4.2.3 milestone Mar 5, 2025
@morozov morozov changed the title Convert some test to integration tests Convert some unit tests to integration tests Mar 5, 2025
@morozov morozov marked this pull request as ready for review March 5, 2025 07:43
@morozov morozov requested a review from greg0ire March 5, 2025 07:44
greg0ire
greg0ire previously approved these changes Mar 5, 2025

class AlterTableTest extends FunctionalTestCase
{
/** @throws Exception */
Copy link
Member

Choose a reason for hiding this comment

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

What's the point of this annotation?

Copy link
Member

Choose a reason for hiding this comment

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

@throws annotations on unit tests don't make much sense. Noboby's going to catch them except for PHPUnit itself. We should remove them.

Copy link
Member Author

@morozov morozov Mar 5, 2025

Choose a reason for hiding this comment

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

What's the point of this annotation?

Normally, it shows that a method throws a checked exception, which the caller should either catch or declare as @throws in its own signature.

IIRC, PhpStorm by default considers all exceptions that don't extend RuntimeException or LogicException checked (I'll add the screenshot just for reference, we don't design our code for PhpStorm).
Screenshot 2025-03-05 at 9 33 26 AM
If this annotation is removed, it starts underlining the methods that throw an unhandled checked exception.

Screenshot 2025-03-05 at 7 26 44 AM

I don't think this annotation makes a lot of sense for the readers of this code because this method is not invoked explicitly. However it makes PhpStorm happier. Maybe instead of adding these annotations on test methods, I could suppress this inspection for tests in PhpStorm.

Copy link
Member

Choose a reason for hiding this comment

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

Yes… maybe this could even be reported to PHPStorm, I guess they must have some kind of PHPUnit integration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reported as WI-80744.

Copy link
Member

Choose a reason for hiding this comment

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

I'm generally not happy with the way PhpStorm deals with exceptions, but I guess that's what we get when Java people build a PHP editor. 😉 This inspection is more or less the first thing I deactivate or disable the highlighting for when configuring PhpStorm for a new project.

}

/** @throws Exception */
private function testMigration(Table $oldTable, callable $migration): void
Copy link
Member

Choose a reason for hiding this comment

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

We should not use the test prefix on methods that we don't want PHPUnit to pick up as tests. I am aware that PHPUnit will skip the method because it's private, but still: we can probably find a better name.

Copy link
Member Author

@morozov morozov Mar 5, 2025

Choose a reason for hiding this comment

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

I don't think using the test prefix is a problem – right because PHPUnit will skip it, and in this specific case, the method does contain the body of the test (so the name is appropriate). I'm open to suggestions on renaming the method.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to merge as it's not a blocker. Happy to rename this one and potentially other similar methods in a separate PR.

@morozov morozov force-pushed the alter-table-integration-testing branch from 31849c1 to 90e365c Compare March 5, 2025 19:48
@morozov morozov merged commit 37ab825 into doctrine:4.2.x Mar 6, 2025
66 checks passed
@morozov morozov deleted the alter-table-integration-testing branch March 6, 2025 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants