EcomDev / EcomDev_UrlRewrite

Alternative implementation of Url Rewrite Index by EcomDev
72 stars 33 forks source link

Multiple dispatches in one test run: Events not properly isloated #11

Closed amenk closed 11 years ago

amenk commented 11 years ago

I have a module that registers a frontend event "controller_action_predispatch_wishlist_index_send"

Steps to reproduce:

  1. $this->dispatch('/);
  2. $this->dispatch('wishlist/index/send');
  3. Event controller_action_predispatch_wishlist_index_send is not fired

If I directly dispatch the "right" action, i.e. the action that fires the event, it will be fired:

Steps to reproduce:

  1. $this->dispatch('wishlist/index/send');
  2. Event controller_action_predispatch_wishlist_index_send is fired

I debugged this a little and there seems to be some kind of caching problem. After the first dispatch, the event cache is already initialized. Now during the second call, events that have not fired before, are just ignored.

This happens if I have the dispatches in 1. and 2. in different tests as well as in the same test.

amenk commented 11 years ago

Correction:

amenk commented 11 years ago

I made a small test module to reproduce this: https://github.com/amenk/N98_EcomDevPHPUnitIssue

Running both tests

phpunit.phar --debug --filter N98_EcomDevPHPUnitIssue_Test_Controller_TestController PHPUnit 3.7.13 by Sebastian Bergmann.

Configuration read from tests/integration/phpunit.xml

Starting test 'N98_EcomDevPHPUnitIssue_Test_Controller_TestController::aAction'. . Starting test 'N98_EcomDevPHPUnitIssue_Test_Controller_TestController::bAction'. F

Time: 5 seconds, Memory: 55.50Mb

There was 1 failure:

1) N98_EcomDevPHPUnitIssue_Test_Controller_TestController::bAction event was not really fired Failed asserting that null is true.

app/code/local/N98/EcomDevPHPUnitIssue/Test/Controller/TestController.php:30 phpunit.phar:524

FAILURES! Tests: 2, Assertions: 4, Failures: 1.

Running only bAction

phpunit.phar --debug --filter N98_EcomDevPHPUnitIssue_Test_Controller_TestController::bAction PHPUnit 3.7.13 by Sebastian Bergmann.

Configuration read from tests/integration/phpunit.xml

Starting test 'N98_EcomDevPHPUnitIssue_Test_Controller_TestController::bAction'. .

Time: 4 seconds, Memory: 36.50Mb

OK (1 test, 4 assertions)

amenk commented 11 years ago

I created the issue in the wrong project - shame on my. Here is the right one: https://github.com/IvanChepurnyi/EcomDev_PHPUnit/issues/85