Commit 696cec80 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

Merge branch 'release/v0.3.1'

parents 83c456bc 72657688
...@@ -49,15 +49,28 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -49,15 +49,28 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
{ {
if ($this->firstLevelTestSuite === null) { if ($this->firstLevelTestSuite === null) {
Mage::dispatchEvent('phpunit_suite_start_before', array(
'suite' => $suite,
'listener' => $this
));
// Apply app substitution for tests // Apply app substitution for tests
if ($this->getAppReflection()->hasMethod('applyTestScope')) { if ($this->getAppReflection()->hasMethod('applyTestScope')) {
$this->getAppReflection()->getMethod('applyTestScope')->invoke(null); $this->getAppReflection()->getMethod('applyTestScope')->invoke(null);
} }
$this->firstLevelTestSuite = $suite; $this->firstLevelTestSuite = $suite;
Mage::dispatchEvent('phpunit_suite_start_after', array(
'suite' => $suite,
'listener' => $this
));
} }
if (EcomDev_Utils_Reflection::getRestrictedPropertyValue($suite, 'testCase')) { if (EcomDev_Utils_Reflection::getRestrictedPropertyValue($suite, 'testCase')) {
Mage::dispatchEvent('phpunit_test_case_start_before', array(
'suite' => $suite,
'listener' => $this
));
EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName()) EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName())
->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED) ->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED)
->loadForClass($suite->getName()); ->loadForClass($suite->getName());
...@@ -69,6 +82,10 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -69,6 +82,10 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName()) EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName())
->setOptions($annotations['class']) ->setOptions($annotations['class'])
->apply(); ->apply();
Mage::dispatchEvent('phpunit_test_case_start_after', array(
'suite' => $suite,
'listener' => $this
));
} }
} }
...@@ -80,17 +97,33 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -80,17 +97,33 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{ {
if (EcomDev_Utils_Reflection::getRestrictedPropertyValue($suite, 'testCase')) { if (EcomDev_Utils_Reflection::getRestrictedPropertyValue($suite, 'testCase')) {
Mage::dispatchEvent('phpunit_test_case_end_before', array(
'suite' => $suite,
'listener' => $this
));
EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName()) EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName())
->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED) ->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED)
->discard(); ->discard();
Mage::dispatchEvent('phpunit_test_case_end_after', array(
'suite' => $suite,
'listener' => $this
));
} }
if ($this->firstLevelTestSuite === $suite) { if ($this->firstLevelTestSuite === $suite) {
Mage::dispatchEvent('phpunit_suite_end_before', array(
'suite' => $suite,
'listener' => $this
));
$this->firstLevelTestSuite = null; $this->firstLevelTestSuite = null;
// Discard test scope app // Discard test scope app
if ($this->getAppReflection()->hasMethod('discardTestScope')) { if ($this->getAppReflection()->hasMethod('discardTestScope')) {
$this->getAppReflection()->getMethod('discardTestScope')->invoke(null); $this->getAppReflection()->getMethod('discardTestScope')->invoke(null);
} }
Mage::dispatchEvent('phpunit_suite_end_after', array(
'suite' => $suite,
'listener' => $this
));
} }
} }
...@@ -101,6 +134,10 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -101,6 +134,10 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
*/ */
public function startTest(PHPUnit_Framework_Test $test) public function startTest(PHPUnit_Framework_Test $test)
{ {
Mage::dispatchEvent('phpunit_test_start_before', array(
'test' => $test,
'listener' => $this
));
if ($test instanceof PHPUnit_Framework_TestCase) { if ($test instanceof PHPUnit_Framework_TestCase) {
EcomDev_PHPUnit_Test_Case_Util::getFixture(get_class($test)) EcomDev_PHPUnit_Test_Case_Util::getFixture(get_class($test))
->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_LOCAL) ->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_LOCAL)
...@@ -112,6 +149,10 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -112,6 +149,10 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
EcomDev_PHPUnit_Test_Case_Util::setUp(); EcomDev_PHPUnit_Test_Case_Util::setUp();
} }
Mage::dispatchEvent('phpunit_test_start_after', array(
'test' => $test,
'listener' => $this
));
} }
/** /**
...@@ -122,6 +163,11 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -122,6 +163,11 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
*/ */
public function endTest(PHPUnit_Framework_Test $test, $time) public function endTest(PHPUnit_Framework_Test $test, $time)
{ {
Mage::dispatchEvent('phpunit_test_end_before', array(
'test' => $test,
'listener' => $this
));
if ($test instanceof PHPUnit_Framework_TestCase) { if ($test instanceof PHPUnit_Framework_TestCase) {
EcomDev_PHPUnit_Test_Case_Util::getFixture(get_class($test)) EcomDev_PHPUnit_Test_Case_Util::getFixture(get_class($test))
->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_LOCAL) ->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_LOCAL)
...@@ -133,6 +179,11 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -133,6 +179,11 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
EcomDev_PHPUnit_Test_Case_Util::tearDown(); EcomDev_PHPUnit_Test_Case_Util::tearDown();
} }
Mage::dispatchEvent('phpunit_test_end_after', array(
'test' => $test,
'listener' => $this
));
} }
/** /**
...@@ -144,6 +195,12 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -144,6 +195,12 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
*/ */
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
{ {
Mage::dispatchEvent('phpunit_test_error', array(
'test' => $test,
'exception' => $e,
'time' => $time,
'listener' => $this
));
// No action is required // No action is required
} }
...@@ -156,6 +213,12 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -156,6 +213,12 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
*/ */
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{ {
Mage::dispatchEvent('phpunit_test_failure', array(
'test' => $test,
'exception' => $e,
'time' => $time,
'listener' => $this
));
// No action is required // No action is required
} }
...@@ -168,6 +231,12 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -168,6 +231,12 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
*/ */
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{ {
Mage::dispatchEvent('phpunit_test_incomplete', array(
'test' => $test,
'exception' => $e,
'time' => $time,
'listener' => $this
));
// No action is required // No action is required
} }
...@@ -180,6 +249,12 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener ...@@ -180,6 +249,12 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
*/ */
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{ {
Mage::dispatchEvent('phpunit_test_skipped', array(
'test' => $test,
'exception' => $e,
'time' => $time,
'listener' => $this
));
// No action is required // No action is required
} }
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
"description": "Magento PHPUnit Integration", "description": "Magento PHPUnit Integration",
"homepage": "http://www.ecomdev.org/shop/code-testing/php-unit-test-suite.html", "homepage": "http://www.ecomdev.org/shop/code-testing/php-unit-test-suite.html",
"require": { "require": {
"magento-hackathon/magento-composer-installer": "dev-master", "magento-hackathon/magento-composer-installer": "*",
"phpunit/phpunit": "3.6.*" "phpunit/phpunit": "3.7.*"
}, },
"authors":[ "authors":[
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment