Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where AfterScenarioListener does not fire #78

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,39 +1,11 @@
<?php
/**
* BehatMage
*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License, that is bundled with this
* package in the file LICENSE.
* It is also available through the world-wide-web at this URL:
*
* http://opensource.org/licenses/MIT
*
* If you did not receive a copy of the license and are unable to obtain it
* through the world-wide-web, please send an email
* to <magetest@sessiondigital.com> so we can send you a copy immediately.
*
* @category MageTest
* @package MagentoExtension
* @subpackage EventListener
*
* @copyright Copyright (c) 2012-2013 MageTest team and contributors.
*/

namespace MageTest\MagentoExtension\EventListener;

use MageTest\MagentoExtension\Fixture\FixtureFactory;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* AfterScenarioListener
*
* @category MageTest
* @package MagentoExtension
* @subpackage EventListener
*
* @author MageTest team (https://github.com/MageTest/BehatMage/contributors)
*/
class AfterScenarioListener
class AfterScenarioListener implements EventSubscriberInterface
{
private $factory;

Expand All @@ -42,8 +14,19 @@ public function __construct(FixtureFactory $factory)
$this->factory = $factory;
}

public static function getSubscribedEvents()
{
return array(
'afterScenario' => 'afterScenario'
);
}

/**
* clean factory in admin-scope
*/
public function afterScenario()
{
\Mage::app()->setCurrentStore(\Mage_Core_Model_App::ADMIN_STORE_ID);
$this->factory->clean();
}
}
6 changes: 5 additions & 1 deletion src/MageTest/MagentoExtension/services/core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parameter key="behat.magento.service.config_manager">MageTest\MagentoExtension\Service\ConfigManager</parameter>
<parameter key="behat.magento.service.config.core_config">MageTest\MagentoExtension\Service\Config\CoreConfig</parameter>
<parameter key="behat.magento.service.bootstrap">MageTest\MagentoExtension\Service\Bootstrap</parameter>
<parameter key="behat.magento.listener.before_scenario">MageTest\MagentoExtension\EventListener\BeforeScenarioListener</parameter>
<parameter key="behat.magento.listener.after_scenario">MageTest\MagentoExtension\EventListener\AfterScenarioListener</parameter>
<parameter key="behat.magento.context.initializer">MageTest\MagentoExtension\Context\Initializer\MagentoAwareInitializer</parameter>
<parameter key="behat.magento.fixture.fixture_factory">MageTest\MagentoExtension\Fixture\FixtureFactory</parameter>
<parameter key="behat.magento.fixture.address">MageTest\MagentoExtension\Fixture\Address</parameter>
Expand Down Expand Up @@ -38,6 +38,10 @@
<service id="behat.magento.service.session" class="%behat.magento.service.session%">
<argument type="service" id="behat.magento.service.bootstrap" />
</service>
<service id="behat.magento.listener.after_scenario" class="%behat.magento.listener.after_scenario%">
<argument type="service" id="behat.magento.fixture.fixture_factory" />
<tag name="behat.event_subscriber" priority="0" />
</service>
<service id="behat.magento.context.initializer" class="%behat.magento.context.initializer%">
<argument type="service" id="behat.magento.service.bootstrap" />
<argument type="service" id="behat.magento.service.cache_manager" />
Expand Down