Open bitwombat opened 3 years ago
Specifically, these two lines guarantee at least two complete Applications
are going to be created...
And then this one gets called after my Cest's _before
and _initialize()
methods, guaranteeing I can't override any Laminas services.
This is probably what the persistentServices
functionality in the connector is for, but it ends up being difficult to grab the right Connector at the right time to make changes stick, since more than one Connector gets created per step (_before
in the Cest can get to the one that is actually in existence when the step gets called).
Just seems like too many Connectors, and way too many Applications getting created.
Comment in line 104 says grabServiceFromContainer may need client in beforeClass hooks of modules or helpers
so it may be useful for other people. This is similar to Symfony module, which instantiates Kernel in _initialize
method.
You may be right that this is not really useful, but it doesn't affect execution of tests. The instance of connector that matters for test is created in _before
hook and it can be modified in the test itself, _before
method of the class and in _before
methods of helper classes if the are executed after Laminas::_before (the order of modules in modules: enabled:
section of suite configuration file matters.
Hmmm... well if I'm the only one confused, that's fine. Just seems that with many Connectors and/or Applications around, it can be confusing that only a last-minute hook will work if changes are needed to the "real" Application that gets called by the test.
The reason this cost me hours is that I could get to a Connector (or Application) from higher-level hooks, so assumed that changing them was going to work. I had no idea that there'd be many Applications init'd.
Anyway, thanks for the answer and for the maintenance of this important module!
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:
Is this expected? The two before
_before()
seem unnecessary/unused.