Skip to content

Commit

Permalink
Removed: testCreateWooCommerceGoals, because it's no longer needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan0sz committed Jun 7, 2024
1 parent 1033128 commit 74250ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 65 deletions.
4 changes: 3 additions & 1 deletion src/Admin/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ private function create_goals( $goals ) {
* @param $settings
*
* @return void
*
* @codeCoverageIgnore Because we don't want to test the API.
*/
public function maybe_create_woocommerce_funnels( $old_settings, $settings ) {
if ( ! Helpers::is_enhanced_measurement_enabled( 'revenue', $settings[ 'enhanced_measurements' ] ) || ! Integrations::is_wc_active() ) {
Expand Down Expand Up @@ -261,7 +263,7 @@ public function maybe_create_woocommerce_funnels( $old_settings, $settings ) {
*
* @return void
*
* @codeCoverageIgnore Because this method should be mocked in tests.
* @codeCoverageIgnore Because this method should be mocked in tests if needed.
*/
private function create_funnel( $name, $steps ) {
$create_request = new Client\Model\FunnelCreateRequest(
Expand Down
64 changes: 0 additions & 64 deletions tests/integration/Admin/ProvisioningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,68 +103,4 @@ public function testCreateGoals() {

delete_option( 'plausible_analytics_enhanced_measurements_goal_ids' );
}

/**
* @see Provisioning::maybe_create_woocommerce_funnels()
* @return void
* @throws ApiException
*/
public function testCreateWooCommerceGoals() {
$settings = [
'enhanced_measurements' => [
'revenue',
],
];
$mock = $this->getMockBuilder( Client::class )->onlyMethods( [ 'create_goals' ] )->getMock();
$goals_array = [
new Goal(
[
'goal' => new GoalPageviewAllOfGoal( [ 'display_name' => 'Add Item To Cart', 'id' => 112, 'path' => null ] ),
'goal_type' => 'Goal.CustomEvent',
]
),
new Goal(
[
'goal' => new GoalPageviewAllOfGoal( [ 'display_name' => 'Remove Cart Item', 'id' => 223, 'path' => null ] ),
'goal_type' => 'Goal.CustomEvent',
]
),
new Goal(
[
'goal' => new GoalPageviewAllOfGoal( [ 'display_name' => 'Entered Checkout', 'id' => 334, 'path' => null ] ),
'goal_type' => 'Goal.CustomEvent',
]
),
new Goal(
[
'goal' => new GoalPageviewAllOfGoal( [ 'display_name' => 'Purchase', 'id' => 445, 'path' => null ] ),
'goal_type' => 'Goal.Revenue',
]
),
];
$goals = new Client\Model\GoalListResponse();

$goals->setGoals( $goals_array );
$goals->setMeta( new Client\Model\GoalListResponseMeta() );
$mock->method( 'create_goals' )->willReturn( $goals );

$class = new Provisioning( $mock );

add_filter( 'plausible_analytics_integrations_woocommerce', '__return_true' );
when( 'get_woocommerce_currency' )->justReturn( 'EUR' );

$class->maybe_create_woocommerce_funnels( [], $settings );

remove_filter( 'plausible_analytics_integrations_woocommerce', '__return_true' );

$goal_ids = get_option( 'plausible_analytics_enhanced_measurements_goal_ids' );

$this->assertCount( 4, $goal_ids );
$this->assertArrayHasKey( 112, $goal_ids );
$this->assertArrayHasKey( 223, $goal_ids );
$this->assertArrayHasKey( 334, $goal_ids );
$this->assertArrayHasKey( 445, $goal_ids );

delete_option( 'plausible_analytics_enhanced_measurements_goal_ids' );
}
}

0 comments on commit 74250ec

Please sign in to comment.