Skip to content

Commit

Permalink
Update tests for v3.2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
taledo committed May 25, 2018
1 parent 0231c84 commit 07850e1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
25 changes: 25 additions & 0 deletions tests/csrest_lists_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 4 additions & 2 deletions tests/csrest_segments_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down
19 changes: 13 additions & 6 deletions tests/csrest_subscribers_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]',
'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 = '[email protected]';
Expand All @@ -53,7 +56,8 @@ function testupdate() {
$subscriber = array (
'Email' => '[email protected]',
'Name' => 'Widget Man!',
'CustomFields' => array(array(1,2), array(3,4))
'CustomFields' => array(array(1,2), array(3,4)),
'ConsentToTrack' => 'unchanged',
);

$transport_result = array (
Expand Down Expand Up @@ -86,12 +90,14 @@ function testimport() {
array (
'Email' => '[email protected]',
'Name' => 'Widget Man!',
'CustomFields' => array(array(1,2), array(3,4))
'CustomFields' => array(array(1,2), array(3,4)),
'ConsentToTrack' => 'no',
),
array (
'Email' => '[email protected]',
'Name' => 'Widget Man!',
'CustomFields' => array(array(1,2), array(3,4))
'CustomFields' => array(array(1,2), array(3,4)),
'ConsentToTrack' => 'yes',
)
);

Expand Down Expand Up @@ -124,9 +130,10 @@ function testget() {
$deserialised = array(1,2,34,5);
$response_code = 200;
$email = '[email protected]';
$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,
Expand All @@ -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);
}
Expand Down

0 comments on commit 07850e1

Please sign in to comment.