Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Tests] StreamlineCompiledUrlGenerator tests#52481

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@OskarStark
Copy link
Contributor

@OskarStarkOskarStark commentedNov 7, 2023
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?no
Deprecations?no
IssuesFollows#52402
LicenseMIT

weird, it looks like the expected exception is thrown in $this->generatorDumper->dump() 🤔 So the following code with the CompiledUrlGenerator is not needed, so maybe the test is not needed anymore or the test must be adjusted somehow to test the behavior of CompiledUrlgenerator....

@OskarStarkOskarStark self-assigned thisNov 7, 2023
@carsonbotcarsonbot added this to the6.4 milestoneNov 7, 2023
$compiledUrlGenerator->generate('a');
}

publicfunctiontestTargetAliasWithNamePrefixNotExisting()
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

after investigating why testTargetAliasWithNamePrefixNotExisting are now failing I found out, that both, CompiledUrlGeneratorDUMPER and CompiledUrlGenerator throw a RouteNotFoundException. We are testing $compiledUrlGenerator->generate('sub_a) here, but the exception is already thrown in file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump()); when generating the dump to prepare a file.

So now after moving the expectedException method call down, I can say, that we are actually not testing the behavior of CompiledUrlGenerator in this test 🤷‍♂️

Same applies to testTargetAliasNotExisting

@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@OskarStarkOskarStark changed the title[Tests] Streamline CompiledUrlGenerator tests[Tests] StreamlineCompiledUrlGenerator testsDec 20, 2023
@OskarStarkOskarStarkforce-pushed thestreamline-compiled-url-gen-test branch from35dec94 to9aaf1f0CompareDecember 27, 2023 08:52
@OskarStarkOskarStark added the Help wantedIssues and PRs which are looking for volunteers to complete them. labelDec 27, 2023
@alexandre-daubois
Copy link
Member

What about:

diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.phpindex 8603ab6d98..572f524a05 100644--- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php+++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php@@ -267,66 +272,72 @@ class CompiledUrlGeneratorDumperTest extends TestCase      public function testTargetAliasNotExisting()     {-        $this->expectException(RouteNotFoundException::class);--        $this->routeCollection->addAlias('a', 'not-existing');+        $this->routeCollection->add('not-existing', new Route('/not-existing'));+        $this->routeCollection->addAlias('alias', 'not-existing');          file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());-        $compiledUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());+        $compiledRoutes = require $this->testTmpFilepath;+        unset($compiledRoutes['alias']);+        $this->expectException(RouteNotFoundException::class);++        $compiledUrlGenerator = new CompiledUrlGenerator($compiledRoutes, new RequestContext());         $compiledUrlGenerator->generate('a');     }      public function testTargetAliasWithNamePrefixNotExisting()     {-        $this->expectException(RouteNotFoundException::class);-         $subCollection = new RouteCollection();-        $subCollection->addAlias('a', 'not-existing');+        $subCollection->add('not-existing', new Route('/not-existing'));+        $subCollection->addAlias('alias', 'not-existing');         $subCollection->addNamePrefix('sub_');          $this->routeCollection->addCollection($subCollection);          file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());-        $compiledUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());+        $compiledRoutes = require $this->testTmpFilepath;+        unset($compiledRoutes['sub_alias']);-        $compiledUrlGenerator->generate('sub_a');+        $this->expectException(RouteNotFoundException::class);++        $compiledUrlGenerator = new CompiledUrlGenerator($compiledRoutes, new RequestContext());+        $compiledUrlGenerator->generate('sub_alias');     }

We generate the file with the existing route then we remove it from compiled ones. This way, we ensure that we test the exception coming from route generation. Works on my computer 😄

@OskarStark
Copy link
ContributorAuthor

Thanks, lets see

@alexandre-daubois
Copy link
Member

Seems to do the job!

@OskarStarkOskarStarkforce-pushed thestreamline-compiled-url-gen-test branch fromcdc20fb toa778254CompareDecember 27, 2023 12:05
@OskarStark
Copy link
ContributorAuthor

@nicolas-grekas I think this should be merged into5.4

@nicolas-grekasnicolas-grekas modified the milestones:7.1,5.4Dec 27, 2023
@nicolas-grekas
Copy link
Member

Works for me, please rebase.

OskarStark reacted with thumbs up emoji

@OskarStarkOskarStarkforce-pushed thestreamline-compiled-url-gen-test branch froma778254 to807d70eCompareDecember 27, 2023 12:51
@OskarStarkOskarStark changed the base branch from7.1 to5.4December 27, 2023 12:51
@OskarStark
Copy link
ContributorAuthor

Rebased ✅

@OskarStarkOskarStark added Ready and removed Help wantedIssues and PRs which are looking for volunteers to complete them. labelsDec 28, 2023
@fabpot
Copy link
Member

Thank you@OskarStark.

OskarStark reacted with thumbs up emoji

@fabpotfabpot merged commit895081d intosymfony:5.4Dec 29, 2023
@OskarStarkOskarStark deleted the streamline-compiled-url-gen-test branchDecember 29, 2023 08:15
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasAwaiting requested review from nicolas-grekas

Assignees

@OskarStarkOskarStark

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

5 participants

@OskarStark@alexandre-daubois@nicolas-grekas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp