Codeception / Codeception/module-laminas

Laminas->createApplication() called too many times

Open
#8 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1
Forks
7
PR merge metrics
No merged PRs in 30d

Description

I'm trying to override the ServiceManager in my functional tests. I understand this needs to be done in `_beforeStep()` (true?)

But in watching Codeception and the Laminas module work, I was surprised at how many times `Laminas->createApplication()` is called.

I would expect one fresh application per simulated HTTP request (e.g. `->see()` or `->click()`), but there are more than that:

Trimmed stack traces:

```
Laminas.php:182, Codeception\Lib\Connector\Laminas->createApplication() <----- HERE
Laminas.php:106, Codeception\Module\Laminas->_initialize()
SuiteManager.php:83, Codeception\SuiteManager->initialize() <----- BECAUSE OF THIS EVENT/STEP
Codecept.php:204, Codeception\Codecept->runSuite()

_beforeSuite() is called

Laminas.php:182, Codeception\Lib\Connector\Laminas->createApplication() <----- HERE
Laminas.php:34, Codeception\Lib\Connector\Laminas->setApplicationConfig()
Laminas.php:112, Codeception\Module\Laminas->_before()
Module.php:56, Codeception\Subscriber\Module->before() <----- BECAUSE OF THIS EVENT/STEP
EventDispatcher.php:230, Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
EventDispatcher.php:59, Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
DispatcherWrapper.php:22, Codeception\PHPUnit\Listener->dispatch()
Listener.php:134, Codeception\PHPUnit\Listener->fire()
Listener.php:103, Codeception\PHPUnit\Listener->startTest()
TestResult.php:434, PHPUnit\Framework\TestResult->startTest()
Test.php:80, Codeception\Test\Cest->run()
TestSuite.php:677, Codeception\Suite->run()
Runner.php:117, Codeception\PHPUnit\Runner->doEnhancedRun()
SuiteManager.php:161, Codeception\SuiteManager->run()
Codecept.php:208, Codeception\Codecept->runSuite()
Codecept.php:162, Codeception\Codecept->run()

MyCest->_before() is called

Laminas.php:182, Codeception\Lib\Connector\Laminas->createApplication() <----- HERE
Laminas.php:46, Codeception\Lib\Connector\Laminas->doRequest()
AbstractBrowser.php:384, Codeception\Lib\Connector\Laminas->request()
InnerBrowser.php:233, Codeception\Module\Laminas->clientRequest()
InnerBrowser.php:281, Codeception\Module\Laminas->_loadPage()
InnerBrowser.php:393, Codeception\Module\Laminas->amOnPage() <----- BECAUSE OF THIS EVENT/STEP

Laminas.php:182, Codeception\Lib\Connector\Laminas->createApplication() <----- HERE
Laminas.php:46, Codeception\Lib\Connector\Laminas->doRequest()
AbstractBrowser.php:384, Codeception\Lib\Connector\Laminas->request()
InnerBrowser.php:233, Codeception\Module\Laminas->clientRequest()
InnerBrowser.php:936, Codeception\Module\Laminas->proceedSubmitForm()
InnerBrowser.php:492, Codeception\Module\Laminas->clickButton()
InnerBrowser.php:451, Codeception\Module\Laminas->clickByLocator()
InnerBrowser.php:424, Codeception\Module\Laminas->click() <----- BECAUSE OF THIS EVENT/STEP
```

Is this expected? The two before `_before()` seem unnecessary/unused.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Codeception\Lib\Connector\Laminas::createApplication() and trace its callers in Laminas.php, especially setApplicationConfig(), doRequest(), and the module’s _initialize() and _before() paths. Compare these calls with SuiteManager initialization and request steps to determine whether the extra application creation is expected; done means the lifecycle is clarified and any unnecessary calls are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.