Skip to content

Commit 26e5bba

Browse files
committed
Fix tests
1 parent 2fc509f commit 26e5bba

5 files changed

Lines changed: 17 additions & 19 deletions

File tree

classes/Hook/HookDisplayBeforeBodyClosingTag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private function renderProductListing()
162162
// Prepare items to our format
163163
$productWrapper = new ProductWrapper($this->context);
164164
$items = $productWrapper->prepareItemListFromProductList($listing['products']);
165-
165+
166166
// Prepare info about the list
167167
$item_list_id = $this->context->controller->php_self;
168168
$item_list_name = $listing['label'];
@@ -245,7 +245,7 @@ private function renderBeginCheckout()
245245
// If using default OrderController that comes with prestashop, we will check if we are
246246
// on step 1 of the checkout. Otherwise, we will flush the output anyway. It's probably OPC
247247
// handling everything with javascript, so our code will load only once.
248-
if (get_class($this->context->controller) == "OrderController") {
248+
if (get_class($this->context->controller) == 'OrderController') {
249249
// If we are not in the first step of checkout, we don't do anything
250250
// TODO test how it behaves with logged in customer
251251
if (!$this->context->controller->getCheckoutProcess()->getSteps()[0]->isCurrent()) {

classes/Hook/HookDisplayFooterProduct.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(Ps_Googleanalytics $module, Context $context)
3939
/**
4040
* run
4141
*
42-
* @return string
42+
* @return string|null
4343
*/
4444
public function run()
4545
{
@@ -105,7 +105,8 @@ public function run()
105105
*
106106
* @return bool
107107
*/
108-
private function wasPreviousPageOurShop() {
108+
private function wasPreviousPageOurShop()
109+
{
109110
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
110111
return true;
111112
}
@@ -135,6 +136,7 @@ private function getLastVisitedListing()
135136
// Check if the last listing is the page the user came from
136137
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $last_listing['item_list_url']) !== false) {
137138
unset($last_listing['item_list_url']);
139+
138140
return $last_listing;
139141
}
140142

classes/Hook/HookDisplayHeader.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@
2020

2121
namespace PrestaShop\Module\Ps_Googleanalytics\Hooks;
2222

23-
use Category;
2423
use Configuration;
2524
use Context;
2625
use Customer;
27-
use PrestaShop\Module\Ps_Googleanalytics\Handler\GanalyticsJsHandler;
28-
use PrestaShop\Module\Ps_Googleanalytics\Handler\ModuleHandler;
29-
use PrestaShop\Module\Ps_Googleanalytics\Wrapper\ProductWrapper;
3026
use Ps_Googleanalytics;
3127
use Tools;
3228

classes/Hook/HookDisplayOrderConfirmation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function run()
6969

7070
// If the customer is revisiting confirmation screen and the order was already sent, we don't do anything
7171
if ($ganalyticsRepository->hasOrderBeenAlreadySent((int) $order->id)) {
72-
// return $gaScripts;
72+
return $gaScripts;
7373
}
7474

7575
// Prepare transaction data

classes/Wrapper/ProductWrapper.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
use Configuration;
2424
use Context;
25-
use Product;
26-
use Tools;
27-
use Shop;
2825
use PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductLazyArray;
2926
use PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingLazyArray;
27+
use Product;
28+
use Shop;
29+
use Tools;
3030

3131
class ProductWrapper
3232
{
@@ -83,9 +83,9 @@ public function wrapProduct($product, $extras = [], $index = 0)
8383

8484
/**
8585
* Takes provided list of product (lazy) arrays and converts it to a format that GA4 requires.
86-
*
86+
*
8787
* @param array $productList
88-
*
88+
*
8989
* @return array Item data standardized for GA
9090
*/
9191
public function prepareItemListFromProductList($productList, $isCartList = false)
@@ -103,7 +103,7 @@ public function prepareItemListFromProductList($productList, $isCartList = false
103103
$product = $this->prepareItemFromProduct($product, $isCartList);
104104
$product['index'] = $counter;
105105
$items[] = $product;
106-
$counter++;
106+
++$counter;
107107
}
108108

109109
return $items;
@@ -115,9 +115,9 @@ public function prepareItemListFromProductList($productList, $isCartList = false
115115
* - ProductListingLazyArray from presented listings
116116
* - ProductListingLazyArray from presented cart
117117
* - Raw $cart->getProducts()
118-
*
118+
*
119119
* @param ProductLazyArray|ProductListingLazyArray|array $product
120-
*
120+
*
121121
* @return array Item data standardized for GA
122122
*/
123123
public function prepareItemFromProduct($product, $isCartList = false)
@@ -139,7 +139,7 @@ public function prepareItemFromProduct($product, $isCartList = false)
139139
'affiliation' => Shop::isFeatureActive() ? $this->context->shop->name : Configuration::get('PS_SHOP_NAME'),
140140
'index' => 0,
141141
'price' => $product['price_amount'],
142-
'quantity' => 1
142+
'quantity' => 1,
143143
];
144144

145145
// Add manufacturer info if we have it
@@ -183,7 +183,7 @@ public function prepareItemFromProduct($product, $isCartList = false)
183183
$counter = 1;
184184
foreach ($productCategories as $productCategory) {
185185
$item[$counter == 1 ? 'item_category' : 'item_category' . $counter] = $productCategory['name'];
186-
$counter++;
186+
++$counter;
187187
}
188188

189189
return $item;

0 commit comments

Comments
 (0)