Вход Регистрация
Файл: vendor/phpunit/phpunit/src/Runner/ResultCacheExtension.php
Строк: 104
<?php declare(strict_types=1);
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PHPUnitRunner;

use function 
preg_match;
use function 
round;

/**
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
 */
final class ResultCacheExtension implements AfterIncompleteTestHookAfterLastTestHookAfterRiskyTestHookAfterSkippedTestHookAfterSuccessfulTestHookAfterTestErrorHookAfterTestFailureHookAfterTestWarningHook
{
    
/**
     * @var TestResultCache
     */
    
private $cache;

    public function 
__construct(TestResultCache $cache)
    {
        
$this->cache $cache;
    }

    public function 
flush(): void
    
{
        
$this->cache->persist();
    }

    public function 
executeAfterSuccessfulTest(string $testfloat $time): void
    
{
        
$testName $this->getTestName($test);

        
$this->cache->setTime($testNameround($time3));
    }

    public function 
executeAfterIncompleteTest(string $teststring $messagefloat $time): void
    
{
        
$testName $this->getTestName($test);

        
$this->cache->setTime($testNameround($time3));
        
$this->cache->setState($testNameBaseTestRunner::STATUS_INCOMPLETE);
    }

    public function 
executeAfterRiskyTest(string $teststring $messagefloat $time): void
    
{
        
$testName $this->getTestName($test);

        
$this->cache->setTime($testNameround($time3));
        
$this->cache->setState($testNameBaseTestRunner::STATUS_RISKY);
    }

    public function 
executeAfterSkippedTest(string $teststring $messagefloat $time): void
    
{
        
$testName $this->getTestName($test);

        
$this->cache->setTime($testNameround($time3));
        
$this->cache->setState($testNameBaseTestRunner::STATUS_SKIPPED);
    }

    public function 
executeAfterTestError(string $teststring $messagefloat $time): void
    
{
        
$testName $this->getTestName($test);

        
$this->cache->setTime($testNameround($time3));
        
$this->cache->setState($testNameBaseTestRunner::STATUS_ERROR);
    }

    public function 
executeAfterTestFailure(string $teststring $messagefloat $time): void
    
{
        
$testName $this->getTestName($test);

        
$this->cache->setTime($testNameround($time3));
        
$this->cache->setState($testNameBaseTestRunner::STATUS_FAILURE);
    }

    public function 
executeAfterTestWarning(string $teststring $messagefloat $time): void
    
{
        
$testName $this->getTestName($test);

        
$this->cache->setTime($testNameround($time3));
        
$this->cache->setState($testNameBaseTestRunner::STATUS_WARNING);
    }

    public function 
executeAfterLastTest(): void
    
{
        
$this->flush();
    }

    
/**
     * @param string $test A long description format of the current test
     *
     * @return string The test name without TestSuiteClassName:: and @dataprovider details
     */
    
private function getTestName(string $test): string
    
{
        
$matches = [];

        if (
preg_match('/^(?<name>S+::S+)(?:(?<dataname> with data set (?:#d+|"[^"]+"))s()?/'$test$matches)) {
            
$test $matches['name'] . ($matches['dataname'] ?? '');
        }

        return 
$test;
    }
}
Онлайн: 1
Реклама