1 <?php declare(strict_types=1);
3 namespace Tests\Commands;
7 class UpdateCommandTest extends TestCase
9 public function test_command_updates_instance_in_cwd()
11 chdir('/var/www/bookstack');
13 $result = $this->runCommand('update');
14 $result->assertSuccessfulExit();
15 $result->assertStdoutContains("Your BookStack instance at [/var/www/bookstack] has been updated!");
18 public function test_composer_gets_downloaded_locally_if_not_found()
20 chdir('/var/www/bookstack');
22 rename('/usr/local/bin/composer', '/usr/local/bin/hiddencomposer');
24 $this->assertFileDoesNotExist('/var/www/bookstack/composer');
26 $result = $this->runCommand('update');
27 $result->assertSuccessfulExit();
28 $result->assertStdoutContains("Composer does not exist, downloading a local copy...");
29 $result->assertStdoutContains("Your BookStack instance at [/var/www/bookstack] has been updated!");
31 $this->assertFileExists('/var/www/bookstack/composer');
32 unlink('/var/www/bookstack/composer');
34 rename('/usr/local/bin/hiddencomposer', '/usr/local/bin/composer');
37 public function test_command_rejects_on_no_instance_found()
41 $result = $this->runCommand('update');
42 $result->assertErrorExit();
43 $result->assertStderrContains('Could not find a valid BookStack installation');
46 public function test_command_can_be_provided_app_directory_option()
50 $result = $this->runCommand('update', ['--app-directory' => '/var/www/bookstack']);
51 $result->assertSuccessfulExit();
52 $result->assertStdoutContains("Your BookStack instance at [/var/www/bookstack] has been updated!");