assertTrue( false !== strpos( $url, 'test=test' ) ); return array( 'response' => 200, 'status_code' => 200, 'success' => 1, 'body' => '{}', ); }, 10, 3 ); add_filter( 'woocommerce_explat_request_args', function( $args ) { $args['test'] = 'test'; return $args; }, 10, 1 ); $exp = new Experimental_Abtest( 'anon', 'platform', true ); $exp->get_variation( 'control' ); } /** * Tests retrieve the test variation when consent is false */ public function test_get_variation_return_control_when_no_consent() { $exp = new Experimental_Abtest( 'anon', 'platform', false ); $this->assertEquals( $exp->get_variation( 'test_experiment_name' ), 'control' ); } /** * Tests retrieve the test variation when consent is false */ public function test_get_variation() { delete_transient( 'abtest_variation_control' ); add_filter( 'pre_http_request', function( $preempt, $parsed_args, $url ) { return array( 'response' => 200, 'status_code' => 200, 'success' => 1, 'body' => '{ "variations": { "test_experiment_name": "treatment" } }', ); }, 10, 3 ); $exp = new Experimental_Abtest( 'anon', 'platform', true ); $this->assertEquals( $exp->get_variation( 'test_experiment_name' ), 'treatment' ); } }