c3 icon indicating copy to clipboard operation
c3 copied to clipboard

Constant C3_CODECOVERAGE_MEDIATE_STORAGE can be used before it's defined

Open CJDennis opened this issue 7 years ago • 2 comments

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.

CJDennis avatar Oct 30 '17 04:10 CJDennis

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

bscheshirwork avatar Nov 15 '17 12:11 bscheshirwork

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';

willpower232 avatar Feb 10 '20 11:02 willpower232