-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathFilterCheckTest.php
More file actions
75 lines (63 loc) · 1.91 KB
/
FilterCheckTest.php
File metadata and controls
75 lines (63 loc) · 1.91 KB
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
74
75
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace CodeIgniter\Commands;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\StreamFilterTrait;
use PHPUnit\Framework\Attributes\Group;
/**
* @internal
*/
#[Group('Others')]
final class FilterCheckTest extends CIUnitTestCase
{
use StreamFilterTrait;
protected function setUp(): void
{
$this->resetServices();
parent::setUp();
}
protected function tearDown(): void
{
$this->resetServices();
parent::tearDown();
}
protected function getBuffer(): string
{
return $this->getStreamFilterBuffer();
}
public function testFilterCheckDefinedRoute(): void
{
command('filter:check GET /');
$this->assertStringContainsString(
'| GET | / | forcehttps pagecache | pagecache performance toolbar |',
(string) preg_replace('/\033\[.+?m/u', '', $this->getBuffer()),
);
$this->assertStringContainsString(
'Before Filter Classes:
CodeIgniter\Filters\ForceHTTPS → CodeIgniter\Filters\PageCache
After Filter Classes:
CodeIgniter\Filters\PageCache → CodeIgniter\Filters\PerformanceMetrics → CodeIgniter\Filters\DebugToolbar',
(string) preg_replace('/\033\[.+?m/u', '', $this->getBuffer()),
);
}
public function testFilterCheckInvalidRoute(): void
{
command('filter:check PUT product/123');
$this->assertStringContainsString(
'Can\'t find a route: "PUT product/123"',
str_replace(
["\033[0m", "\033[1;31m", "\033[0;30m", "\033[47m"],
'',
$this->getBuffer(),
),
);
}
}