Can any one explain this?
Hardcoding the request URLs is a best practice for functional tests. If the test generates URLs using the Symfony router, it won't detect any change made to the application URLs which may impact the end users.
http://symfony.com/doc/current/book/testing.html#working-with-the-test-client
What sort of changes are they referring to? Why is this a problem if all url are generated using the router?
If a url changes, it affects bookmarks, links from other sites, page rank... If you test using a generated url, the test will succeed, even if you (accidentally) changed the url pattern.
By using hard-coded urls you can prevent this from happening. The test will fail if you accidentally change the url. If you meant to change it, you can just update the hardcoded url to match the new situation. This way you are in control.
For some applications, or some urls within a specific site or application, it might not matter at all if the url changes. In that case, you can generate the url of course. It's a general advice, not a law. :)
If URLs are not hard coded, the template code for generating a URL might look like:
{{ path('examplebundle_home_action') }}
Which the router will then expand to:
http://www.example.com/action
If your functional test refers to the path
call as above, suppose that you change the path for the action, so that the URL is now:
http://www.example.com/newaction
Since your tests refer to the path
call, they will continue to pass, since they seamlessly refer to the new URL. However, your users may disagree -- they may have bookmarked the old URL, or it may be referred to outside of Symfony elsewhere in your application, and so on. It is always dangerous to change a URL without fully understanding the impact, and having it hardcoded in a functional test is a good reminder that something significant has changed.