This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathAppAnalyseMetricsCommandTest.php
73 lines (61 loc) · 2.01 KB
/
AppAnalyseMetricsCommandTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php declare(strict_types=1);
namespace App\Tests\Functional\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* Class AppAnalyseMetricsCommandTest
*
* @package App\Tests\Functional\Command
*/
class AppAnalyseMetricsCommandTest extends KernelTestCase
{
/**
* @return \Generator
*/
public function detectionProvider(): \Generator
{
/**
* The first test case is all about working statistics
* from a basic set of values. Check out the input and
* output files of what we expect.
*/
yield [
// Filename
__DIR__ . '/../../../resources/fixtures/1.json',
// Output
__DIR__ . '/../../../resources/fixtures/1.output',
];
/**
* The second test case is all pattern detection, working
* out when something out of the ordinary is happening.
*/
yield [
// Filename
__DIR__ . '/../../../resources/fixtures/2.json',
// Output
__DIR__ . '/../../../resources/fixtures/2.output',
];
}
/**
* Tests to ensure we're correctly detecting all slowdowns.
*
* @dataProvider detectionProvider
*
* @param string $filename The filename of the input fixture.
* @param string $expected The expected output of the command.
*/
public function testDetection(string $filename, string $expected): void
{
$kernel = self::createKernel();
$kernel->boot();
$application = new Application($kernel);
$command = $application->find('app:analyse-metrics');
$commandTester = new CommandTester($command);
$commandTester->execute([
'command' => $command->getName(),
'--input' => \realpath($filename),
]);
$this->assertStringEqualsFile(\realpath($expected), $commandTester->getDisplay());
}
}