Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Yii1 module not path url format bug #182

Ragazzo opened this Issue Feb 22, 2013 · 12 comments


4 participants

Ragazzo commented Feb 22, 2013

Discussed on the yii en forum. @DavertMik need your opinion about situation when user run all tests and like in the topic below user has one module (Yii1) included in 2 suites, so is it correct that module _initialize called 2 times?


Ragazzo commented Feb 23, 2013

Tested on view url with view/id/5 works correct for me, but anyway need to solve problems with determining pathinfo and script url, to not use localhost.

radzserg commented Mar 1, 2013

So how things are going?

Also as for overriding CHttpRequest - actually it's quite bad idea. First of all everytime you have to update your config. On other hand you don't allow user override CHttpRequest by his class. For example I need to override it in my apps that are using JSON encoder requests. Default CHttpRequest don't do it automatically.

But the best thing that you can easily add you functionality of CodeceptionHttpRequest to default CHttpRequest by yii behaviors. Yii::app()->request->asa('CodeceptionHttpRequest'); This will solve all the problems listed below.


Ragazzo commented Mar 1, 2013

Actually i see no difference between adding behavior to the request or by changing request class in this way, so if user want he can replace extends CHttpRequest path in codeception, second problem is that some methods (redirect) is used often so if u will add behavior it will not affect this method (the main goal of the CodeceptionHttpRequest was to handle cookie and header() function) so i think behavior is not better solution here.
As for path url-format i've tested on fresh generated yii app as i've described above and it worked, so can u provide more info about what is not working in your code? And as for url problem for now i really have not so much time, so if u will ever have some free time it will be good if you provide a PR that solve this problem :)

radzserg commented Mar 1, 2013

ok I'll help. Will provide my updates soon

radzserg commented Mar 5, 2013

Here's my update https://www.dropbox.com/s/ta941ranyjf5zvh/yiiHelper.tar.gz?m
I made it as _helper. Please review and perhaps you'll use some of my ideas.

  • I check that yii module should be initialized only once
  • I made Yii::app()->request->asa(new \YiiHttpRequestBehavior()); for yii request component. But then I commented it. @Ragazzo where it's required? I used only cept format.

Unfortunately I don't have much time and there are a lot of unstable places still. For example yii do not catch exception but uses set_exception_handler. And if you need to check 404 error. $I->amOnPage('/notexistedpage'); yii will throw an exception. Bu its logic it should be handled by Yii::app()->handleException but instead of this this exception will be catche in Codeception.

So this module is still very unstable and need time to test it


Ragazzo commented Mar 5, 2013

Well i got brief look in your version, i think that when u recreate app only in before is wrong, because every new request to entry point doRequest method must create new api request(new application instance) as usual user do when working with app. Also i did not see where u use http-request Behavior (because behavior still will not save from header function call in users code). Can u also paste your code in your repo for easy review in future, will be handful?
As for exceptions yes, need to think about it, but if you include Yii1 module as last module in the list, yii will catch exceptions.

This was referenced Mar 7, 2013

nurcahyo commented May 5, 2013

i have setup my Yii1 project with codeception and follow the documentation for yii1 module step by step.
It running success when i use codeception.phar and use $I->amOnPage('r=site/login'). But on functional test when i config urlManager component the request always going to site/index controller i have change $I->amOnPage('/index.php/site/login'); it bring me to error too, then i use $I->amOnPage('/site/login') it always call the request to site/index.
And the other issue when i install codeception from Composer. I cant use Yii1 module, it always throw error on method $I->amOnPage();


Ragazzo commented May 5, 2013

Can you post error message? and what url did you specified in config suite? maybe also it is a good way yo use PhpBrowser for functional tests for you, to avoid this "pain" from Yii1 module. PhpBrowser is also very fast. Try it.

nurcahyo commented May 6, 2013

My configuration is here:

If I using PhpBrowser i cant coverage my controller, it always give me [ErrorException]
unserialize(): Error at offset 0 of 4127 bytes on coverage test

so i keep using Yii1 module and defined environment and if the envirnonment=='test' i am make my urlManager not using urlRule. But i think it is not a good way to make new enveronment testing and make condition on config, since Yii has Yii_DEBUG not used for test only but for development too.
So i hope there will be a fix for this issue.

When using codeception from Composer the error message was cant find amOnPage of zero


Ragazzo commented May 6, 2013

well, i think we need some more help from @DavertMik here, specially for composer issues, because i am not very familiar with it.


DavertMik commented May 7, 2013

Looks like it's code coverage error you are showing. Not sure how that related to Yii module and Gist.

I'd suggest you to debug deeply Yii1 module to see what happens when your URL comes to Yii framework and how the framework processes it. Maybe it changes it somehow or has some requirements.


DavertMik commented May 8, 2013

looks like usage of localhost is current limitation of this module.
maybe anyone can patch this. But probably that won't be me or @Ragazzo.

@DavertMik DavertMik closed this May 8, 2013

@DavertMik DavertMik added a commit that referenced this issue Oct 30, 2013

@DavertMik DavertMik Merge pull request #618 from kop/yii1_localhost_issue
Issue #182. Hardcoded 'localhost' removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment