Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Commit

Permalink
Fix error reporting for issues happining during setup process, lift p…
Browse files Browse the repository at this point in the history
…hpunit version to major one
  • Loading branch information
IvanChepurnyi committed Aug 12, 2015
1 parent 68bfe5b commit e0b3595
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions app/code/community/EcomDev/PHPUnit/Model/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,20 @@ public static function applyTestScope()
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_registry', array());

// All unit tests will be run in admin scope, to get rid of frontend restrictions
Mage::app()->initTest();
// Init modules runs install process for table structures,
// It is required for setting up proper setup script
try {
set_error_handler(function ($errorCode, $errorMessage) {
echo $errorMessage, $errorCode;
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
exit;
});
Mage::app()->initTest();
restore_error_handler();
} catch (Exception $e) {
echo $e->getMessage(), "\n", $e->getTraceAsString();

This comment has been minimized.

Copy link
@ozzyogkush

ozzyogkush Aug 12, 2015

the stack trace should be optional via a flag... the buffer can be huge and seeing an enormous stack trace isn't helpful when you can't even find the start of the message.

This comment has been minimized.

Copy link
@IvanChepurnyi

IvanChepurnyi Aug 12, 2015

Author Member

Do you mean exception trace or error message backtrace?

This comment has been minimized.

Copy link
@ozzyogkush

ozzyogkush Aug 12, 2015

I'm talking about the object that gets printed when an exception is thrown. sometimes the message is so huge that even when i output to a file (eg phpunit > logfile.log) my IDE refuses to open it. for example:

[vagrant@me vagrant]$ php tests/vendor/bin/phpunit
PHPUnit 4.8.3 by Sebastian Bergmann and contributors.
Warning:    Deprecated configuration setting "strict" used

<pre>Mage_Eav_Exception Object
(
    [_messages:protected] => Array
        (
        )

    [message:protected] => Wrong attribute set ID
    [string:Exception:private] => 
    [code:protected] => 0
    [file:protected] => /vagrant/app/Mage.php
    [line:protected] => 588
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => /vagrant/app/code/core/Mage/Eav/Model/Entity/Setup.php
                    [line] => 318
                    [function] => exception
                    [class] => Mage
                    [type] => ::
                    [args] => Array
                        (
                            [0] => Mage_Eav
                            [1] => Wrong attribute set ID
                        )

                )

            [1] => Array.......

It doesn't happen all the time, sometimes it's just a basic stack trace

This comment has been minimized.

Copy link
@IvanChepurnyi

IvanChepurnyi Aug 12, 2015

Author Member

Did it happen with the new update?
Because the current fix actually related to this issue, as standart PHPUnit just print_r() the exception object, so you get this issue.

This comment has been minimized.

Copy link
@ozzyogkush

ozzyogkush Aug 12, 2015

Yep, I saw that it was the new commit, and my composer file is running off of dev-dev. I ran composer update to grab the latest commit and it did update.

exit;
}
}

/**
Expand Down Expand Up @@ -383,7 +396,6 @@ public function getResponse()
protected function _getClassNameFromConfig($configPath, $interface = null)
{
$className = (string)$this->getConfig()->getNode($configPath);

$reflection = EcomDev_Utils_Reflection::getReflection($className);
if ($interface !== null && !$reflection->implementsInterface($interface)) {
throw new RuntimeException(
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"homepage": "http://www.ecomdev.org/shop/code-testing/php-unit-test-suite.html",
"require": {
"magento-hackathon/magento-composer-installer": "*",
"phpunit/phpunit": "4.1.*"
"phpunit/phpunit": "4.*"
},
"replace": {
"ivanchepurnyi/ecomdev_phpunit":"*"
Expand Down

0 comments on commit e0b3595

Please sign in to comment.