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 ); + } }