# Reset application loop/event manager during tests

**URL:** <https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976>\
**Category:** Components & MVC\
**Tags:** laminas-test\
**Created:** [July 26, 2022, 3:36pm UTC](https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976 "2022-07-26T15:36:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jurigag](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/jurigag/32/1345_2.png) [@Jurigag](https://discourse.laminas.dev/u/Jurigag)\
**Post date:** [July 26, 2022, 3:36pm UTC](https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976/1 "2022-07-26T15:36:00Z")

</div>

So we have currently end to end tests using real http client which are really slow. I wanted to switch them to use laminas/laminas-test but we test cases making many requests in one test, and it doesn’t seem to be working. If I do two requests to the same endpoint it doesn’t do anything, It just returns the same response and controller is never executed.

Is there a way to do that without init of new application?

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [July 27, 2022, 8:12am UTC](https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976/2 "2022-07-27T08:12:32Z")

</div>

Hello and welcome to our forums! 😃

> [@Jurigag](#):
>
> …we test cases making many requests in one test, and it doesn’t seem to be working.

_Many_ requests in on test seems like a lot to verify an assertion.

Check the `setUp` and the `tearDown` method and you will find `reset`. But you should recheck your tests because many requests in one test sounds wrong.

---

<div class="post-metadata">

**Author:** ![Jurigag](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/jurigag/32/1345_2.png) [@Jurigag](https://discourse.laminas.dev/u/Jurigag)\
**Post date:** [July 27, 2022, 8:48am UTC](https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976/3 "2022-07-27T08:48:20Z")

</div>

Hi there! I know there is reset method - but it resets the whole application just to null, this doesn’t seem to be solution - because each time the application will be bootstrapped again. I was wondering if there is some more optimized way to do it.

Well we have tons of tests like this already - legacy code so can’t really change them.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [August 2, 2022, 7:12am UTC](https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976/4 "2022-08-02T07:12:29Z")

</div>

> [@Jurigag](#):
>
> I was wondering if there is some more optimized way to do it.

No, this does not exist, as it does not correspond to the concept. Create your own `reset` method and check if it works without destroying the application. But this can lead to side effects!

> [@Jurigag](#):
>
> Well we have tons of tests like this already - legacy code so can’t really change them.

It’s not an argument, because if you don’t change it now, you’re just shifting the problem! 😜

---

<div class="post-metadata">

**Author:** ![Jurigag](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/jurigag/32/1345_2.png) [@Jurigag](https://discourse.laminas.dev/u/Jurigag)\
**Post date:** [August 2, 2022, 8:44am UTC](https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976/5 "2022-08-02T08:44:08Z")

</div>

Well it is argument because we have hunders if not thousands of those tests, so changing them will require a tremendous job to do that.

Also those tests are kind of end to end implemented that way - they check whole scenarios, so they need to really call some endpoint multiple times in one test case.

Yea I was trying to do that already - like create my own reset method but it wasn’t actually working correctly, controller was not executed. This is kind of sad because in all other frameworks it works without any issue.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [August 2, 2022, 9:20am UTC](https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976/6 "2022-08-02T09:20:52Z")

</div>

> [@Jurigag](#):
>
> This is kind of sad because in all other frameworks it works without any issue.

Please help to improve this! [Create an issue report](https://github.com/laminas/laminas-test/issues) or a [pull request](https://github.com/laminas/laminas-test/pulls) with your findings.

---

<div class="post-metadata">

**Author:** ![Jurigag](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/jurigag/32/1345_2.png) [@Jurigag](https://discourse.laminas.dev/u/Jurigag)\
**Post date:** [August 2, 2022, 3:23pm UTC](https://discourse.laminas.dev/t/reset-application-loop-event-manager-during-tests/2976/7 "2022-08-02T15:23:42Z")

</div>

But i don’t think this is actually a tests issue, most likely just Laminas\Mvc\Application issue.
