Run this relatively simple test
$user = $I->grabFixture('user', 'user1');
$I->amOnPage('ru/user/login');
$I->see('Авторизоваться', 'h2');
$I->wantTo('ensure that login is successful');
$I->submitForm('form#login-form', [
'login-form[login]' => $user->username,
'login-form[password]' => 'test',
]);
$I->seeElement('a.logout');
$I->seeElement('.page_user_name');
Red test with error in output file <pre>Not found: Страница не найдена. </pre>. In 2.4.0 it was green.
Interesting thing.
$I->amOnPage('ru/user/login');
This instruction executes successfully. But suddenly submitting on the same url says page not found. How this can be understandable?
composer show)class_name: FunctionalTester
modules:
enabled:
- Filesystem
- Yii2
- REST
- Asserts
config:
Yii2:
configFile: 'tests/codeception/_config/functional.php'
transaction: true
cleanup: false
REST:
depends: Yii2
Debug execution:
LoginCest: Ensure that login is successful
Signature: LoginCest:successLogin
Test: tests/codeception/functional/LoginCest.php:successLogin
Scenario --
Destroying application
Starting application
[Fixtures] Loading fixtures
[Fixtures] Done
I have fixtures {"user":"tests\\codeception\\unit\\fixtures\\UserFixture"}
I grab fixture "user","user1"
I am on page "ru/user/login"
[Request Headers] []
[yii\web\Session::open] 'Session started'
[Page] ru/user/login
[Response] 200
[Request Cookies] []
[Response Headers] {"content-type":["text/html; charset=UTF-8"]}
I see "Авторизоваться","h2"
I submit form "form#login-form",{"login-form[login]":"[email protected]","login-form[password]":"...}
[Uri] http://localhost/ru/user/login
[Method] POST
[Parameters] {"login-form[login]":"[email protected]","login-form[password]":"test"}
[Request Headers] []
[yii\web\HttpException:404] 'yii\\base\\InvalidRouteException: Unable to resolve the request "ru/user/login". in /app/vendor/yiisoft/yii2/base/Module.php:537
Stack trace:
#0 /app/vendor/yiisoft/yii2/web/Application.php(103): yii\\base\\Module->runAction(\'ru/user/login\', Array)
#1 /app/vendor/codeception/codeception/src/Codeception/Lib/Connector/Yii2.php(135): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))
#2 /app/vendor/symfony/browser-kit/Client.php(312): Codeception\\Lib\\Connector\\Yii2->doRequest(Object(Symfony\\Component\\BrowserKit\\Request))
#3 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(193): Symfony\\Component\\BrowserKit\\Client->request(\'POST\', \'http://localhos...\', Array, Array, Array, \'login-form%5Blo...\', true)
#4 /app/vendor/codeception/codeception/src/Codeception/Module/Yii2.php(670): Codeception\\Lib\\InnerBrowser->clientRequest(\'POST\', \'http://localhos...\', Array, Array, Array, \'login-form%5Blo...\', true)
#5 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(857): Codeception\\Module\\Yii2->clientRequest(\'POST\', \'http://localhos...\', Array, Array)
#6 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(868): Codeception\\Lib\\InnerBrowser->proceedSubmitForm(Object(Symfony\\Component\\DomCrawler\\Crawler), Array, NULL)
#7 [internal function]: Codeception\\Lib\\InnerBrowser->submitForm(\'form#login-form\', Array)
#8 /app/vendor/codeception/codeception/src/Codeception/Step.php(264): call_user_func_array(Array, Array)
#9 /app/vendor/codeception/codeception/src/Codeception/Scenario.php(72): Codeception\\Step->run(Object(Codeception\\Lib\\ModuleContainer))
#10 /app/tests/codeception/_support/_generated/FunctionalTesterActions.php(2133): Codeception\\Scenario->runStep(Object(Codeception\\Step\\Action))
#11 /app/tests/codeception/functional/LoginCest.php(26): FunctionalTester->submitForm(\'form#login-form\', Array)
#12 [internal function]: LoginCest->successLogin(Object(FunctionalTester))
#13 /app/vendor/codeception/codeception/src/Codeception/Lib/Di.php(127): ReflectionMethod->invokeArgs(Object(LoginCest), Array)
#14 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(138): Codeception\\Lib\\Di->injectDependencies(Object(LoginCest), \'successLogin\', Array)
#15 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(150): Codeception\\Test\\Cest->invoke(\'successLogin\', Array)
#16 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(82): Codeception\\Test\\Cest->executeTestMethod(Object(FunctionalTester))
#17 /app/vendor/codeception/codeception/src/Codeception/Test/Test.php(89): Codeception\\Test\\Cest->test()
#18 /app/vendor/phpunit/phpunit/src/Framework/TestSuite.php(760): Codeception\\Test\\Test->run(Object(PHPUnit\\Framework\\TestResult))
#19 /app/vendor/codeception/phpunit-wrapper/src/Runner.php(114): PHPUnit\\Framework\\TestSuite->run(Object(PHPUnit\\Framework\\TestResult))
#20 /app/vendor/codeception/codeception/src/Codeception/SuiteManager.php(157): Codeception\\PHPUnit\\Runner->doEnhancedRun(Object(Codeception\\Suite), Object(PHPUnit\\Framework\\TestResult), Array)
#21 /app/vendor/codeception/codeception/src/Codeception/Codecept.php(189): Codeception\\SuiteManager->run(Object(Codeception\\PHPUnit\\Runner), Object(PHPUnit\\Framework\\TestResult), Array)
#22 /app/vendor/codeception/codeception/src/Codeception/Codecept.php(158): Codeception\\Codecept->runSuite(Array, \'functional\', \'LoginCest\')
#23 /app/vendor/codeception/codeception/src/Codeception/Command/Run.php(355): Codeception\\Codecept->run(\'functional\', \'LoginCest\', Array)
#24 /app/vendor/symfony/console/Command/Command.php(252): Codeception\\Command\\Run->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /app/vendor/symfony/console/Application.php(865): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /app/vendor/symfony/console/Application.php(241): Symfony\\Component\\Console\\Application->doRunCommand(Object(Codeception\\Command\\Run), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 /app/vendor/symfony/console/Application.php(143): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#28 /app/vendor/codeception/codeception/src/Codeception/Application.php(108): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#29 /app/vendor/codeception/codeception/codecept(42): Codeception\\Application->run()
#30 {main}
Next yii\\web\\NotFoundHttpException: Страница не найдена. in /app/vendor/yiisoft/yii2/web/Application.php:115
Stack trace:
#0 /app/vendor/codeception/codeception/src/Codeception/Lib/Connector/Yii2.php(135): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))
#1 /app/vendor/symfony/browser-kit/Client.php(312): Codeception\\Lib\\Connector\\Yii2->doRequest(Object(Symfony\\Component\\BrowserKit\\Request))
#2 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(193): Symfony\\Component\\BrowserKit\\Client->request(\'POST\', \'http://localhos...\', Array, Array, Array, \'login-form%5Blo...\', true)
#3 /app/vendor/codeception/codeception/src/Codeception/Module/Yii2.php(670): Codeception\\Lib\\InnerBrowser->clientRequest(\'POST\', \'http://localhos...\', Array, Array, Array, \'login-form%5Blo...\', true)
#4 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(857): Codeception\\Module\\Yii2->clientRequest(\'POST\', \'http://localhos...\', Array, Array)
#5 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(868): Codeception\\Lib\\InnerBrowser->proceedSubmitForm(Object(Symfony\\Component\\DomCrawler\\Crawler), Array, NULL)
#6 [internal function]: Codeception\\Lib\\InnerBrowser->submitForm(\'form#login-form\', Array)
#7 /app/vendor/codeception/codeception/src/Codeception/Step.php(264): call_user_func_array(Array, Array)
#8 /app/vendor/codeception/codeception/src/Codeception/Scenario.php(72): Codeception\\Step->run(Object(Codeception\\Lib\\ModuleContainer))
#9 /app/tests/codeception/_support/_generated/FunctionalTesterActions.php(2133): Codeception\\Scenario->runStep(Object(Codeception\\Step\\Action))
#10 /app/tests/codeception/functional/LoginCest.php(26): FunctionalTester->submitForm(\'form#login-form\', Array)
#11 [internal function]: LoginCest->successLogin(Object(FunctionalTester))
#12 /app/vendor/codeception/codeception/src/Codeception/Lib/Di.php(127): ReflectionMethod->invokeArgs(Object(LoginCest), Array)
#13 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(138): Codeception\\Lib\\Di->injectDependencies(Object(LoginCest), \'successLogin\', Array)
#14 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(150): Codeception\\Test\\Cest->invoke(\'successLogin\', Array)
#15 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(82): Codeception\\Test\\Cest->executeTestMethod(Object(FunctionalTester))
#16 /app/vendor/codeception/codeception/src/Codeception/Test/Test.php(89): Codeception\\Test\\Cest->test()
#17 /app/vendor/phpunit/phpunit/src/Framework/TestSuite.php(760): Codeception\\Test\\Test->run(Object(PHPUnit\\Framework\\TestResult))
#18 /app/vendor/codeception/phpunit-wrapper/src/Runner.php(114): PHPUnit\\Framework\\TestSuite->run(Object(PHPUnit\\Framework\\TestResult))
#19 /app/vendor/codeception/codeception/src/Codeception/SuiteManager.php(157): Codeception\\PHPUnit\\Runner->doEnhancedRun(Object(Codeception\\Suite), Object(PHPUnit\\Framework\\TestResult), Array)
#20 /app/vendor/codeception/codeception/src/Codeception/Codecept.php(189): Codeception\\SuiteManager->run(Object(Codeception\\PHPUnit\\Runner), Object(PHPUnit\\Framework\\TestResult), Array)
#21 /app/vendor/codeception/codeception/src/Codeception/Codecept.php(158): Codeception\\Codecept->runSuite(Array, \'functional\', \'LoginCest\')
#22 /app/vendor/codeception/codeception/src/Codeception/Command/Run.php(355): Codeception\\Codecept->run(\'functional\', \'LoginCest\', Array)
#23 /app/vendor/symfony/console/Command/Command.php(252): Codeception\\Command\\Run->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /app/vendor/symfony/console/Application.php(865): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /app/vendor/symfony/console/Application.php(241): Symfony\\Component\\Console\\Application->doRunCommand(Object(Codeception\\Command\\Run), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /app/vendor/symfony/console/Application.php(143): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 /app/vendor/codeception/codeception/src/Codeception/Application.php(108): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#28 /app/vendor/codeception/codeception/codecept(42): Codeception\\Application->run()
#29 {main}'
[Page] http://localhost/ru/user/login
[Response] 404
[Request Cookies] {"_language":"9457c7cc6ba7cdebe752c3e019d54725c71b7b993a2dda03ec553019f8711243a:2:{i:0;s:9:"_language";i:1;s:2:"ru";}"}
[Response Headers] {"content-type":["text/html; charset=UTF-8"]}
I see element "a.logout"
FAIL
Destroying application
Suite done, restoring $_SERVER to original
----------------------------------------------------------------------------------------------------------------
Time: 12.54 seconds, Memory: 10.00MB
There was 1 failure:
---------
1) LoginCest: Ensure that login is successful
Test tests/codeception/functional/LoginCest.php:successLogin
Step See element "a.logout"
Fail Element located either by name, CSS or XPath element with 'a.logout' was not found.
Scenario Steps:
6. $I->seeElement("a.logout") at tests/codeception/functional/LoginCest.php:28
5. $I->submitForm("form#login-form",{"login-form[login]":"[email protected]","login-form[password]":...}) at tests/codeception/functional/LoginCest.php:26
4. $I->see("Авторизоваться","h2") at tests/codeception/functional/LoginCest.php:20
3. $I->amOnPage("ru/user/login") at tests/codeception/functional/LoginCest.php:19
2. $I->grabFixture("user","user1") at tests/codeception/functional/LoginCest.php:18
1. $I->haveFixtures({"user":"tests\\codeception\\unit\\fixtures\\UserFixture"}) at tests/codeception/functional/LoginCest.php:10
FAILURES!
Tests: 1, Assertions: 2, Failures: 1.
I'll look into it.
@samdark This issue is fixed by the open PR #4918.
Issue was caused by the Module not configuring a strategy for cleaning the request object.
Yes. Still waiting for tests there...
At least 5.6 has succeeded already, so that's a good sign.
@StalkAlex would you be up for adding a test case here? https://github.com/Codeception/yii2-tests
The idea is that you create new minimal Yii2 app (if your app requires specific configuration), or add a test case to one of the existing ones.
I've been reworking the Yii2 Module, unfortunately introducing some breaks, but the goal is to have the module properly tested, which is now possible.
By adding a test we can guarantee that it won't happen again in the future!
I can help, but still haven't understood problem root to be able to create minimal reproducible repo/case.
@samdark it means it won't be fixed? or what?
P.S. ok, I see PR is merged.
@SamMousa @samdark nope, just tried 2.4.x-dev branch, there is the same error!
Hmm, then i didn't reproduce it correctly i guess
@StalkAlex can you try changing amOnPage('abc') to amOnPage(['abc']) ?
I think this could be it.
Or this just happens because in my test I didn't have pretty URLs enabled....
@SamMousa Nope, still error.
It seems Yii for some reason is not getting the route correctly for POST requests to that URL.
Can you share your url manager configuration?
--> if your code is open source you can direct me to it as well so i can reproduce it myself
Unfortunetaly, it's private project.
I'm using this lib.
Config:
'urlManager' => [
'class' => UrlManager::class,
'enablePrettyUrl' => true,
'showScriptName' => getenv('YII_ENV_TEST') ? true : false,
'enableDefaultLanguageUrlCode' => true,
'baseUrl' => '/', // for console version just ''
'hostInfo' => getenv('APP_BASE_URL'),
'ignoreLanguageUrlPatterns' => [
//some patterns
],
'rules' => [
'docs/<file:[a-zA-Z0-9_\-\./]+>' => 'docs',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<module:[\wd-]+>/<controller:[\wd-]+>/<action:[\wd-]+>/<id:\d+>' => '<module>/<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
'languages' => 'en,ru,kz',
],
Can you try changing showScriptName to false?
I'll try the whole config and that lib later today.
showScriptError => false is the same result.
It seems Yii for some reason is not getting the route correctly for POST requests to that URL.
I debugged a bit, there is a difference in path info. For GET request it equals to user/login and then Yii correctly maps url, but for POST it came as ru/user/login/, but there is no such url pattern as ru not a module, it should be resolved by lib mentioned above.
Okay, I found the issue, but it seems to be related to that library.
What happens is that the component changes its state internally; it sets a processed flag here.
This means that on the second request no processing happens which causes your error.
Still looking into where / how to best fix it.
Okay, so the old module did some pretty unpredictable stuff:
Yii::$app intact.Yii::$app (or components in the app) were lost.After the rework there is a more consistent state, but this causes breakage for components that keep state but don't reset it at the end of the request. The new state is detailed in the source code here.
For now a workaround is to add this before the request Yii::$app->setComponent('urlManager', Yii::$app->getComponents()['urlManager']).
This manually removes the urlManager component and Yii will automatically re-instantiate it when needed.
Alternatively you could add an event handler that does this application wide:
```
'on beforeRequest' => function() {
if (Yii::$app->has('urlManager', true)) {
// Note that this sets a protected
Yii::$app->get('urlManager')->_processed = true;
}
````
In my opinion most components inside an application should not have state related to a request, but we could add a configuration to support components that do.
I'm thinking something like
cleanComponents where you can specify a list of components that will be reset before every request.
The issue of resetting them always is that altering a components options from within a test won't work, which is why it is (in my opinion) bad behavior.
@samdark @StalkAlex what are your opinions?
Thanks for such detailed info! I totally agree with your rework solution especially in part of Yii::$app persistence, but from the other side there would be more extensions that make one request per instance assumption. And it's more or less correct too:
In practical scenarios parseRequest() should only every be called once during a request lifecycle, as per the nature of of web apps, there's always only one request involved
I see open issue with your suggestions in Localeurls extensions, maybe author will change his position, issue is still open. But nevertheless the idea to make option to specify components to be cleaned sounds to me the best solution currently. Make this more configurable from the Codeception side.
@StalkAlex #4924
Trying your code, error has changed but it's still error. This is time error on the first request, it can't find user/login.
LoginCest: Ensure that login is successful
Signature: LoginCest:successLogin
Test: tests/codeception/functional/LoginCest.php:successLogin
Scenario --
Destroying application
Starting application
[Fixtures] Loading fixtures
[Fixtures] Done
Transaction
I have fixtures {"user":"tests\\codeception\\unit\\fixtures\\UserFixture"}
I grab fixture "user","***"
I am on page "ru/user/login"
[Request Headers] []
[yii\web\Session::open] 'Session started'
[yii\web\HttpException:404] 'yii\\base\\InvalidRouteException: Unable to resolve the request "user/login". in /app/vendor/yiisoft/yii2/base/Module.php:537
Stack trace:
#0 /app/vendor/yiisoft/yii2/web/Application.php(103): yii\\base\\Module->runAction(\'user/login\', Array)
#1 /app/vendor/codeception/codeception/src/Codeception/Lib/Connector/Yii2.php(180): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))
#2 /app/vendor/symfony/browser-kit/Client.php(312): Codeception\\Lib\\Connector\\Yii2->doRequest(Object(Symfony\\Component\\BrowserKit\\Request))
#3 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(193): Symfony\\Component\\BrowserKit\\Client->request(\'GET\', \'http://localhos...\', Array, Array, Array, NULL, true)
#4 /app/vendor/codeception/codeception/src/Codeception/Module/Yii2.php(713): Codeception\\Lib\\InnerBrowser->clientRequest(\'GET\', \'ru/user/login\', Array, Array, Array, NULL, true)
#5 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(241): Codeception\\Module\\Yii2->clientRequest(\'GET\', \'ru/user/login\', Array, Array, Array, NULL)
#6 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(345): Codeception\\Lib\\InnerBrowser->_loadPage(\'GET\', \'ru/user/login\')
#7 [internal function]: Codeception\\Lib\\InnerBrowser->amOnPage(\'ru/user/login\')
#8 /app/vendor/codeception/codeception/src/Codeception/Step.php(264): call_user_func_array(Array, Array)
#9 /app/vendor/codeception/codeception/src/Codeception/Scenario.php(72): Codeception\\Step->run(Object(Codeception\\Lib\\ModuleContainer))
#10 /app/tests/codeception/_support/_generated/FunctionalTesterActions.php(929): Codeception\\Scenario->runStep(Object(Codeception\\Step\\Condition))
#11 /app/tests/codeception/functional/LoginCest.php(19): FunctionalTester->amOnPage(\'ru/user/login\')
#12 [internal function]: LoginCest->successLogin(Object(FunctionalTester))
#13 /app/vendor/codeception/codeception/src/Codeception/Lib/Di.php(127): ReflectionMethod->invokeArgs(Object(LoginCest), Array)
#14 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(138): Codeception\\Lib\\Di->injectDependencies(Object(LoginCest), \'successLogin\', Array)
#15 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(150): Codeception\\Test\\Cest->invoke(\'successLogin\', Array)
#16 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(82): Codeception\\Test\\Cest->executeTestMethod(Object(FunctionalTester))
#17 /app/vendor/codeception/codeception/src/Codeception/Test/Test.php(89): Codeception\\Test\\Cest->test()
#18 /app/vendor/phpunit/phpunit/src/Framework/TestSuite.php(760): Codeception\\Test\\Test->run(Object(PHPUnit\\Framework\\TestResult))
#19 /app/vendor/codeception/phpunit-wrapper/src/Runner.php(114): PHPUnit\\Framework\\TestSuite->run(Object(PHPUnit\\Framework\\TestResult))
#20 /app/vendor/codeception/codeception/src/Codeception/SuiteManager.php(157): Codeception\\PHPUnit\\Runner->doEnhancedRun(Object(Codeception\\Suite), Object(PHPUnit\\Framework\\TestResult), Array)
#21 /app/vendor/codeception/codeception/src/Codeception/Codecept.php(189): Codeception\\SuiteManager->run(Object(Codeception\\PHPUnit\\Runner), Object(PHPUnit\\Framework\\TestResult), Array)
#22 /app/vendor/codeception/codeception/src/Codeception/Codecept.php(158): Codeception\\Codecept->runSuite(Array, \'functional\', \'LoginCest\')
#23 /app/vendor/codeception/codeception/src/Codeception/Command/Run.php(355): Codeception\\Codecept->run(\'functional\', \'LoginCest\', Array)
#24 /app/vendor/symfony/console/Command/Command.php(252): Codeception\\Command\\Run->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /app/vendor/symfony/console/Application.php(865): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /app/vendor/symfony/console/Application.php(241): Symfony\\Component\\Console\\Application->doRunCommand(Object(Codeception\\Command\\Run), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 /app/vendor/symfony/console/Application.php(143): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#28 /app/vendor/codeception/codeception/src/Codeception/Application.php(108): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#29 /app/vendor/codeception/codeception/codecept(42): Codeception\\Application->run()
#30 {main}
Next yii\\web\\NotFoundHttpException: Страница не найдена. in /app/vendor/yiisoft/yii2/web/Application.php:115
Stack trace:
#0 /app/vendor/codeception/codeception/src/Codeception/Lib/Connector/Yii2.php(180): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))
#1 /app/vendor/symfony/browser-kit/Client.php(312): Codeception\\Lib\\Connector\\Yii2->doRequest(Object(Symfony\\Component\\BrowserKit\\Request))
#2 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(193): Symfony\\Component\\BrowserKit\\Client->request(\'GET\', \'http://localhos...\', Array, Array, Array, NULL, true)
#3 /app/vendor/codeception/codeception/src/Codeception/Module/Yii2.php(713): Codeception\\Lib\\InnerBrowser->clientRequest(\'GET\', \'ru/user/login\', Array, Array, Array, NULL, true)
#4 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(241): Codeception\\Module\\Yii2->clientRequest(\'GET\', \'ru/user/login\', Array, Array, Array, NULL)
#5 /app/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php(345): Codeception\\Lib\\InnerBrowser->_loadPage(\'GET\', \'ru/user/login\')
#6 [internal function]: Codeception\\Lib\\InnerBrowser->amOnPage(\'ru/user/login\')
#7 /app/vendor/codeception/codeception/src/Codeception/Step.php(264): call_user_func_array(Array, Array)
#8 /app/vendor/codeception/codeception/src/Codeception/Scenario.php(72): Codeception\\Step->run(Object(Codeception\\Lib\\ModuleContainer))
#9 /app/tests/codeception/_support/_generated/FunctionalTesterActions.php(929): Codeception\\Scenario->runStep(Object(Codeception\\Step\\Condition))
#10 /app/tests/codeception/functional/LoginCest.php(19): FunctionalTester->amOnPage(\'ru/user/login\')
#11 [internal function]: LoginCest->successLogin(Object(FunctionalTester))
#12 /app/vendor/codeception/codeception/src/Codeception/Lib/Di.php(127): ReflectionMethod->invokeArgs(Object(LoginCest), Array)
#13 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(138): Codeception\\Lib\\Di->injectDependencies(Object(LoginCest), \'successLogin\', Array)
#14 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(150): Codeception\\Test\\Cest->invoke(\'successLogin\', Array)
#15 /app/vendor/codeception/codeception/src/Codeception/Test/Cest.php(82): Codeception\\Test\\Cest->executeTestMethod(Object(FunctionalTester))
#16 /app/vendor/codeception/codeception/src/Codeception/Test/Test.php(89): Codeception\\Test\\Cest->test()
#17 /app/vendor/phpunit/phpunit/src/Framework/TestSuite.php(760): Codeception\\Test\\Test->run(Object(PHPUnit\\Framework\\TestResult))
#18 /app/vendor/codeception/phpunit-wrapper/src/Runner.php(114): PHPUnit\\Framework\\TestSuite->run(Object(PHPUnit\\Framework\\TestResult))
#19 /app/vendor/codeception/codeception/src/Codeception/SuiteManager.php(157): Codeception\\PHPUnit\\Runner->doEnhancedRun(Object(Codeception\\Suite), Object(PHPUnit\\Framework\\TestResult), Array)
#20 /app/vendor/codeception/codeception/src/Codeception/Codecept.php(189): Codeception\\SuiteManager->run(Object(Codeception\\PHPUnit\\Runner), Object(PHPUnit\\Framework\\TestResult), Array)
#21 /app/vendor/codeception/codeception/src/Codeception/Codecept.php(158): Codeception\\Codecept->runSuite(Array, \'functional\', \'LoginCest\')
#22 /app/vendor/codeception/codeception/src/Codeception/Command/Run.php(355): Codeception\\Codecept->run(\'functional\', \'LoginCest\', Array)
#23 /app/vendor/symfony/console/Command/Command.php(252): Codeception\\Command\\Run->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /app/vendor/symfony/console/Application.php(865): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /app/vendor/symfony/console/Application.php(241): Symfony\\Component\\Console\\Application->doRunCommand(Object(Codeception\\Command\\Run), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /app/vendor/symfony/console/Application.php(143): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 /app/vendor/codeception/codeception/src/Codeception/Application.php(108): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#28 /app/vendor/codeception/codeception/codecept(42): Codeception\\Application->run()
#29 {main}'
[Page] ru/user/login
[Response] 404
[Request Cookies] []
[Response Headers] {"content-type":["text/html; charset=UTF-8"]}
I see "Авторизоваться","h2"
FAIL
[Transaction] Rolling back 0 transactions
Destroying application
Suite done, restoring $_SERVER to original
----------------------------------------------------------------------------------------------------------------
Time: 13.81 seconds, Memory: 8.00MB
There was 1 failure:
Did you configure the url manager in recreateComponents in the module configuration?
Yii2:
configFile: 'tests/codeception/_config/functional.php'
transaction: true
cleanup: false,
recreateComponents: ['urlManager']
Weird; I've reproduced your original error in this test case:
https://github.com/Codeception/yii2-tests/blob/master/cases/locale-urls/functional/LocaleUrlCest.php#L29
(Locally it uses the recreateComponents feature) and I can't reproduce your current error...
Commenting those lines restores situation as before. First request is ok, second is faulty.
// foreach($this->recreateComponents as $component) {
// $application->set($component, $definitions[$component]);
// }
Are you on Slack?
Yes I'm using it sometimes, not on everyday basis. Where can I find you?
I'm on the Yii slack, same name.
Issue is fixed, but there another problem showed up after Yii2 module update. https://github.com/Codeception/Codeception/issues/4926
Most helpful comment
Okay, I found the issue, but it seems to be related to that library.
What happens is that the component changes its state internally; it sets a
processedflag here.This means that on the second request no processing happens which causes your error.
Still looking into where / how to best fix it.