Skip to content

Commit

Permalink
tests: add argument for opcache only
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr committed Aug 22, 2024
1 parent 729effd commit 5418869
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
75 changes: 75 additions & 0 deletions tests/system/Commands/Utilities/PhpIniCheckTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

declare(strict_types=1);

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace CodeIgniter\Commands\Utilities;

use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\StreamFilterTrait;
use Config\App;
use PHPUnit\Framework\Attributes\Group;

/**
* @internal
*/
#[Group('Others')]
final class PhpIniCheckTest extends CIUnitTestCase
{
use StreamFilterTrait;

protected function setUp(): void
{
$this->resetServices();
parent::setUp();
}

protected function tearDown(): void
{
$this->resetServices();
parent::tearDown();
}

protected function getBuffer()

Check failure on line 41 in tests/system/Commands/Utilities/PhpIniCheckTest.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method CodeIgniter\Commands\Utilities\PhpIniCheckTest::getBuffer() has no return type specified.
{
return $this->getStreamFilterBuffer();
}

public function testCommandCheckNoArg(): void
{
command('phpini:check');

$result = $this->getBuffer();

$this->assertStringContainsString('Directive', $result);
$this->assertStringContainsString('Global', $result);
$this->assertStringContainsString('Current', $result);
$this->assertStringContainsString('Recommended', $result);
$this->assertStringContainsString('Remark', $result);
}

public function testCommandCheckOpcache(): void
{
command('phpini:check opcache');

$this->assertStringContainsString("opcache.save_comments", $this->getBuffer());
}

public function testCommandCheckNoExistsArg(): void
{
command('phpini:check noexists');

$this->assertStringContainsString(
'You must write correct arguments.',
$this->getBuffer()
);
}
}
4 changes: 2 additions & 2 deletions tests/system/Security/CheckPhpIniTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public function testCheckIni(): void

public function testCheckIniOpcache(): void
{
$output = CheckPhpIni::checkIni();
$output = CheckPhpIni::checkIni('opcache');

$expected = [
'global' => '1',
'current' => '1',
'recommended' => '1',
'recommended' => '0',
'remark' => '',
];
$this->assertSame($expected, $output['opcache.save_comments']);
Expand Down

0 comments on commit 5418869

Please sign in to comment.