Skip to content

Commit 5418869

Browse files
committed
tests: add argument for opcache only
1 parent 729effd commit 5418869

File tree

2 files changed

+77
-2
lines changed

2 files changed

+77
-2
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of CodeIgniter 4 framework.
7+
*
8+
* (c) CodeIgniter Foundation <[email protected]>
9+
*
10+
* For the full copyright and license information, please view
11+
* the LICENSE file that was distributed with this source code.
12+
*/
13+
14+
namespace CodeIgniter\Commands\Utilities;
15+
16+
use CodeIgniter\Test\CIUnitTestCase;
17+
use CodeIgniter\Test\StreamFilterTrait;
18+
use Config\App;
19+
use PHPUnit\Framework\Attributes\Group;
20+
21+
/**
22+
* @internal
23+
*/
24+
#[Group('Others')]
25+
final class PhpIniCheckTest extends CIUnitTestCase
26+
{
27+
use StreamFilterTrait;
28+
29+
protected function setUp(): void
30+
{
31+
$this->resetServices();
32+
parent::setUp();
33+
}
34+
35+
protected function tearDown(): void
36+
{
37+
$this->resetServices();
38+
parent::tearDown();
39+
}
40+
41+
protected function getBuffer()
42+
{
43+
return $this->getStreamFilterBuffer();
44+
}
45+
46+
public function testCommandCheckNoArg(): void
47+
{
48+
command('phpini:check');
49+
50+
$result = $this->getBuffer();
51+
52+
$this->assertStringContainsString('Directive', $result);
53+
$this->assertStringContainsString('Global', $result);
54+
$this->assertStringContainsString('Current', $result);
55+
$this->assertStringContainsString('Recommended', $result);
56+
$this->assertStringContainsString('Remark', $result);
57+
}
58+
59+
public function testCommandCheckOpcache(): void
60+
{
61+
command('phpini:check opcache');
62+
63+
$this->assertStringContainsString("opcache.save_comments", $this->getBuffer());
64+
}
65+
66+
public function testCommandCheckNoExistsArg(): void
67+
{
68+
command('phpini:check noexists');
69+
70+
$this->assertStringContainsString(
71+
'You must write correct arguments.',
72+
$this->getBuffer()
73+
);
74+
}
75+
}

tests/system/Security/CheckPhpIniTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public function testCheckIni(): void
3939

4040
public function testCheckIniOpcache(): void
4141
{
42-
$output = CheckPhpIni::checkIni();
42+
$output = CheckPhpIni::checkIni('opcache');
4343

4444
$expected = [
4545
'global' => '1',
4646
'current' => '1',
47-
'recommended' => '1',
47+
'recommended' => '0',
4848
'remark' => '',
4949
];
5050
$this->assertSame($expected, $output['opcache.save_comments']);

0 commit comments

Comments
 (0)