Fix testExtensionsAreNotInitializedWhenRenderingACompiledTemplate#4263
Merged
Conversation
Member
|
you could check that |
Contributor
Author
|
I tried your suggestion: $twig = new Environment($loader, $options);
$extension = $this->createMock(ExtensionInterface::class);
$extension->expects($this->never())->method($this->anything());
$twig->addExtension($extension);With this, the test fails. My assumption is that the test guesses the cache key wrong. |
Contributor
Author
|
Adding the extension changes the cache key. 🤦🏻♂️ I'll try to work around that. |
2fcd652 to
3a4d513
Compare
Contributor
Author
|
I think, I've fixed the test. Thank you for your help, @stof. |
Contributor
|
Thank you @derrabus. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I stumbled over this test while checking for PHPUnit deprecations. In this case, we need to do something about the
setMethods()call which has been removed in PHPUnit 11.However, we add an expectation for a method
initExtensions()which has been removed a long time ago. So, if that method was actually called, we'd get an error anyway. Expecting this method not to be called feels a little redundant.This basically means, we can run this test against an unmockedEnvironment. But if we do so, the test does not really test what it's supposed to test which is why I decided to remove the whole test.Update: Instead, I'm now registering an extension that throws if we try to initialize it.