dancryer / PHPCI

PHPCI is a free and open source continuous integration tool specifically designed for PHP.
BSD 2-Clause "Simplified" License
2.42k stars 441 forks source link

Strange behaviour, due to PHP Notice: Undefined index: default in [...] SuiteManager.php, on line 130 #1285

Closed aedart closed 7 years ago

aedart commented 7 years ago

I'm in the process of writing a few tests for an asynchronous session package. However, sometimes my test fail, yet it isn't due to my code... Well, at least not as far as I can see?

Expected behaviour

No test to fail because of test-framework

Actual behaviour

Tests do not execute as expected, when no default group detail is available inside SuiteManager. No feedback is given, yet it appears that this affects some PHP components.

Steps to reproduce

I have no clue why the "group" details are not available in the first place or when they should be. Thus, no idea how to reproduce ... But, I finally found the defect by adding a shutdown handler;

    protected function _before()
    {
        parent::_before();

        // Register shutdown handler...
        register_shutdown_function(function(){

            $lastError = error_get_last();
            if(!is_null($lastError)){
                die('Shutdown error ' .  PHP_EOL . $lastError)
            }
        });
    }

Possible Solution

Ensure that default group details are only set, if available, e.g.

(Inside SuiteManager.php, addToSuite method)

        // registering group for data providers
        if (!empty($groups) && $test instanceof \PHPUnit_Framework_TestSuite_DataProvider) {
            $groupDetails = [];
            foreach ($groups as $group) {

                $details = $test->getGroupDetails();
                if(isset($details['default'])){
                    $groupDetails[$group] = $details['default'];
                }
            }
            $test->setGroupDetails($groupDetails);
        }

Environment info

Codeception: 2.2.7 Operating System: ubuntu PHP Version: 5.6.29-1+deb.sury.org~xenial+1 (cli) MySQL Version: N/A

Logs or other output that would be helpful

[Groups] session-repository 
PHP Notice:  Undefined index: default in /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/src/Codeception/SuiteManager.php on line 130
PHP Stack trace:
PHP   1. {main}() /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/codecept:0
PHP   2. Codeception\Application->run() /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/codecept:34
PHP   3. Symfony\Component\Console\Application->run() /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/src/Codeception/Application.php:103
PHP   4. Symfony\Component\Console\Application->doRun() /home/ade/Projects/Packages/PHP/session/vendor/symfony/console/Application.php:122
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/ade/Projects/Packages/PHP/session/vendor/symfony/console/Application.php:191
PHP   6. Symfony\Component\Console\Command\Command->run() /home/ade/Projects/Packages/PHP/session/vendor/symfony/console/Application.php:830
PHP   7. Codeception\Command\Run->execute() /home/ade/Projects/Packages/PHP/session/vendor/symfony/console/Command/Command.php:255
PHP   8. Codeception\Command\Run->runSuites() /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/src/Codeception/Command/Run.php:287
PHP   9. Codeception\Codecept->run() /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/src/Codeception/Command/Run.php:360
PHP  10. Codeception\Codecept->runSuite() /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/src/Codeception/Codecept.php:152
PHP  11. Codeception\SuiteManager->loadTests() /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/src/Codeception/Codecept.php:182
PHP  12. Codeception\SuiteManager->addToSuite() /home/ade/Projects/Packages/PHP/session/vendor/codeception/codeception/src/Codeception/SuiteManager.php:103
ptejada commented 7 years ago

@aedart I don't think this is related to this project. Do yo get same error if try to execute directly on CLI(without PHPCI)?

aedart commented 7 years ago

Ups - uhm, not sure how this issue landed here. Please ignore this issue, as it is related to Codeception / PHP Unit...

Very sorry :)

aedart commented 7 years ago

Moved issue to https://github.com/Codeception/Codeception/issues/3870