PHP code example of league / phpunit-coverage-listener

1. Go to this page and download the library: Download league/phpunit-coverage-listener library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

league / phpunit-coverage-listener example snippets




$success = false;

if (!empty($_FILES) && isset($_FILES['json_file'])) {
    $target = __DIR__.'/coverage.json';
    move_uploaded_file($_FILES['json_file']['tmp_name'], $target);
    $success = 'Saved into http://'.$_SERVER['HTTP_HOST'].'/coverage.json';
}

header('Content-Type: application/json');
die(json_encode(compact('success')));

public function beforeCollect(Collection $data)
{
    // Check for Travis-CI environment
    // if it appears, then assign it respectively
    if (getenv('TRAVIS_JOB_ID') || isset($_ENV['TRAVIS_JOB_ID'])) {
        // Remove repo token
        $data->remove('repo_token');

        // And use travis config
        $travis_job_id = isset($_ENV['TRAVIS_JOB_ID']) ? $_ENV['TRAVIS_JOB_ID'] : getenv('TRAVIS_JOB_ID');
        $data->set('service_name', 'travis-ci');
        $data->set('service_job_id', $travis_job_id);
    }

    return $data;
}