From 07850e1b7a99f78dd789b1acbad22bb143849c1b Mon Sep 17 00:00:00 2001 From: Peter Vahaviolos Date: Fri, 25 May 2018 11:34:53 +1000 Subject: [PATCH] Update tests for v3.2 changes --- tests/csrest_lists_test.php | 25 +++++++++++++++++++++++++ tests/csrest_segments_test.php | 6 ++++-- tests/csrest_subscribers_test.php | 19 +++++++++++++------ 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/tests/csrest_lists_test.php b/tests/csrest_lists_test.php index 65af019..9df4a4c 100644 --- a/tests/csrest_lists_test.php +++ b/tests/csrest_lists_test.php @@ -276,6 +276,31 @@ function testget_active() { $this->assertIdentical($expected_result, $result); } + function testget_active_tracking() { + $raw_result = 'some subscribers'; + $since = '2020'; + $response_code = 200; + $deserialised = array('Subscriber 1', 'Subscriber 2'); + $tracking_pref = 'true'; + + $call_options = $this->get_call_options($this->list_base_route.'active.json?date='.$since.'&includeTrackingPreference='.$tracking_pref); + + $transport_result = array ( + 'code' => $response_code, + 'response' => $raw_result + ); + + $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code); + + $this->setup_transport_and_serialisation($transport_result, $call_options, + $deserialised, $raw_result, NULL, NULL, $response_code); + + $result = $this->wrapper->get_active_subscribers($since, null, null, null, null, true); + + $this->assertIdentical($expected_result, $result); + } + + function testget_unconfirmed_subscribers() { $raw_result = 'some subscribers'; $since = '2020'; diff --git a/tests/csrest_segments_test.php b/tests/csrest_segments_test.php index e67d3c0..c129fbf 100644 --- a/tests/csrest_segments_test.php +++ b/tests/csrest_segments_test.php @@ -120,7 +120,9 @@ function testget_segment_subscribers() { $segment_id = 'abc123'; $response_code = 200; $deserialised = array('Subscriber 1', 'Subscriber 2'); - $call_options = $this->get_call_options($this->segment_base_route.'/active.json?date='); + $tracking_pref = 'false'; + + $call_options = $this->get_call_options($this->segment_base_route.'/active.json?date=&includeTrackingPreference='.$tracking_pref); $transport_result = array ( 'code' => $response_code, @@ -132,7 +134,7 @@ function testget_segment_subscribers() { $this->setup_transport_and_serialisation($transport_result, $call_options, $deserialised, $raw_result, NULL, NULL, $response_code); - $result = $this->wrapper->get_subscribers(); + $result = $this->wrapper->get_subscribers(null, null, null, null, null, false); $this->assertIdentical($expected_result, $result); } diff --git a/tests/csrest_subscribers_test.php b/tests/csrest_subscribers_test.php index da4e6da..0483873 100644 --- a/tests/csrest_subscribers_test.php +++ b/tests/csrest_subscribers_test.php @@ -30,18 +30,21 @@ function set_up_inner() { function testadd() { $raw_result = ''; + $call_options = $this->get_call_options($this->list_base_route.'.json', 'POST'); $subscriber = array ( 'Email' => 'test@test.com', 'Name' => 'Widget Man!', - 'CustomFields' => array(array(1,2), array(3,4)) + 'CustomFields' => array(array(1,2), array(3,4)), + 'ConsentToTrack' => 'yes' ); $this->general_test_with_argument('add', $subscriber, $call_options, $raw_result, $raw_result, 'subscriber was serialised to this'); } + function testupdate() { $raw_result = ''; $email = 'test@test.com'; @@ -53,7 +56,8 @@ function testupdate() { $subscriber = array ( 'Email' => 'test2@test.com', 'Name' => 'Widget Man!', - 'CustomFields' => array(array(1,2), array(3,4)) + 'CustomFields' => array(array(1,2), array(3,4)), + 'ConsentToTrack' => 'unchanged', ); $transport_result = array ( @@ -86,12 +90,14 @@ function testimport() { array ( 'Email' => 'test@test.com', 'Name' => 'Widget Man!', - 'CustomFields' => array(array(1,2), array(3,4)) + 'CustomFields' => array(array(1,2), array(3,4)), + 'ConsentToTrack' => 'no', ), array ( 'Email' => 'test@test.com', 'Name' => 'Widget Man!', - 'CustomFields' => array(array(1,2), array(3,4)) + 'CustomFields' => array(array(1,2), array(3,4)), + 'ConsentToTrack' => 'yes', ) ); @@ -124,9 +130,10 @@ function testget() { $deserialised = array(1,2,34,5); $response_code = 200; $email = 'test@test.com'; + $tracking_pref = 'true'; $call_options = $this->get_call_options( - $this->list_base_route.'.json?email='.urlencode($email), 'GET'); + $this->list_base_route.'.json?email='.urlencode($email).'&includeTrackingPreference='.$tracking_pref, 'GET'); $transport_result = array ( 'code' => $response_code, @@ -138,7 +145,7 @@ function testget() { $this->setup_transport_and_serialisation($transport_result, $call_options, $deserialised, $raw_result, NULL, NULL, $response_code); - $result = $this->wrapper->get($email); + $result = $this->wrapper->get($email, true); $this->assertIdentical($expected_result, $result); }