-
-
Notifications
You must be signed in to change notification settings - Fork 106
feat(2.9): deprecate ResetDatabase trait
#985
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
base: 2.x
Are you sure you want to change the base?
feat(2.9): deprecate ResetDatabase trait
#985
Conversation
ResetDatabase trait
43f4a0b to
91dd0a7
Compare
91dd0a7 to
a3f404b
Compare
f898cd3 to
f48fbd2
Compare
| public function boot(): void | ||
| { | ||
| if ($this->container) { | ||
| if ($this->container && (!Configuration::isBooted() || !FoundryExtension::isEnabled())) { |
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.
@HypeMC, just for you to know:
now we're deprecating the usage of ResetDatabase trait in favor of an attribute + usage of the PHPUnit extension, I had errors ServiceNotFoundException: The "kernel" service is synthetic, it needs to be set at boot time before it can be used. in the database reset testsuite.
Because this currently needs to work with and without the ResetDatabase trait, the only solution I found was to check if the extension is enabled.
Don't hesitate if you have another idea. Anyway, this ugly stuff will be removed in Foundry 3
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.
@nikophil Hello, thank you for the heads-up. I've tested this branch, and unfortunately, this change seems to bring back the original issue. I haven't had time to look into it in detail yet, but I'll try to figure it out.
EDIT: Switching to the #[ResetDatabase] attribute does solve the problem.
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.
The reason the EarlyBootedKernelWithTraitsTest passes is that it's no longer the first test, so ResetDatabaseManager::hasDatabaseBeenReset is true.
It needs to be false for the test to fail, e.g. try running it individually:
./phpunit tests/Integration/ResetDatabase/EarlyBootedKernelWithTraitsTest.php
Perhaps the before() method could be improved:
#[BeforeClass(10)]
public static function before(): void
{
$ref = new \ReflectionProperty(ResetDatabaseManager::class, 'hasDatabaseBeenReset');
$ref->setValue(false);
self::bootKernel();
}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.
@HypeMC I'm not sure what's the best way to fix this: we would need a marker to tell "reset database trait was used" to decide whether to check Configuration::isBooted() in ZenstruckFoundryBundle::boot() method
this becomes overly complex for such a niche bug, moreover that the problem will only occur when using the newly deprecated trait ResetDatabase
I think it will stay this way, unless you have a good idea
bbeb282 to
874ce5a
Compare
874ce5a to
557aa86
Compare
Uh oh!
There was an error while loading. Please reload this page.