-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing Hooks with
ps_qualityassurance
- Loading branch information
Showing
7 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...ization/quality-council/processes/test-hooks-with-ps_qualityassurance/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"} |
Binary file added
BIN
+88.3 KB
...sses/test-hooks-with-ps_qualityassurance/hook-actionProductPriceCalculation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
...rocesses/test-hooks-with-ps_qualityassurance/hook-displayProductListReviews.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+163 KB
...es/test-hooks-with-ps_qualityassurance/hooked-actionProductPriceCalculation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+98.6 KB
...cesses/test-hooks-with-ps_qualityassurance/hooked-displayProductListReviews.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.5 KB
...lity-council/processes/test-hooks-with-ps_qualityassurance/installed-module.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.