I have been trying for days to get acceptance tests working but have been unsuccessful.
I think I have set everything up correctly, I have been over it many times.
I can start the phpbrowser but I am still getting the following error:
Can't be on page "/frontend/web/index-test.php/site/about":
yii\base\ErrorException: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given, called in /Applications/MAMP/htdocs/accserv/vendor/guzzlehttp/guzzle/src/Client.php on line 87 and defined
I just went over everything again for the … I don’t know, 10th time:
I ran composer update (yii version 2.0.7) then I followed the instructions in project_root/tests/README.md again.
I ran the Codeception installation again, I can run codecept globally, Codeception version is 2.0.16, my test database is set up, I ran the migration for it, I started the webserver from the project root since I am using the advanced template. I then run codeception build and codeception run:
All acceptance tests fail
Some functional tests pass and some fail
The unit tests error out:
Trying to test contact (tests\codeception\frontend\unit\models\ContactFormTest::testContact)... <pre>PHP Fatal Error 'yii\base\ErrorException' with message 'Maximum function nesting level of '100' reached, aborting!'
My strategy was to try to get into acceptance testing by starting with the most simple acceptance test, the about page and here I still am a couple days into it. If only I could debug this thing and trace the guzzle error or something. And again, I CAN get to the url that is supposed to be loaded with a browser, I am used to solving complex problems and debugging but I am groping in the dark here.
Admittedly this is not a brand new project but it is only a couple months old and there is nothing "special" configuration or anything.
Let me know if you need any other information. Also, thank you for taking the time to look into this.
I set up a new project, configured it and ran tests. They all passed. Then I compared new_project/tests to old_project/tests (I didn’t know until now you can compare all files in a directory structure in phpstorm until now, what a cool feature). Anyway, I compared ALL the files and there there many differences because of updates to classes, test files, etc. but nothing I accidentally broke.
I also compared composer.json files, they are almost identical, nothing that should interfere.
One interesting thing is when I run the tests on the project that works without the webserver on, I don’t get the same error as the project that does not work. I know the error message says it clearly but I think the next thing to do is check Guzzle.
It’s Guzzle for sure:
I am using a package that requires Guzzle. Removing it fixes the problem. I tried to look into how that could be; Apparently AcceptanceTester uses Guzzle to load php generated html for tests IF it’s available, and in turn, for whatever reason on my installation Guzzle is breaking it according to the error I posted above. I have not yet looked into it deeply but I think that is the gist of it.
I can verify that guzzlehttp/guzzle >=6.0.0 breaks the acceptance tests. guzzlehttp/guzzle <=5.3.0 works. I can’t believe no one has come across this before. Guzzle is VERY widely used. I am not sure where to report the problem or whose problem it is, I could investigate further but I can’t figure out how to step through the code when running codeception.
Any ideas or should I just try to submit a bug to yii2?
Yes, though now I think maybe I opened the ticket for the wrong thing. Like I mentioned in my last post, Codeception 2.1 has an "adapter" for guzzle 6 but Yii2 has some problems with Codeception 2.1. Not sure where to go from here but I think I am going to try Codeception 2.1 and see what happens.