Passed
Pull Request — master (#156)
by Wilmer
02:29
created

ConsoleAppInfoCollectorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A checkCollectedData() 0 10 2
A getCollector() 0 3 1
A collectTestData() 0 5 1
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
final class ConsoleAppInfoCollectorTest extends CollectorTestCase
14
{
15
    /**
16
     * @param CollectorInterface|WebAppInfoCollector $collector
17
     */
18
    protected function collectTestData(CollectorInterface $collector): void
19
    {
20
        $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

20
        $collector->/** @scrutinizer ignore-call */ 
21
                    collect(new ApplicationStartup(null));
Loading history...
21
        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...
22
        $collector->collect(new ApplicationShutdown(0));
23
    }
24
25
    protected function getCollector(): CollectorInterface
26
    {
27
        return new ConsoleAppInfoCollector();
28
    }
29
30
    protected function checkCollectedData(CollectorInterface $collector): void
31
    {
32
        if (DIRECTORY_SEPARATOR === '\\') {
33
            $this->markTestSkipped('This test is not supported on Windows.');
34
        }
35
36
        parent::checkCollectedData($collector);
37
        $data = $collector->getCollected();
38
39
        $this->assertGreaterThan(0.122, $data['applicationProcessingTime']);
40
    }
41
}
42