-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
feat: throw an error if Factories trait is not used in a KernelTestCase #766
base: 2.x
Are you sure you want to change the base?
feat: throw an error if Factories trait is not used in a KernelTestCase #766
Conversation
b28e7cb
to
05cef62
Compare
|
||
final class KernelTestCaseWithBothTraitsInWrongOrderTest extends KernelTestCase | ||
{ | ||
use ResetDatabase, Factories; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my different tests, I noticed that sometimes, the order of these traits could have an impact, so I wanted to test with both cases
@kbond I think I won't throw directly an error, but add a deprecation instead: Foundry kinda works without the trait in few situations... WDYT? |
bdd057d
to
dcd6ef8
Compare
trigger_deprecation( | ||
'zenstruck/foundry', | ||
'2.4', | ||
'In order to use Foundry, you must use the trait "%s" in your "%s" tests. This will throw an exception in 3.0.', | ||
KernelTestCase::class, | ||
$class | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at first I built everything to throw an error, but now I think we should not throw, it's a little bit too much violent I think 😆 🥊
But since everything is ready to throw, I propose to keep it like this in the exception
use Zenstruck\Foundry\Test\ResetDatabase; | ||
use Zenstruck\Foundry\Tests\Fixture\Factories\Object1Factory; | ||
|
||
#[RequiresPhpunit('>=11.0')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only PhpUnit 11 handles correctly deprecation, so all tests in this namespace will only be ran with phpunit 11
dcd6ef8
to
43b4e62
Compare
43b4e62
to
22ce3cf
Compare
22ce3cf
to
2dc090a
Compare
fixes #750
This "feature" was actually very challenging! 🤯