7 class DownloadVendorCommandTest extends TestCase
9 public function test_command_downloads_vendor_folder()
11 $this->withOwnBookStackFolder(function (string $basePath) {
12 exec("rm -rf $basePath/vendor");
13 file_put_contents("$basePath/version", 'v25.02');
14 mkdir("$basePath/dev/checksums", '0777', true);
15 file_put_contents("$basePath/dev/checksums/vendor", '22e02ee72d21ff719c1073abbec8302f8e2096ba6d072e133051064ed24b45b1');
17 $this->assertDirectoryDoesNotExist("$basePath/vendor");
19 $result = $this->runCommand('download-vendor');
21 $result->assertSuccessfulExit();
22 $result->assertStdoutContains('Downloading ZIP from files.bookstackapp.com...');
23 $result->assertStdoutContains('Successfully downloaded & extracted vendor files into BookStack instance!');
25 $this->assertDirectoryExists("$basePath/vendor/composer");
29 public function test_app_directory_option()
31 $this->withOwnBookStackFolder(function (string $basePath) {
34 exec("rm -rf $basePath/vendor");
35 file_put_contents("$basePath/version", 'v25.02');
36 mkdir("$basePath/dev/checksums", '0777', true);
37 file_put_contents("$basePath/dev/checksums/vendor", '22e02ee72d21ff719c1073abbec8302f8e2096ba6d072e133051064ed24b45b1');
39 $this->assertDirectoryDoesNotExist("$basePath/vendor");
41 $result = $this->runCommand('download-vendor', ['--app-directory' => $basePath]);
43 $result->assertSuccessfulExit();
44 $this->assertDirectoryExists("$basePath/vendor/composer");
46 $result = $this->runCommand('download-vendor', ['--app-directory' => '/var/beans']);
47 $result->assertErrorExit();
48 $result->assertStderrContains('Could not find a valid BookStack installation');
52 public function test_command_fails_on_checksum_mismatch()
54 $this->withOwnBookStackFolder(function (string $basePath) {
55 file_put_contents("$basePath/version", 'v25.02');
56 mkdir("$basePath/dev/checksums", '0777', true);
57 file_put_contents("$basePath/dev/checksums/vendor", '42e02ee72d21ff719c1073abbec8302f8e2096ba6d072e133051064ed24b45b1');
59 $result = $this->runCommand('download-vendor');
61 $result->assertErrorExit();
62 $result->assertStdoutContains('Downloading ZIP from files.bookstackapp.com...');
63 $result->assertStderrContains('Checksum of downloaded ZIP does not match the expected checksum.');
65 $this->assertDirectoryExists("$basePath/vendor/composer");