tidy-up - remove duplicate array keys
[civicrm-core.git] / tests / phpunit / api / v3 / MailingTest.php
index c185da7571cb4b9597f06dea18047cca3086e249..c95fe661f73dc81483dba01c56a7cc123af44674 100755 (executable)
@@ -79,10 +79,23 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     // BEGIN SAMPLE DATA
     $groupIDs['a'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group'));
     $groupIDs['b'] = $this->groupCreate(array('name' => 'Example exclude group', 'title' => 'Example exclude group'));
-    $contactIDs['a'] = $this->individualCreate(array('email' => 'include.me@example.org', 'first_name' => 'Includer', 'last_name' => 'Person'));
-    $contactIDs['b'] = $this->individualCreate(array('email' => 'exclude.me@example.org', 'last_name' => 'Excluder', 'last_name' => 'Excluder'));
-    $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['a'], 'contact_id' => $contactIDs['a']));
-    $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['b'], 'contact_id' => $contactIDs['b']));
+    $contactIDs['a'] = $this->individualCreate(array(
+        'email' => 'include.me@example.org',
+        'first_name' => 'Includer',
+        'last_name' => 'Person'
+      ));
+    $contactIDs['b'] = $this->individualCreate(array(
+        'email' => 'exclude.me@example.org',
+        'last_name' => 'Excluder'
+      ));
+    $this->callAPISuccess('GroupContact', 'create', array(
+        'group_id' => $groupIDs['a'],
+        'contact_id' => $contactIDs['a']
+      ));
+    $this->callAPISuccess('GroupContact', 'create', array(
+        'group_id' => $groupIDs['b'],
+        'contact_id' => $contactIDs['b']
+      ));
     // END SAMPLE DATA
 
     // ** Pass 1: Create
@@ -163,11 +176,27 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     // BEGIN SAMPLE DATA
     $groupIDs['inc'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group'));
     $groupIDs['exc'] = $this->groupCreate(array('name' => 'Example exclude group', 'title' => 'Example exclude group'));
-    $contactIDs['includeme'] = $this->individualCreate(array('email' => 'include.me@example.org', 'first_name' => 'Includer', 'last_name' => 'Person'));
-    $contactIDs['excludeme'] = $this->individualCreate(array('email' => 'exclude.me@example.org', 'last_name' => 'Excluder', 'last_name' => 'Excluder'));
-    $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['includeme']));
-    $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['excludeme']));
-    $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['exc'], 'contact_id' => $contactIDs['excludeme']));
+    $contactIDs['includeme'] = $this->individualCreate(array(
+        'email' => 'include.me@example.org',
+        'first_name' => 'Includer',
+        'last_name' => 'Person'
+      ));
+    $contactIDs['excludeme'] = $this->individualCreate(array(
+        'email' => 'exclude.me@example.org',
+          'last_name' => 'Excluder',
+      ));
+    $this->callAPISuccess('GroupContact', 'create', array(
+        'group_id' => $groupIDs['inc'],
+        'contact_id' => $contactIDs['includeme']
+      ));
+    $this->callAPISuccess('GroupContact', 'create', array(
+        'group_id' => $groupIDs['inc'],
+        'contact_id' => $contactIDs['excludeme']
+      ));
+    $this->callAPISuccess('GroupContact', 'create', array(
+        'group_id' => $groupIDs['exc'],
+        'contact_id' => $contactIDs['excludeme']
+      ));
 
     $params = $this->_params;
     $params['groups']['include'] = array($groupIDs['inc']);
