rmrevin / yii2-minify-view

Yii2 View component with minification css & js
MIT License
191 stars 67 forks source link

Wanted a way to exclude certain routes and default to normal behaivour #28

Closed synackSA closed 8 years ago

synackSA commented 8 years ago

Added a way to exclude certain routes so it could default to normal behaviour. Needed this due to the fact that wigget plugins with javacript wouldn't work like https://github.com/zxbodya/yii2-elfinder

rmrevin commented 8 years ago

@synackSA Need to do tests

synackSA commented 8 years ago

I can't really test this from the command line because you can't get the route

\Yii::$app->urlManager->parseRequest(\Yii::$app->request) generates the following error when executed from the command line:

1) rmrevin\yii\minify\tests\unit\view\ViewTest::testRouteExclude
yii\base\UnknownMethodException: Calling unknown method: yii\console\Request::getQueryParam()

The piece of code if (php_sapi_name() !== 'cli') makes sure that we don't check the routes when executed from the command line, so in turn, simply running the other tests and it not generating the above error, tests that line of code. I'm not sure how else to test the exclusion of routes on the command line (I have tested it via the web and it works).

rmrevin commented 8 years ago

You should create a mock object that will replace the request component. And configure the test application so that it used this mock object.

synackSA commented 8 years ago

I'm gonna close this pull request for now, I've found more issues that need to be sorted out, I'll add them to the issues list.