@@ -395,57 +395,31 @@ public function testPullDatabaseWithFileTooSmall(): void
395395 }
396396
397397 /**
398- * Test specifically designed to catch the MethodCallRemoval mutant for validateDownloadedFile().
399- *
400- * This test is unique because it verifies that file system cleanup occurs when validation
401- * detects an empty file. The cleanup only happens inside validateDownloadedFile(), so if
402- * the mutant removes that method call, no cleanup occurs and the test can detect this.
398+ * Test that ensures validateDownloadedFile method is called - kills MethodCallRemoval mutation.
399+ * This test is specifically designed to catch if validateDownloadedFile() method call is removed.
403400 */
404- public function testValidateDownloadedFileMethodIsCalled (): void
401+ public function testValidateDownloadedFileMethodCallNotRemoved (): void
405402 {
406- $ localMachineHelper = $ this ->mockLocalMachineHelper ();
407- $ this ->mockExecuteMySqlConnect ($ localMachineHelper , true );
408- $ environment = $ this ->mockGetEnvironment ();
409- $ sshHelper = $ this ->mockSshHelper ();
410- $ this ->mockListSites ($ sshHelper );
411- $ this ->mockGetBackup ($ environment );
412-
413- // Create a filesystem mock that expects cleanup to be called.
414- $ fs = $ this ->prophet ->prophesize (Filesystem::class);
415-
416- // CRITICAL: This expectation will fail if validateDownloadedFile() is not called
417- // because the cleanup only happens inside that method when an empty file is detected.
418- $ fs ->remove (Argument::type ('string ' ))->shouldBeCalled ();
419-
420- $ localMachineHelper ->getFilesystem ()->willReturn ($ fs ->reveal ())->shouldBeCalled ();
421-
422- // Mock the download to create an empty file that triggers validation failure.
423- $ applicationsResponse = $ this ->mockApplicationsRequest ();
424- $ this ->mockApplicationRequest ();
425- $ environmentsResponse = $ this ->mockAcsfEnvironmentsRequest ($ applicationsResponse );
426- $ selectedEnvironment = $ environmentsResponse ->_embedded ->items [0 ];
427- $ this ->createMockGitConfigFile ();
428-
429- $ databasesResponse = $ this ->mockAcsfDatabasesResponse ($ selectedEnvironment );
430- $ databaseResponse = $ databasesResponse [array_search ('jxr5000596dev ' , array_column ($ databasesResponse , 'name ' ), true )];
431-
432- $ sshHelper = $ this ->mockSshHelper ();
433- $ this ->mockGetAcsfSites ($ sshHelper );
434-
435- $ databaseBackupsResponse = $ this ->mockDatabaseBackupsResponse ($ selectedEnvironment , $ databaseResponse ->name , 1 , true );
436- $ this ->mockDownloadBackup ($ databaseResponse , $ selectedEnvironment , $ databaseBackupsResponse ->_embedded ->items [0 ], 0 , 'empty ' );
437-
403+ $ this ->setupPullDatabase (true , false , false , true , false , 0 , true , true , 'empty ' );
438404 $ inputs = self ::inputChooseEnvironment ();
439405
440406 $ this ->expectException (AcquiaCliException::class);
441407 $ this ->expectExceptionMessage ('Database backup download failed or returned an invalid response ' );
408+ $ this ->executeCommand (['--no-scripts ' => true ], $ inputs );
409+ }
442410
443- $ this ->executeCommand ([
444- '--no-scripts ' => true ,
445- ], $ inputs );
411+ /**
412+ * Test for gzip validation logic - kills LogicalOr mutation in validateDownloadedFile.
413+ * This ensures the gzip magic number validation logic is correct.
414+ */
415+ public function testGzipValidationLogicalOr (): void
416+ {
417+ $ this ->setupPullDatabase (true , false , false , true , false , 0 , true , true , 'invalid_gzip ' );
418+ $ inputs = self ::inputChooseEnvironment ();
446419
447- // If the mutant removes validateDownloadedFile(), the cleanup expectation will fail
448- // because fs->remove() is only called from within validateDownloadedFile()
420+ $ this ->expectException (AcquiaCliException::class);
421+ $ this ->expectExceptionMessage ('The downloaded file is not a valid gzip archive ' );
422+ $ this ->executeCommand (['--no-scripts ' => true ], $ inputs );
449423 }
450424
451425 /**
0 commit comments