Skip to content

Commit

Permalink
fix message and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Mar 14, 2024
1 parent 807b79e commit 6ef589d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use AcquiaCloudApi\Response\AccountResponse;
use AcquiaCloudApi\Response\ApplicationResponse;
use AcquiaCloudApi\Response\ApplicationsResponse;
use AcquiaCloudApi\Response\CronResponse;
use AcquiaCloudApi\Response\CronsResponse;
use AcquiaCloudApi\Response\DatabasesResponse;
use AcquiaCloudApi\Response\EnvironmentResponse;
use AcquiaCloudApi\Response\EnvironmentsResponse;
Expand All @@ -14,7 +16,9 @@
'getApplicationByUuid' => ApplicationResponse::class,
'getApplicationEnvironments' => EnvironmentsResponse::class,
'getEnvironmentsDatabases' => DatabasesResponse::class,
'getEnvironment' => EnvironmentResponse::class
'getEnvironment' => EnvironmentResponse::class,
'getCron' => CronResponse::class,
'getCronJobsByEnvironmentId' => CronsResponse::class
]));

}
2 changes: 1 addition & 1 deletion src/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function onConsoleError(ConsoleErrorEvent $event): void {
}

if ($error instanceof \TypeError && str_contains($error->getMessage(), 'AcquiaCloudApi\Response')) {

Check warning on line 82 in src/EventListener/ExceptionListener.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ $this->helpMessages[] = "You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/"; } } - if ($error instanceof \TypeError && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { + if (false && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { $newErrorMessage = 'Cloud Platform API returned an unexpected data type. This is not an issue with Acquia CLI but could indicate a problem with your Cloud Platform application.'; } $this->helpMessages[] = "You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/";

Check warning on line 82 in src/EventListener/ExceptionListener.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ $this->helpMessages[] = "You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/"; } } - if ($error instanceof \TypeError && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { + if (true && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { $newErrorMessage = 'Cloud Platform API returned an unexpected data type. This is not an issue with Acquia CLI but could indicate a problem with your Cloud Platform application.'; } $this->helpMessages[] = "You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/";

Check warning on line 82 in src/EventListener/ExceptionListener.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ $this->helpMessages[] = "You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/"; } } - if ($error instanceof \TypeError && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { + if ($error instanceof \TypeError || str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { $newErrorMessage = 'Cloud Platform API returned an unexpected data type. This is not an issue with Acquia CLI but could indicate a problem with your Cloud Platform application.'; } $this->helpMessages[] = "You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/";

Check warning on line 82 in src/EventListener/ExceptionListener.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "LogicalAndAllSubExprNegation": --- Original +++ New @@ @@ $this->helpMessages[] = "You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/"; } } - if ($error instanceof \TypeError && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { + if (!$error instanceof \TypeError && !str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { $newErrorMessage = 'Cloud Platform API returned an unexpected data type. This is not an issue with Acquia CLI but could indicate a problem with your Cloud Platform application.'; } $this->helpMessages[] = "You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/";

Check warning on line 82 in src/EventListener/ExceptionListener.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "LogicalAndNegation": --- Original +++ New @@ @@ $this->helpMessages[] = "You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/"; } } - if ($error instanceof \TypeError && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { + if (!($error instanceof \TypeError && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response'))) { $newErrorMessage = 'Cloud Platform API returned an unexpected data type. This is not an issue with Acquia CLI but could indicate a problem with your Cloud Platform application.'; } $this->helpMessages[] = "You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/";

Check warning on line 82 in src/EventListener/ExceptionListener.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation": --- Original +++ New @@ @@ $this->helpMessages[] = "You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/"; } } - if ($error instanceof \TypeError && str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { + if ($error instanceof \TypeError && !str_contains($error->getMessage(), 'AcquiaCloudApi\\Response')) { $newErrorMessage = 'Cloud Platform API returned an unexpected data type. This is not an issue with Acquia CLI but could indicate a problem with your Cloud Platform application.'; } $this->helpMessages[] = "You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/";
$newErrorMessage = 'Cloud API returned an unexpected data type; this could indicate a problem with your Cloud application.';
$newErrorMessage = 'Cloud Platform API returned an unexpected data type. This is not an issue with Acquia CLI but could indicate a problem with your Cloud Platform application.';
}

$this->helpMessages[] = "You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/";
Expand Down
17 changes: 17 additions & 0 deletions tests/phpunit/src/Application/ExceptionApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,21 @@ public function testInvalidApplicationUuid(): void {
self::assertStringContainsString('An alias consists of an application name', $buffer);
}

/**
* @group serial
*/
public function testApiTypeError(): void {
$tamper = function ($response): void {
$response[0]->server = [];
};
$this->mockRequest('getCronJobsByEnvironmentId', '24-a47ac10b-58cc-4372-a567-0e02b2c3d470', NULL, NULL, $tamper);
$this->setInput([
'command' => 'env:cron-copy',
'dest_env' => '24-a47ac10b-58cc-4372-a567-0e02b2c3d471',
'source_env' => '24-a47ac10b-58cc-4372-a567-0e02b2c3d470',
]);
$buffer = $this->runApp();
self::assertStringContainsString('Cloud Platform API returned an unexpected data type.', $buffer);
}

}

0 comments on commit 6ef589d

Please sign in to comment.