Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

test(deploy): expand force param tests to cover all coercion cases

Josh Salway6eb527d0ab81
diff --git a/tests/Feature/DeployForceBooleanCastTest.php b/tests/Feature/DeployForceBooleanCastTest.php
index d00136ed22..5dc08d29b3 100644
--- a/tests/Feature/DeployForceBooleanCastTest.php
+++ b/tests/Feature/DeployForceBooleanCastTest.php
@@ -43,28 +43,47 @@ beforeEach(function () {
});
// Regression test: $request->input('force') ?? false coerced the string "false" to bool true,
-// causing every API deploy with force=false to run with --no-cache.
-test('force=false query string param does not set force_rebuild', function () {
+// causing every API deploy with ?force=false to run with --no-cache and bypass layer caching.
+//
+// Input | input('force') ?? false (old) | boolean('force') (fix)
+// ------------|-------------------------------|----------------------
+// "false" | true (bug — non-empty string)| false (correct)
+// "true" | true | true
+// "0" | false (PHP special-cases "0") | false
+// "1" | true | true
+// absent/null | false | false
+
+dataset('falsy force values', [
+ 'string false' => ['false'],
+ 'string 0' => ['0'],
+]);
+
+dataset('truthy force values', [
+ 'string true' => ['true'],
+ 'string 1' => ['1'],
+]);
+
+test('force=<falsy> query string param does not set force_rebuild', function (string $value) {
$response = $this->withHeaders(['Authorization' => 'Bearer '.$this->bearerToken])
- ->postJson('/api/v1/deploy?uuid='.$this->application->uuid.'&force=false');
+ ->postJson('/api/v1/deploy?uuid='.$this->application->uuid.'&force='.$value);
$response->assertSuccessful();
$deployment = $this->application->deployment_queue()->latest('id')->first();
expect($deployment)->not()->toBeNull();
expect($deployment->force_rebuild)->toBeFalse();
-});
+})->with('falsy force values');
-test('force=true query string param sets force_rebuild', function () {
+test('force=<truthy> query string param sets force_rebuild', function (string $value) {
$response = $this->withHeaders(['Authorization' => 'Bearer '.$this->bearerToken])
- ->postJson('/api/v1/deploy?uuid='.$this->application->uuid.'&force=true');
+ ->postJson('/api/v1/deploy?uuid='.$this->application->uuid.'&force='.$value);
$response->assertSuccessful();
$deployment = $this->application->deployment_queue()->latest('id')->first();
expect($deployment)->not()->toBeNull();
expect($deployment->force_rebuild)->toBeTrue();
-});
+})->with('truthy force values');
test('omitting force param does not set force_rebuild', function () {
$response = $this->withHeaders(['Authorization' => 'Bearer '.$this->bearerToken])