@@ -206,7 +235,11 @@ class api_v3_MailingTest extends CiviUnitTestCase {
   }
 
   public function testMailerSendTest_email() {
-    $contactIDs['alice'] = $this->individualCreate(array('email' => 'alice@example.org', 'first_name' => 'Alice', 'last_name' => 'Person'));
+    $contactIDs['alice'] = $this->individualCreate(array(
+        'email' => 'alice@example.org',
+        'first_name' => 'Alice',
+        'last_name' => 'Person'
+      ));
 
     $mail = $this->callAPISuccess('mailing', 'create', $this->_params);
 
@@ -224,12 +257,33 @@ class api_v3_MailingTest extends CiviUnitTestCase {
   public function testMailerSendTest_group() {
     // BEGIN SAMPLE DATA
     $groupIDs['inc'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group'));
-    $contactIDs['alice'] = $this->individualCreate(array('email' => 'alice@example.org', 'first_name' => 'Alice', 'last_name' => 'Person'));
-    $contactIDs['bob'] = $this->individualCreate(array('email' => 'bob@example.org', 'first_name' => 'Bob', 'last_name' => 'Person'));
-    $contactIDs['carol'] = $this->individualCreate(array('email' => 'carol@example.org', 'first_name' => 'Carol', 'last_name' => 'Person'));
-    $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['alice']));
-    $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['bob']));
-    $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['carol']));
+    $contactIDs['alice'] = $this->individualCreate(array(
+        'email' => 'alice@example.org',
+        'first_name' => 'Alice',
+        'last_name' => 'Person'
+      ));
+    $contactIDs['bob'] = $this->individualCreate(array(
+        'email' => 'bob@example.org',
+        'first_name' => 'Bob',
+        'last_name' => 'Person'
+      ));
+    $contactIDs['carol'] = $this->individualCreate(array(
+        'email' => 'carol@example.org',
+        'first_name' => 'Carol',
+        'last_name' => 'Person'
+      ));
+    $this->callAPISuccess('GroupContact', 'create', array(
+        'group_id' => $groupIDs['inc'],
+        'contact_id' => $contactIDs['alice']
+      ));
+    $this->callAPISuccess('GroupContact', 'create', array(
+        'group_id' => $groupIDs['inc'],
+        'contact_id' => $contactIDs['bob']
+      ));
+    $this->callAPISuccess('GroupContact', 'create', array(
+        'group_id' => $groupIDs['inc'],
+        'contact_id' => $contactIDs['carol']
+      ));
     // END SAMPLE DATA
 
     $mail = $this->callAPISuccess('mailing', 'create', $this->_params);
@@ -247,6 +301,9 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     $this->assertEquals(array('alice@example.org', 'bob@example.org', 'carol@example.org'), $deliveredEmails);
   }
 
+  /**
+   * @return array
+   */
   public function submitProvider() {
     $cases = array(); // $useLogin, $params, $expectedFailure, $expectedJobCount
     $cases[] = array(
@@ -315,7 +372,7 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     $mail = $this->callAPISuccess('mailing', 'create', $this->_params);
     $params = array('mailing_id' => $mail['id'], 'test_email' => NULL, 'test_group' => $this->_groupID);
     $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params);
-    $deliveredIds  = implode(',', array_keys($deliveredInfo['values']));
+    $deliveredIds = implode(',', array_keys($deliveredInfo['values']));
 
     //Change the test mail into live
     $sql = "UPDATE civicrm_mailing_job SET is_test = 0 WHERE mailing_id = {$mail['id']}";
@@ -354,12 +411,13 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
     );
     $this->checkArrayEquals($expectedResult, $result['values'][$mail['id']]);
   }
+
   /**
    * Test civicrm_mailing_delete
    */
   public function testMailerDeleteSuccess() {
     $result = $this->callAPISuccess($this->_entity, 'create', $this->_params);
-    $jobs = $this->callAPIAndDocument($this->_entity, 'delete', array('id' => $result['id']), __FUNCTION__, __FILE__);
+    $this->callAPIAndDocument($this->_entity, 'delete', array('id' => $result['id']), __FUNCTION__, __FILE__);
     $this->assertAPIDeleted($this->_entity, $result['id']);
   }
 
@@ -381,7 +439,7 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
       'body' => 'Body...',
       'time_stamp' => '20111109212100',
     );
-    $result = $this->callAPIFailure('mailing_event', 'bounce', $params,
+    $this->callAPIFailure('mailing_event', 'bounce', $params,
       'Queue event could not be found'
     );
   }
@@ -402,7 +460,7 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
       'event_subscribe_id' => '123',
       'time_stamp' => '20111111010101',
     );
-    $result = $this->callAPIFailure('mailing_event', 'confirm', $params,
+    $this->callAPIFailure('mailing_event', 'confirm', $params,
       'Confirmation failed'
     );
   }
@@ -425,7 +483,7 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
       'replyTo' => $this->_email,
       'time_stamp' => '20111111010101',
     );
-    $result = $this->callAPIFailure('mailing_event', 'reply', $params,
+    $this->callAPIFailure('mailing_event', 'reply', $params,
       'Queue event could not be found'
     );
   }
@@ -447,7 +505,7 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
       'email' => $this->_email,
       'time_stamp' => '20111111010101',
     );
-    $result = $this->callAPIFailure('mailing_event', 'forward', $params,
+    $this->callAPIFailure('mailing_event', 'forward', $params,
       'Queue event could not be found'
     );
   }