|
| 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 | +} |
0 commit comments