]> BookStack Code Mirror - system-cli/blob - tests/Commands/InitCommandTest.php
Added strict types, started phpunit testing
[system-cli] / tests / Commands / InitCommandTest.php
1 <?php declare(strict_types=1);
2
3 namespace Tests\Commands;
4
5 use Tests\TestCase;
6
7 class InitCommandTest extends TestCase
8 {
9     public function test_command_creates_an_instance_in_cwd()
10     {
11         $dir = $this->getEmptyTestDir();
12         chdir($dir);
13
14         $commandTester = $this->runCommand('init');
15         $commandTester->assertCommandIsSuccessful();
16
17         $this->assertFileExists($dir . '/vendor/autoload.php');
18         $this->assertFileExists($dir . '/.env');
19
20         $envData = file_get_contents($dir . '/.env');
21         $this->assertMatchesRegularExpression('/^APP_KEY=base64:.{30,60}$/m', $envData);
22
23         $output = $commandTester->getDisplay();
24         $this->assertStringContainsString("A BookStack install has been initialized at: " . $dir, $output);
25
26         $this->deleteDirectory($dir);
27     }
28 }