Codeception / c3

Remote CodeCoverage for Codeception. Part of Codeception testing framework.
http://codeception.com
72 stars 46 forks source link

Constant C3_CODECOVERAGE_MEDIATE_STORAGE can be used before it's defined #37

Open CJDennis opened 6 years ago

CJDennis commented 6 years ago

If these lines fail:

try {
    \Codeception\Configuration::config($config_file);
} catch (\Exception $e) {
    __c3_error($e->getMessage());
}

due to \Codeception\Configuration not existing, then

        $errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ?
            C3_CODECOVERAGE_ERROR_LOG_FILE :
            C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt';

is called before

    define('C3_CODECOVERAGE_MEDIATE_STORAGE', Codeception\Configuration::logDir() . 'c3tmp');
    define('C3_CODECOVERAGE_PROJECT_ROOT', Codeception\Configuration::projectDir());
    define('C3_CODECOVERAGE_TESTNAME', $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE']);

is run.

bscheshirwork commented 6 years ago

This like a true...

https://github.com/Codeception/c3/blob/777e3b626d9a5ecdfea3eff3d3de437045b41c92/c3.php#L33-L49 is a function definition.

In this code https://github.com/Codeception/c3/blob/777e3b626d9a5ecdfea3eff3d3de437045b41c92/c3.php#L95-L99

Function __c3_error is called before check https://github.com/Codeception/c3/blob/777e3b626d9a5ecdfea3eff3d3de437045b41c92/c3.php#L101

willpower232 commented 4 years ago

This is still an issue, I am using Laravel so I have made the following change:

$mediateStorage = defined('C3_CODECOVERAGE_MEDIATE_STORAGE') ?
    C3_CODECOVERAGE_MEDIATE_STORAGE :
    'storage';

$errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ?
    C3_CODECOVERAGE_ERROR_LOG_FILE :
    $mediateStorage . DIRECTORY_SEPARATOR . 'error.txt';