diff options
| author | William Boman <william@redwill.se> | 2022-09-12 16:10:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-12 16:10:09 +0200 |
| commit | b56ea0bd8b6b1c265752226666f1069d0a479438 (patch) | |
| tree | 5a90f8d008438962215d18c8ad3852f1bb339875 /tests | |
| parent | feat: add phpcs, phpcbf, phpmd, phpstan and twigcs (#399) (diff) | |
| download | mason-b56ea0bd8b6b1c265752226666f1069d0a479438.tar mason-b56ea0bd8b6b1c265752226666f1069d0a479438.tar.gz mason-b56ea0bd8b6b1c265752226666f1069d0a479438.tar.bz2 mason-b56ea0bd8b6b1c265752226666f1069d0a479438.tar.lz mason-b56ea0bd8b6b1c265752226666f1069d0a479438.tar.xz mason-b56ea0bd8b6b1c265752226666f1069d0a479438.tar.zst mason-b56ea0bd8b6b1c265752226666f1069d0a479438.zip | |
refactor: add ctx:write_php_exec_wrapper utility (#409)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mason-core/installer/context_spec.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/mason-core/installer/context_spec.lua b/tests/mason-core/installer/context_spec.lua index 3f8b23c9..2523d33e 100644 --- a/tests/mason-core/installer/context_spec.lua +++ b/tests/mason-core/installer/context_spec.lua @@ -172,4 +172,39 @@ cmd.exe /C echo %GREETING% %*]] assert.equals([[Cannot write exec wrapper for path "obscure/path/to/server" as it doesn't exist.]], err) assert.spy(ctx.write_shell_exec_wrapper).was_called(0) end) + + it("should write PHP exec wrapper", function() + local php_rel_path = path.concat { "some", "obscure", "path", "cli.php" } + local dummy = registry.get_package "dummy" + local handle = InstallHandleGenerator "dummy" + local ctx = InstallContextGenerator(handle) + stub(ctx, "write_shell_exec_wrapper") + stub(ctx.fs, "file_exists") + ctx.fs.file_exists.on_call_with(match.is_ref(ctx.fs), php_rel_path).returns(true) + + ctx:write_php_exec_wrapper("my-wrapper-script", php_rel_path) + + assert.spy(ctx.write_shell_exec_wrapper).was_called(1) + assert.spy(ctx.write_shell_exec_wrapper).was_called_with( + match.is_ref(ctx), + "my-wrapper-script", + ("php %q"):format(path.concat { dummy:get_install_path(), php_rel_path }) + ) + end) + + it("should not write PHP exec wrapper if the target script doesn't exist", function() + local php_rel_path = path.concat { "some", "obscure", "path", "cli.php" } + local handle = InstallHandleGenerator "dummy" + local ctx = InstallContextGenerator(handle) + stub(ctx, "write_shell_exec_wrapper") + stub(ctx.fs, "file_exists") + ctx.fs.file_exists.on_call_with(match.is_ref(ctx.fs), php_rel_path).returns(false) + + local err = assert.has_error(function() + ctx:write_php_exec_wrapper("my-wrapper-script", php_rel_path) + end) + + assert.equals([[Cannot write PHP exec wrapper for path "some/obscure/path/cli.php" as it doesn't exist.]], err) + assert.spy(ctx.write_shell_exec_wrapper).was_called(0) + end) end) |
