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

Component Routing 2.6 composer package is missing a dependency #12828

Closed
sk-sparhandy opened this issue Dec 3, 2014 · 6 comments
Closed

Component Routing 2.6 composer package is missing a dependency #12828

sk-sparhandy opened this issue Dec 3, 2014 · 6 comments
Labels

Comments

@sk-sparhandy
Copy link

It seams to me that at least one Class of the Routing Component 2.6 has a hard dependency on the ExpressionLanguage Component.

Symfony\Component\Routing\Matcher\UrlMatcher requires the presence of Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface (line 21 and 119)

The Packagist package definition of Routing Component does not contain this aspect. (Only in "Requires (Dev)" but that is not enough!)

@xabbuh
Copy link
Member

xabbuh commented Dec 3, 2014

@sk-sparhandy Did you experience any real issues (errors, etc.)? Because as far as I can see, there's no hard dependency on the ExpressionLanguage component if you don't make use of this optional feature.

@sk-sparhandy
Copy link
Author

@xabbuh Install the Routing Component by composer and instantiate a mock object with the getMock Method of PHPUnit 3.7.

$mockedUrlMatcher = $this->getMock(
    'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', array(), array(), '', false
);

will result in

Declaration of Mock_UrlMatcher_9e416bac::addExpressionLanguageProvider() should be compatible 
with Symfony\Component\Routing\Matcher\UrlMatcher::addExpressionLanguageProvider
(Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface $provider)

which leads to a failed UnitTest.

@xabbuh
Copy link
Member

xabbuh commented Dec 3, 2014

@sk-sparhandy You can workaround this by explicitly passing the methods to mock (see #12088 or FriendsOfSymfony/FOSRestBundle#914 for examples how to do that). This may not be ideal, but I don't think it's something to fix in the Routing component.

@sk-sparhandy
Copy link
Author

If you do not want to change the implementation would you consider adding ExpressionLanguage Component as a dependency as long as the not ideal situation remains?

The current implementation strikes me as very unusual requiring extra effort to handle the class. I would be more then willing to offer a pull request dealing with this issue as you see fit.

@fabpot fabpot added the Routing label Dec 7, 2014
@fabpot
Copy link
Member

fabpot commented Dec 24, 2014

ExpressionLanguage is as a soft dependency as the component can work without it, that's why we did not add it as a requirement. The UrlMatcher class works (when using it) without the dependency; it's true that when mocking it, you might have a problem if not doing what @xabbuh suggests.

@fabpot fabpot closed this as completed Dec 24, 2014
@stof
Copy link
Member

stof commented Jan 18, 2015

Note that only PHPUnit_MockObject requires the ExpressionLanguage to be there to mock the class. Both Prophecy and Mockery are handling this better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants