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

Fixes error with unperisted dynamic route in sonata FrontendLinkExtension #275

Merged
merged 3 commits into from
Nov 20, 2014

Conversation

frne
Copy link
Contributor

@frne frne commented Nov 18, 2014

Fixes a serious error at the \Symfony\Cmf\Bundle\RoutingBundle\Admin\Extension\FrontendLinkExtension when a new dynamic route is created in sonata admin:

An exception has been thrown during the rendering of a template ("Can not determine the prefix. 
Either this is a new, unpersisted document or the listener that calls setPrefix is not set up correctly.") 
in SonataAdminBundle:CRUD:base_edit.html.twig at line 34.
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets symfony-cmf/cmf-sandbox#276
License MIT
Doc PR none

@@ -68,6 +68,11 @@ public function configureTabMenu(
);
}

if($subject instanceof PrefixInterface && !is_string($subject->getId())) {
Copy link
Member

Choose a reason for hiding this comment

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

missing a space after the if

@@ -68,6 +68,11 @@ public function configureTabMenu(
);
}

if ($subject instanceof PrefixInterface && !is_string($subject->getId())) {
Copy link
Member

Choose a reason for hiding this comment

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

you need to add a use statement for this interface in the header as you are in a different namespace.

any chance you can add tests for this extension? maybe configure it in Tests/Resources/app/config and check for the link (when it should exist) in Tests/WebTest/RouteAdminTest.php ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The link is already being tested (/cmf/routing/route/create). Trying to get it tested somehow...

Copy link
Member

Choose a reason for hiding this comment

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

yes it is, you just need to adjust the config to make this extension being loaded into the admin (then the problem with namespace you now fixed would have been shown as test failure). when you do, you could add a check in the web test cases to check if the frontend link is actually there (except in the create case where the whole tab must be not there, which you could test as well just to be sure)

dbu added a commit that referenced this pull request Nov 20, 2014
Fixes error with unperisted dynamic route in sonata FrontendLinkExtension
@dbu dbu merged commit 816585d into symfony-cmf:master Nov 20, 2014
@dbu
Copy link
Member

dbu commented Nov 20, 2014

i merged already as this fixes the bug. if you can add it to testing, that would be cool

The link is already being tested (/cmf/routing/route/create). Trying to get it tested somehow...

yes it is, you just need to adjust the config in Tests/Resources/app/config/... to make this extension being loaded into the admin (then the problem with namespace you now fixed would have been shown as test failure). when you do, you could add a check in the web test cases to check if the frontend link is actually there (except in the create case where the whole tab must be not there, which you could test as well just to be sure)

@frne
Copy link
Contributor Author

frne commented Nov 20, 2014

@dbu Is it possible that the WebTests are never executed? No <testsuite/> for those tests in phpunit.xml.dist...

I also don't know how to manage the whole db/phpcr test setup to get the WebTests running. Any tips?

1) Symfony\Cmf\Bundle\RoutingBundle\Tests\WebTest\RedirectRouteAdminTest::testRedirectRouteList
PHPCR\RepositoryException: Unexpected error talking to the backend: An exception occurred while 
executing 'SELECT 1 FROM phpcr_workspaces WHERE name = ?' with params ["default"]:

SQLSTATE[HY000]: General error: 1 no such table: phpcr_workspaces
...

Btw. Because of the bug, tag v1.3.1 is still broken. Do you plan to update the tag, or how do you guys manage broken tags?

@dantleech
Copy link
Member

It looks indeed like the webtests might not be running.

Try running:

$ vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh

Then try again, see the MenuBundle for an example of how the WebTests are executed.

@dbu
Copy link
Member

dbu commented Nov 21, 2014

we don't ever change a tag once its done. it can mess up some peoples system quite badly when a tag changes what git commit its referencing (e.g. when using satis to mirror packagist). i just created 1.3.2 now to have a release where the extension works.

@frne if you can try to activate the web tests the same way we run them on menu bundle, that would be great! if not, i will try to do that.

@frne
Copy link
Contributor Author

frne commented Nov 21, 2014

@dbu I'll activate the tests and expand them to test the sonata extension. Thx.

@frne frne mentioned this pull request Nov 21, 2014
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants