From 0425652d8e1232521d07a25ba149d57a23f432f6 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:04:06 +0200 Subject: [PATCH] Added: testCreateGoalRequest --- src/Admin/Provisioning.php | 2 +- tests/integration/Admin/ProvisioningTest.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Admin/Provisioning.php b/src/Admin/Provisioning.php index 3c64aeb6..20bf95f1 100644 --- a/src/Admin/Provisioning.php +++ b/src/Admin/Provisioning.php @@ -167,7 +167,7 @@ public function maybe_create_goals( $old_settings, $settings ) { * * @return GoalCreateRequestCustomEvent|GoalCreateRequestPageview|GoalCreateRequestRevenue */ - private function create_goal_request( $name, $type = 'CustomEvent', $currency = '', $path = '' ) { + public function create_goal_request( $name, $type = 'CustomEvent', $currency = '', $path = '' ) { $props = [ 'goal' => [ 'event_name' => $name, diff --git a/tests/integration/Admin/ProvisioningTest.php b/tests/integration/Admin/ProvisioningTest.php index a21d9928..aeed673b 100644 --- a/tests/integration/Admin/ProvisioningTest.php +++ b/tests/integration/Admin/ProvisioningTest.php @@ -103,4 +103,24 @@ public function testCreateGoals() { delete_option( 'plausible_analytics_enhanced_measurements_goal_ids' ); } + + /** + * @see Provisioning::create_goal_request() + * @return void + */ + public function testCreateGoalRequest() { + $class = new Provisioning( false ); + + $pageview = $class->create_goal_request( 'Test Pageview', 'Pageview', null, '/test' ); + + $this->assertInstanceOf( 'Plausible\Analytics\WP\Client\Model\GoalCreateRequestPageview', $pageview ); + + $revenue = $class->create_goal_request( 'Test Revenue', 'Revenue', 'EUR' ); + + $this->assertInstanceOf( 'Plausible\Analytics\WP\Client\Model\GoalCreateRequestRevenue', $revenue ); + + $custom_event = $class->create_goal_request( 'Test Custom Event' ); + + $this->assertInstanceOf( 'Plausible\Analytics\WP\Client\Model\GoalCreateRequestCustomEvent', $custom_event ); + } }