Passed
Pull Request — master (#156)
by Wilmer
05:09 queued 02:34
created

ConsoleAppInfoCollectorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 26
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A checkCollectedData() 0 7 1
A getCollector() 0 3 1
A collectTestData() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Tests\Collector;
6
7
use Yiisoft\Yii\Console\Event\ApplicationShutdown;
8
use Yiisoft\Yii\Console\Event\ApplicationStartup;
9
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
10
use Yiisoft\Yii\Debug\Collector\ConsoleAppInfoCollector;
11
use Yiisoft\Yii\Debug\Collector\WebAppInfoCollector;
12
13
use function sleep;
14
use function usleep;
15
16
final class ConsoleAppInfoCollectorTest extends CollectorTestCase
17
{
18
    /**
19
     * @param CollectorInterface|WebAppInfoCollector $collector
20
     */
21
    protected function collectTestData(CollectorInterface $collector): void
22
    {
23
        $collector->collect(new ApplicationStartup(null));
0 ignored issues
show
Bug introduced by
The method collect() does not exist on Yiisoft\Yii\Debug\Collector\CollectorInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Yiisoft\Yii\Debug\Collector\QueueCollector. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        $collector->/** @scrutinizer ignore-call */ 
24
                    collect(new ApplicationStartup(null));
Loading history...
24
25
        DIRECTORY_SEPARATOR === '\\' ? sleep(1) : usleep(123_000);
0 ignored issues
show
Bug introduced by
The constant Yiisoft\Yii\Debug\Tests\Collector\123_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
26
27
        $collector->collect(new ApplicationShutdown(0));
28
    }
29
30
    protected function getCollector(): CollectorInterface
31
    {
32
        return new ConsoleAppInfoCollector();
33
    }
34
35
    protected function checkCollectedData(CollectorInterface $collector): void
36
    {
37
        parent::checkCollectedData($collector);
38
39
        $data = $collector->getCollected();
40
41
        $this->assertGreaterThan(0.122, $data['applicationProcessingTime']);
42
    }
43
}
44