Base.php
10 months ago
EasyDigitalDownloads.php
4 years ago
MatomoTestEcommerce.php
10 months ago
MemberPress.php
3 months ago
ServerSideVisitorId.php
1 year ago
Woocommerce.php
4 months ago
MatomoTestEcommerce.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WpMatomo\Ecommerce; |
| 4 | |
| 5 | /** |
| 6 | * this class is required only for phpunit tests. |
| 7 | * It allow to change the visibility of some methods of the Base class |
| 8 | * and so allow to test them in the unit tests |
| 9 | * |
| 10 | * phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found |
| 11 | */ |
| 12 | class MatomoTestEcommerce extends Base { |
| 13 | |
| 14 | public $should_track_background = false; |
| 15 | |
| 16 | public $supports_delayed_tracking = false; |
| 17 | |
| 18 | public $session_data = []; |
| 19 | |
| 20 | public $tracked_orders = []; |
| 21 | |
| 22 | /** |
| 23 | * Render public the wrap_script method. Required for the unit tests |
| 24 | * |
| 25 | * @param string $script |
| 26 | * |
| 27 | * @return string |
| 28 | * @see Base::wrap_script() |
| 29 | */ |
| 30 | public function wrap_script( $script ) { |
| 31 | return parent::wrap_script( $script ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Render public the wrap_script method. Required for the unit tests |
| 36 | * |
| 37 | * @param [] $params |
| 38 | * |
| 39 | * @return string |
| 40 | * @see Base::make_matomo_js_tracker_call() |
| 41 | */ |
| 42 | public function make_matomo_js_tracker_call( $params ) { |
| 43 | return parent::make_matomo_js_tracker_call( $params ); |
| 44 | } |
| 45 | |
| 46 | protected function should_track_background() { |
| 47 | return $this->should_track_background; |
| 48 | } |
| 49 | |
| 50 | protected function get_tracking_calls_in_session() { |
| 51 | return $this->session_data['ajax_calls']; |
| 52 | } |
| 53 | |
| 54 | protected function add_tracking_calls_to_session( $data ) { |
| 55 | $this->session_data['ajax_calls'][] = $data; |
| 56 | } |
| 57 | |
| 58 | protected function remove_tracking_calls_in_session() { |
| 59 | $this->session_data['ajax_calls'] = []; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @return bool |
| 64 | */ |
| 65 | public function supports_delayed_tracking() { |
| 66 | return $this->supports_delayed_tracking; |
| 67 | } |
| 68 | |
| 69 | public function set_order_been_tracked( $order_id ) { |
| 70 | $this->tracked_orders[] = $order_id; |
| 71 | } |
| 72 | |
| 73 | public function has_order_been_tracked_already( $order_id ) { |
| 74 | return in_array( $order_id, $this->tracked_orders, true ); |
| 75 | } |
| 76 | } |
| 77 |