Skip to content

Commit

Permalink
Added: testCreateGoalRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan0sz committed Jun 7, 2024
1 parent 74250ec commit 0425652
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Admin/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/Admin/ProvisioningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

0 comments on commit 0425652

Please sign in to comment.