Acceptance test error

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 can even go to:


 http://localhost:8080/frontend/web/index-test.php/site/about 

in my web browser and it works, but I am still getting the abvoe error.

Does anyone have any idea what the problem could be?

Like I wrote here http://stackoverflow…cceptance-tests I can’t reproduce the issue.

Make sure that you are running the command php -S localhost:8080 from the root directory of your project.

I do get errors when I fire up the php webserver from the test directory.

You have installed the prerequisite Codeception packages?

Like specify and verify?

What is the version of Codeception that you are running?

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 think all I can do now is to download a new clean project, make is work then compare files. I don’t know what else to do at this point. I’ll let you know what happens.

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.

UPDATE:

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.

Wow - that is some great trouble-shooting there :)

Perhaps there should be filed a bug report somewhere…

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?

This is apparently solved in Codeception 2.1 which, according to some other posts in this forum, does not play well with Yii2. Around we go!

Looks like you have an open ticket for it :)

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.

Well, if you ticket does not fit, make it fit.

It is your ticket after all ;)

https://github.com/yiisoft/yii2-codeception/issues/21

You can rename it to match the actual problem.

I am now using Codeception 2.1.7 with latest Yii 2, and it seems to work OK.

Interesting, I will try it, thanks.