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

Use expectException(Message) instead of annotations #2076

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

olvlvl
Copy link
Contributor

@olvlvl olvlvl commented Oct 2, 2019

Q A
Type improvement
BC Break no

Summary

The @expectedException and @expectedExceptionMessage annotations are deprecated. They will be removed in PHPUnit 9. This PR replaces @expectedException and @expectedExceptionMessage annotations with expectedException() and expectedExceptionMessage().

My only concern is with OutTest because builder->out() is throwing the exception, not builder->getPipeline().

@malarzm
Copy link
Member

malarzm commented Oct 2, 2019

My only concern is with OutTest because builder->out() is throwing the exception, not builder->getPipeline().

I think that getPipeline() call could be removed in this case

@@ -82,6 +79,7 @@ public function testExpressionWithoutField()

$expr = $this->createExpr();

$this->expectException(\LogicException::class);
Copy link
Member

Choose a reason for hiding this comment

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

Personally I prefer putting expectException as a first thing in a test but I'm not sure what's the preference of us as a team :)

Copy link
Contributor Author

@olvlvl olvlvl Oct 3, 2019

Choose a reason for hiding this comment

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

We put the expectException() just before the thing that is expected to throw an exception, because some exceptions such as \InvalidArgumentException can be thrown in many cases. Let me know what to do.

Copy link
Member

Choose a reason for hiding this comment

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

Your usage is correct - test setup should not trigger the expected exception by accident. Please leave it as is 👍

@malarzm malarzm added the Task label Oct 2, 2019
@olvlvl olvlvl force-pushed the expected-exception branch 2 times, most recently from 9d303ee to b925e96 Compare October 3, 2019 07:46
Copy link
Member

@malarzm malarzm left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

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

Great! I'd squash both commits together, since it's very unlikely that we would revert one and not the other.

@olvlvl
Copy link
Contributor Author

olvlvl commented Oct 3, 2019

@greg0ire Do you want me to do the squash, or will you squash+merge?

@olvlvl olvlvl changed the title Use expectException instead of annotation Use expectException(Message) instead of annotation Oct 3, 2019
@olvlvl olvlvl changed the title Use expectException(Message) instead of annotation Use expectException(Message) instead of annotations Oct 3, 2019
@malarzm
Copy link
Member

malarzm commented Oct 3, 2019

@olvlvl please squash, we're not using squash+merge as it's not doing an actual merge (or it wasn't doing this last time we were checking)

@greg0ire
Copy link
Member

greg0ire commented Oct 3, 2019

Also, we would rather have you be in charge of the final commit message ;)

The @ExpectedException and @expectedExceptionMessage annotations
are deprecated. They will be removed in PHPUnit 9.
@olvlvl
Copy link
Contributor Author

olvlvl commented Oct 3, 2019

Squashed.

@greg0ire greg0ire merged commit 7f12145 into doctrine:master Oct 3, 2019
@greg0ire
Copy link
Member

greg0ire commented Oct 3, 2019

Thanks @olvlvl !

@olvlvl olvlvl deleted the expected-exception branch October 3, 2019 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants