diff --git a/content/project-organization/quality-council/processes/_index.md b/content/project-organization/quality-council/processes/_index.md index b899ae4..80d13a5 100644 --- a/content/project-organization/quality-council/processes/_index.md +++ b/content/project-organization/quality-council/processes/_index.md @@ -10,11 +10,9 @@ title: Processes ## Pull Request Management +* [Testing Hooks with `ps_qualityassurance`](./test-hooks-with-ps_qualityassurance) * [Testing Pull Request](./pr-management) - -## Testing with vagrant - -* [How to test Pull Requests](./test-pr-and-branches) +* [Testing Pull Request with Vagrant](./test-pr-and-branches) ## Software Development in Test diff --git a/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/_index.md b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/_index.md new file mode 100644 index 0000000..12e8eef --- /dev/null +++ b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/_index.md @@ -0,0 +1,84 @@ +--- +title: Testing Hooks with `ps_qualityassurance` +--- + +# Testing Hooks with `ps_qualityassurance` + +Hooks are not easily testable. So a module [`ps_qualityassurance`](https://github.com/PrestaShop/ps_qualityassurance) has been created to test this module. + +## Installation + +### Fetch the ZIP module + +* Go to the [releases page of the module](https://github.com/PrestaShop/ps_qualityassurance/releases) +* Download the ZIP asset of the module linked to the latest release + +### Install the module + +* Go to your BackOffice +* Go to the "Modules" > "Module Manager" page +* Click on the "Upload a module" button +* Select the previous downloaded file +* The module is installed. + +![The module is installed.](./installed-module.png) +{class="text-center"} + +## Usage + +### Test an `action` Hook + +#### Context + +In this example, we try to check if the hook `actionProductPriceCalculation` is called in frontoffice. + +![Hook actionProductPriceCalculation](./hook-actionProductPriceCalculation.png) +{class="text-center"} + +We can see that the price is passed as reference. We will modify the price with `ps_qualityassurance`. + +#### Example + +* Go the configuration page of the module +* Click on the tab "Register Hook" +* For the hook name, use `actionProductPriceCalculation` +* For the content, use +```php + if ($params['use_tax']) { + $params['price'] = 42.00; + } else { + $params['price'] = 35.00; + } +``` +* Save +* Go to the frontoffice +* The hook runs well +![The hook runs well](./hooked-actionProductPriceCalculation.png) +{class="text-center"} + +### Test a `display` Hook + +#### Context + +In this example, we try to check if the hook `displayProductListReviews` is called in frontoffice. + +![Hook displayProductListReviews](./hook-displayProductListReviews.png) +{class="text-center"} + +We can see that the product is passed as parameter. We will use the product for displaying a new text with `ps_qualityassurance`. + +#### Example + +* Go the configuration page of the module +* Click on the tab "Register Hook" +* For the hook name, use `displayProductListReviews` +* For the content, use +```php + return 'Your product "' . $params['product']['name'] . '" has the ID ' . $params['product']['id'] . '.'; +``` +* Save +* Go to the frontoffice +* Go to a category page +* The hook runs well +![The hook runs well](./hooked-displayProductListReviews.png) +{class="text-center"} \ No newline at end of file diff --git a/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hook-actionProductPriceCalculation.png b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hook-actionProductPriceCalculation.png new file mode 100644 index 0000000..4f7a1ff Binary files /dev/null and b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hook-actionProductPriceCalculation.png differ diff --git a/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hook-displayProductListReviews.png b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hook-displayProductListReviews.png new file mode 100644 index 0000000..b50bb21 Binary files /dev/null and b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hook-displayProductListReviews.png differ diff --git a/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hooked-actionProductPriceCalculation.png b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hooked-actionProductPriceCalculation.png new file mode 100644 index 0000000..3e863cc Binary files /dev/null and b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hooked-actionProductPriceCalculation.png differ diff --git a/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hooked-displayProductListReviews.png b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hooked-displayProductListReviews.png new file mode 100644 index 0000000..12b55da Binary files /dev/null and b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/hooked-displayProductListReviews.png differ diff --git a/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/installed-module.png b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/installed-module.png new file mode 100644 index 0000000..7b85b99 Binary files /dev/null and b/content/project-organization/quality-council/processes/test-hooks-with-ps_qualityassurance/installed-module.png differ