Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/383957 )
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment 9fa46538d Fix Omnimailing.load job to bypass creating recipients & to use internal replace, add test. Change-Id: I924a1d028ebaaa33879bdb74b8e817b8247481d6 --- D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberGetTest.php D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberLoadTest.php D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailBaseTestClass.php D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailingGetTest.php D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailingLoadTest.php D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientGetTest.php D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientLoadTest.php D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientProcessUnsubscribesTest.php D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/AggregateGetResponse1.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/AuthenticateResponse.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/ExportListResponse.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/GetMailingTemplateResponse.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/GetMailingTemplateResponse2.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/JobStatusCompleteResponse.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/JobStatusWaitingResponse.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/MailingGetResponse1.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.csv D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/RawRecipientDataExportResponse.txt D sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/bootstrap.php 20 files changed, 0 insertions(+), 1,404 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/57/383957/1 diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberGetTest.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberGetTest.php deleted file mode 100644 index 0509181..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberGetTest.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php - -use Civi\Test\EndToEndInterface; -use Civi\Test\HookInterface; -use Civi\Test\TransactionalInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\Response; -require_once __DIR__ . '/OmnimailBaseTestClass.php'; - -/** - * FIXME - Add test description. - * - * Tips: - * - With HookInterface, you may implement CiviCRM hooks directly in the test class. - * Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar). - * - With TransactionalInterface, any data changes made by setUp() or test****() functions will - * rollback automatically -- as long as you don't manipulate schema or truncate tables. - * If this test needs to manipulate schema or truncate tables, then either: - * a. Do all that using setupHeadless() and Civi\Test. - * b. Disable TransactionalInterface, and handle all setup/teardown yourself. - * - * @group e2e - */ -class OmnigroupmemberGetTest extends OmnimailBaseTestClass implements EndToEndInterface, TransactionalInterface { - - public function setUpHeadless() { - // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). - // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md - return \Civi\Test::e2e() - ->installMe(__DIR__) - ->apply(); - } - - public function tearDown() { - parent::tearDown(); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnigroupmemberGet() { - $client = $this->setupSuccessfulDownloadClient(); - - $result = civicrm_api3('Omnigroupmember', 'get', array('mail_provider' => 'Silverpop', 'username' => 'Shrek', 'password' => 'Fiona', 'options' => array('limit' => 3), 'client' => $client, 'group_identifier' => 123)); - $this->assertEquals(3, $result['count']); - $this->assertEquals('e...@example.com', $result['values'][0]['email']); - $this->assertEquals('', $result['values'][0]['contact_id']); - $this->assertEquals(TRUE, $result['values'][0]['is_opt_out']); - $this->assertEquals('2016-10-18 20:01:00', $result['values'][0]['opt_in_date']); - $this->assertEquals('2017-07-04 11:11:00', $result['values'][0]['opt_out_date']); - $this->assertEquals('Added by WebForms', $result['values'][0]['opt_in_source']); - $this->assertEquals('Opt out via email opt out.', $result['values'][0]['opt_out_source']); - $this->assertEquals('clever place', $result['values'][2]['source']); - $this->assertEquals('US', $result['values'][2]['country']); - $this->assertEquals('en', $result['values'][2]['language']); - $this->assertEquals('07/04/17', $result['values'][2]['created_date']); - } - - - /** - * @return \GuzzleHttp\Client - */ - protected function setupSuccessfulDownloadClient() { - $responses = array( - file_get_contents(__DIR__ . '/Responses/ExportListResponse.txt'), - file_get_contents(__DIR__ . '/Responses/JobStatusCompleteResponse.txt'), - ); - copy(__DIR__ . '/Responses/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', sys_get_temp_dir() . '/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv'); - fopen(sys_get_temp_dir() . '/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv.complete', 'c'); - $this->createSetting('omnimail_omnigroupmembers_load', array('Silverpop' => array('last_timestamp' => '1487890800'))); - - $client = $this->getMockRequest($responses); - return $client; - } -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberLoadTest.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberLoadTest.php deleted file mode 100644 index a2a9876..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberLoadTest.php +++ /dev/null @@ -1,296 +0,0 @@ -<?php - -use Civi\Test\EndToEndInterface; -use Civi\Test\HookInterface; -use Civi\Test\TransactionalInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\Response; -require_once __DIR__ . '/OmnimailBaseTestClass.php'; - -/** - * FIXME - Add test description. - * - * Tips: - * - With HookInterface, you may implement CiviCRM hooks directly in the test class. - * Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar). - * - With TransactionalInterface, any data changes made by setUp() or test****() functions will - * rollback automatically -- as long as you don't manipulate schema or truncate tables. - * If this test needs to manipulate schema or truncate tables, then either: - * a. Do all that using setupHeadless() and Civi\Test. - * b. Disable TransactionalInterface, and handle all setup/teardown yourself. - * - * @group e2e - */ -class OmnigroupmemberLoadTest extends OmnimailBaseTestClass implements EndToEndInterface, TransactionalInterface { - - public function setUpHeadless() { - // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). - // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md - return \Civi\Test::e2e() - ->installMe(__DIR__) - ->apply(); - } - - public function tearDown() { - parent::tearDown(); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnigroupmemberLoad() { - $client = $this->setupSuccessfulDownloadClient(); - $group = civicrm_api3('Group', 'create', array('name' => 'Omnimailers', 'title' => 'Omni')); - - civicrm_api3('Omnigroupmember', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Shrek', 'password' => 'Fiona', 'options' => array('limit' => 3), 'client' => $client, 'group_identifier' => 123, 'group_id' => $group['id'])); - $groupMembers = civicrm_api3('GroupContact', 'get', array('group_id' => $group['id'])); - $this->assertEquals(3, $groupMembers['count']); - $contacts = $this->getGroupMemberDetails($groupMembers); - $this->assertEquals('fr_FR', $contacts['values'][0]['preferred_language']); - $this->assertEquals('e...@example.com', $contacts['values'][0]['email']); - $this->assertEquals('France', $contacts['values'][0]['country']); - $this->assertEquals(1, $contacts['values'][0]['is_opt_out']); - $this->assertEquals('Silverpop Added by WebForms 10/18/16', $contacts['values'][0]['contact_source']); - - $this->assertEquals('Silverpop clever place 07/04/17', $contacts['values'][2]['contact_source']); - $this->cleanupGroup($group); - } - - /** - * Example: Test that offset is respected. - */ - public function testOmnigroupmemberLoadOffset() { - $client = $this->setupSuccessfulDownloadClient(); - $group = civicrm_api3('Group', 'create', array('name' => 'Omnimailers', 'title' => 'Omni')); - - civicrm_api3('Omnigroupmember', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Shrek', 'password' => 'Fiona', 'options' => array('offset' => 1), 'client' => $client, 'group_identifier' => 123, 'group_id' => $group['id'])); - $groupMembers = civicrm_api3('GroupContact', 'get', array('group_id' => $group['id'])); - $this->assertEquals(2, $groupMembers['count']); - $contacts = $this->getGroupMemberDetails($groupMembers); - $this->assertEquals('sa...@example.com', $contacts['values'][0]['email']); - $this->assertEquals('l...@example.com', $contacts['values'][1]['email']); - $this->cleanupGroup($group); - } - - /** - * Example: Test that offset is respected. - */ - public function testOmnigroupmemberLoadUseOffsetSetting() { - $client = $this->setupSuccessfulDownloadClient(); - $group = civicrm_api3('Group', 'create', array('name' => 'Omnimailers', 'title' => 'Omni')); - - civicrm_api3('Omnigroupmember', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Shrek', 'password' => 'Fiona', 'options' => array('limit' => 1), 'client' => $client, 'group_identifier' => 123, 'group_id' => $group['id'])); - $groupMembers = civicrm_api3('GroupContact', 'get', array('group_id' => $group['id'])); - $this->assertEquals(1, $groupMembers['count']); - $contacts = $this->getGroupMemberDetails($groupMembers); - $this->assertEquals('e...@example.com', $contacts['values'][0]['email']); - - // Re-run. Offset is now 1 in settings & we are passing in limit =1. Sarah should be created. - $client = $this->setupSuccessfulDownloadClient(FALSE); - civicrm_api3('Omnigroupmember', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Shrek', 'password' => 'Fiona', 'options' => array('limit' => 1), 'client' => $client, 'group_identifier' => 123, 'group_id' => $group['id'])); - $groupMembers = civicrm_api3('GroupContact', 'get', array('group_id' => $group['id'])); - $this->assertEquals(2, $groupMembers['count']); - $contacts = $this->getGroupMemberDetails($groupMembers); - $this->assertEquals('sa...@example.com', $contacts['values'][1]['email']); - $this->cleanupGroup($group); - - $this->assertEquals(array( - 'last_timestamp' => '1487890800', - 'progress_end_date' => '1488495600', - 'offset' => 2, - 'retrieval_parameters' => array( - 'jobId' => '101719657', - 'filePath' => '/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', - ), - ), $this->getJobSettings()); - - } - - /** - * Test when download does not complete in time. - */ - public function testOmnigroupmemberLoadIncomplete() { - civicrm_api3('Setting', 'create', array( - 'omnimail_omnigroupmembers_load' => array( - 'Silverpop' => array('last_timestamp' => '1487890800'), - ), - )); - $responses = array( - file_get_contents(__DIR__ . '/Responses/ExportListResponse.txt'), - ); - for ($i = 0; $i < 15; $i++) { - $responses[] = file_get_contents(__DIR__ . '/Responses/JobStatusWaitingResponse.txt'); - } - civicrm_api3('setting', 'create', array('omnimail_job_retry_interval' => 0.01)); - $group = civicrm_api3('Group', 'create', array('name' => 'Omnimailers2', 'title' => 'Omni2')); - - civicrm_api3('Omnigroupmember', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Donald', 'password' => 'Duck', 'client' => $this->getMockRequest($responses), 'group_identifier' => 123, 'group_id' => $group['id'])); - - $groupMembers = civicrm_api3('GroupContact', 'get', array('group_id' => $group['id'])); - $this->assertEquals(0, $groupMembers['count']); - - $this->assertEquals(array( - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101719657', - 'filePath' => '/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', - ), - 'progress_end_date' => '1488495600', - 'offset' => 0, - ), $this->getJobSettings()); - $this->cleanupGroup($group); - } - - /** - * Test when download does not complete in time. - */ - public function testOmnigroupmemberLoadIncompleteUseSuffix() { - civicrm_api3('Setting', 'create', array( - 'omnimail_omnigroupmembers_load' => array( - 'Silverpop' . '_woot' => array('last_timestamp' => '1487890800'), - ), - )); - $responses = array( - file_get_contents(__DIR__ . '/Responses/ExportListResponse.txt'), - ); - for ($i = 0; $i < 15; $i++) { - $responses[] = file_get_contents(__DIR__ . '/Responses/JobStatusWaitingResponse.txt'); - } - civicrm_api3('setting', 'create', array('omnimail_job_retry_interval' => 0.01)); - $group = civicrm_api3('Group', 'create', array('name' => 'Omnimailers2', 'title' => 'Omni2')); - - civicrm_api3('Omnigroupmember', 'load', array( - 'mail_provider' => 'Silverpop', - 'username' => 'Donald', - 'password' => 'Duck', - 'client' => $this->getMockRequest($responses), - 'group_identifier' => 123, - 'group_id' => $group['id'], - 'job_suffix' => '_woot', - )); - - $groupMembers = civicrm_api3('GroupContact', 'get', array('group_id' => $group['id'])); - $this->assertEquals(0, $groupMembers['count']); - - $this->assertEquals(array( - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101719657', - 'filePath' => '/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', - ), - 'progress_end_date' => '1488495600', - 'offset' => 0, - ), $this->getJobSettings(array('mail_provider' => 'Silverpop', 'job_suffix' => '_woot'))); - $this->cleanupGroup($group); - } - - /** - * After completing an incomplete download the end date should be the progress end date. - */ - public function testCompleteIncomplete() { - $client = $this->setupSuccessfulDownloadClient(); - $group = civicrm_api3('Group', 'create', array('name' => 'Omnimailers3', 'title' => 'Omni3')); - civicrm_api3('setting', 'create', array( - 'omnimail_omnigroupmembers_load' => array( - 'Silverpop' => array( - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101719657', - 'filePath' => '/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', - ), - 'progress_end_date' => '1488150000', - ), - ), - )); - - civicrm_api3('Omnigroupmember', 'load', array( - 'mail_provider' => 'Silverpop', - 'username' => 'Shrek', - 'password' => 'Fiona', - 'options' => array('limit' => 3), - 'client' => $client, - 'group_identifier' => 123, - 'group_id' => $group['id'], - )); - - $groupMembers = civicrm_api3('GroupContact', 'get', array('group_id' => $group['id'])); - $this->assertEquals(3, $groupMembers['count']); - - $this->assertEquals(array( - 'last_timestamp' => '1488495600', - ), $this->getJobSettings(array('mail_provider' => 'Silverpop'))); - $this->cleanupGroup($group); - } - - /** - * Set up the mock client to emulate a successful download. - * @param bool $isUpdateSetting - * - * @return \GuzzleHttp\Client - */ - protected function setupSuccessfulDownloadClient($isUpdateSetting = TRUE) { - $responses = array( - file_get_contents(__DIR__ . '/Responses/ExportListResponse.txt'), - file_get_contents(__DIR__ . '/Responses/JobStatusCompleteResponse.txt'), - ); - copy(__DIR__ . '/Responses/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', sys_get_temp_dir() . '/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv'); - fopen(sys_get_temp_dir() . '/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv.complete', 'c'); - if ($isUpdateSetting) { - $this->createSetting('omnimail_omnigroupmembers_load', array('Silverpop' => array('last_timestamp' => '1487890800'))); - } - - $client = $this->getMockRequest($responses); - return $client; - } - - /** - * Get job settings. - * - * @param array $params - * - * @return array - */ - public function getJobSettings($params = array('mail_provider' => 'Silverpop')) { - $omnimail = new CRM_Omnimail_Omnigroupmembers($params); - return $omnimail->getJobSettings(); - } - - /** - * @param $group - */ - protected function cleanupGroup($group) { - civicrm_api3('GroupContact', 'get', array( - 'group_id' => $group['id'], - 'api.contact.delete' => array('skip_undelete' => 1), - )); - civicrm_api3('Group', 'delete', array('id' => $group['id'])); - - } - - /** - * @param $groupMembers - * @return array - */ - protected function getGroupMemberDetails($groupMembers) { - $contactIDs = array('IN' => array()); - foreach ($groupMembers['values'] as $groupMember) { - $contactIDs['IN'][] = $groupMember['contact_id']; - } - $contacts = civicrm_api3('Contact', 'get', array( - 'contact_id' => $contactIDs, - 'sequential' => 1, - 'return' => array( - 'contact_source', - 'email', - 'country', - 'created_date', - 'preferred_language', - 'is_opt_out' - ) - )); - return $contacts; - } - -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailBaseTestClass.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailBaseTestClass.php deleted file mode 100644 index 120d607..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailBaseTestClass.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -use Civi\Test\EndToEndInterface; -use Civi\Test\HookInterface; -use Civi\Test\TransactionalInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\Response; - -/** - * FIXME - Add test description. - * - * Tips: - * - With HookInterface, you may implement CiviCRM hooks directly in the test class. - * Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar). - * - With TransactionalInterface, any data changes made by setUp() or test****() functions will - * rollback automatically -- as long as you don't manipulate schema or truncate tables. - * If this test needs to manipulate schema or truncate tables, then either: - * a. Do all that using setupHeadless() and Civi\Test. - * b. Disable TransactionalInterface, and handle all setup/teardown yourself. - * - * @group e2e - */ -class OmnimailBaseTestClass extends \PHPUnit_Framework_TestCase implements EndToEndInterface, TransactionalInterface { - - public function setUp() { - parent::setUp(); - $null = NULL; - Civi::service('settings_manager')->flush(); - \Civi::$statics['_omnimail_settings'] = array(); - } - - /** - * Get mock guzzle client object. - * - * @param $body - * @param bool $authenticateFirst - * @return \GuzzleHttp\Client - */ - public function getMockRequest($body = array(), $authenticateFirst = TRUE) { - - $responses = array(); - if ($authenticateFirst) { - $responses[] = new Response(200, [], file_get_contents(__DIR__ . '/Responses/AuthenticateResponse.txt')); - } - foreach ($body as $responseBody) { - $responses[] = new Response(200, [], $responseBody); - } - $mock = new MockHandler($responses); - $handler = HandlerStack::create($mock); - return new Client(array('handler' => $handler)); - } - - - /** - * @return \GuzzleHttp\Client - */ - protected function setupSuccessfulDownloadClient() { - $responses = array( - file_get_contents(__DIR__ . '/Responses/RawRecipientDataExportResponse.txt'), - file_get_contents(__DIR__ . '/Responses/JobStatusCompleteResponse.txt'), - ); - //Raw Recipient Data Export Jul 02 2017 21-46-49 PM 758.zip - copy(__DIR__ . '/Responses/Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.csv', sys_get_temp_dir() . '/Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.csv'); - fopen(sys_get_temp_dir() . '/Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.csv.complete', 'c'); - $this->createSetting('omnimail_omnirecipient_load',array('Silverpop' => array('last_timestamp' => '1487890800'),)); - $client = $this->getMockRequest($responses); - return $client; - } - - /** - * Create a CiviCRM setting with some extra debugging if it fails. - * - * @param $setting - * @param $value - */ - protected function createSetting($setting, $value) { - try { - civicrm_api3('Setting', 'create', array( - 'debug' => 1, - $setting => $value, - )); - } catch (CiviCRM_API3_Exception $e) { - $settings = \Civi\Core\SettingsMetadata::getMetadata(); - $this->fail(print_r(array_keys($settings), 1), $e->getMessage() . $e->getTraceAsString() . print_r($e->getExtraParams(), TRUE)); - } - } -} \ No newline at end of file diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailingGetTest.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailingGetTest.php deleted file mode 100644 index 9ce2521..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailingGetTest.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -use Civi\Test\EndToEndInterface; -use Civi\Test\HookInterface; -use Civi\Test\TransactionalInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\Response; -require_once __DIR__ . '/OmnimailBaseTestClass.php'; - -/** - * FIXME - Add test description. - * - * Tips: - * - With HookInterface, you may implement CiviCRM hooks directly in the test class. - * Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar). - * - With TransactionalInterface, any data changes made by setUp() or test****() functions will - * rollback automatically -- as long as you don't manipulate schema or truncate tables. - * If this test needs to manipulate schema or truncate tables, then either: - * a. Do all that using setupHeadless() and Civi\Test. - * b. Disable TransactionalInterface, and handle all setup/teardown yourself. - * - * @group e2e - */ -class OmnimailingGetTest extends OmnimailBaseTestClass implements EndToEndInterface, TransactionalInterface { - - public function setUpHeadless() { - // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). - // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md - return \Civi\Test::e2e() - ->installMe(__DIR__) - ->apply(); - } - - public function setUp() { - parent::setUp(); - } - - public function tearDown() { - parent::tearDown(); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnimailingGet() { - $responses = array( - file_get_contents(__DIR__ . '/Responses/MailingGetResponse1.txt'), - file_get_contents(__DIR__ . '/Responses/AggregateGetResponse1.txt'), - file_get_contents(__DIR__ . '/Responses/GetMailingTemplateResponse.txt'), - file_get_contents(__DIR__ . '/Responses/GetMailingTemplateResponse2.txt'), - file_get_contents(__DIR__ . '/Responses/GetMailingTemplateResponse2.txt'), - ); - $mailings = civicrm_api3('Omnimailing', 'get', array('mail_provider' => 'Silverpop', 'client' => $this->getMockRequest($responses), 'username' => 'Donald', 'password' => 'quack')); - $this->assertEquals(2, $mailings['count']); - } - -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailingLoadTest.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailingLoadTest.php deleted file mode 100644 index 57e2c96..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailingLoadTest.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php - -use Civi\Test\EndToEndInterface; -use Civi\Test\TransactionalInterface; - -require_once __DIR__ . '/OmnimailBaseTestClass.php'; - -/** - * FIXME - Add test description. - * - * Tips: - * - With HookInterface, you may implement CiviCRM hooks directly in the test class. - * Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar). - * - With TransactionalInterface, any data changes made by setUp() or test****() functions will - * rollback automatically -- as long as you don't manipulate schema or truncate tables. - * If this test needs to manipulate schema or truncate tables, then either: - * a. Do all that using setupHeadless() and Civi\Test. - * b. Disable TransactionalInterface, and handle all setup/teardown yourself. - * - * @group e2e - */ -class OmnimailingLoadTest extends OmnimailBaseTestClass implements EndToEndInterface, TransactionalInterface { - - public function setUpHeadless() { - // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). - // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md - return \Civi\Test::e2e() - ->installMe(__DIR__) - ->apply(); - } - - public function setUp() { - parent::setUp(); - } - - public function tearDown() { - parent::tearDown(); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnimailingLoad() { - $mailings = $this->loadMailings(); - $this->assertEquals(2, $mailings['count']); - $mailing = civicrm_api3('Mailing', 'getsingle', array('hash' => 'sp7877')); - $this->assertEquals(1, $mailing['is_completed']); - - $this->loadMailings(); - - $mailingReloaded = civicrm_api3('Mailing', 'getsingle', array('hash' => 'sp7877')); - - $this->assertEquals($mailingReloaded['id'], $mailing['id']); - $mailingJobs = civicrm_api3('MailingJob', 'get', array('mailing_id' => $mailing['id'])); - $this->assertEquals(0, $mailingJobs['count']); - - } - - /** - * @return array - */ - protected function loadMailings() { - $responses = array( - file_get_contents(__DIR__ . '/Responses/MailingGetResponse1.txt'), - file_get_contents(__DIR__ . '/Responses/AggregateGetResponse1.txt'), - file_get_contents(__DIR__ . '/Responses/GetMailingTemplateResponse.txt'), - file_get_contents(__DIR__ . '/Responses/GetMailingTemplateResponse2.txt'), - file_get_contents(__DIR__ . '/Responses/GetMailingTemplateResponse2.txt'), - ); - $mailings = civicrm_api3('Omnimailing', 'load', array( - 'mail_provider' => 'Silverpop', - 'client' => $this->getMockRequest($responses), - 'username' => 'Donald', - 'password' => 'quack' - )); - return $mailings; - } - -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientGetTest.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientGetTest.php deleted file mode 100644 index b04204e..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientGetTest.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php - -use Civi\Test\EndToEndInterface; -use Civi\Test\HookInterface; -use Civi\Test\TransactionalInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\Response; -require_once __DIR__ . '/OmnimailBaseTestClass.php'; - -/** - * FIXME - Add test description. - * - * Tips: - * - With HookInterface, you may implement CiviCRM hooks directly in the test class. - * Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar). - * - With TransactionalInterface, any data changes made by setUp() or test****() functions will - * rollback automatically -- as long as you don't manipulate schema or truncate tables. - * If this test needs to manipulate schema or truncate tables, then either: - * a. Do all that using setupHeadless() and Civi\Test. - * b. Disable TransactionalInterface, and handle all setup/teardown yourself. - * - * @group e2e - */ -class OmnirecipientGetTest extends OmnimailBaseTestClass implements EndToEndInterface, TransactionalInterface { - - public function setUpHeadless() { - // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). - // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md - return \Civi\Test::e2e() - ->installMe(__DIR__) - ->apply(); - } - - public function setUp() { - parent::setUp(); - } - - public function tearDown() { - parent::tearDown(); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnirecipientGet() { - $client = $this->setupSuccessfulDownloadClient(); - - $result = civicrm_api3('Omnirecipient', 'get', array('mail_provider' => 'Silverpop', 'username' => 'Shrek', 'password' => 'Fiona', 'options' => array('limit' => 3), 'client' => $client)); - $this->assertEquals(3, $result['count']); - $this->assertEquals('b...@example.com', $result['values'][0]['email']); - $this->assertEquals('123', $result['values'][0]['contact_id']); - } - -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientLoadTest.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientLoadTest.php deleted file mode 100644 index ef7b939..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientLoadTest.php +++ /dev/null @@ -1,307 +0,0 @@ -<?php - -use Civi\Test\EndToEndInterface; -use Civi\Test\HookInterface; -use Civi\Test\TransactionalInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\Response; -require_once __DIR__ . '/OmnimailBaseTestClass.php'; - -/** - * FIXME - Add test description. - * - * Tips: - * - With HookInterface, you may implement CiviCRM hooks directly in the test class. - * Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar). - * - With TransactionalInterface, any data changes made by setUp() or test****() functions will - * rollback automatically -- as long as you don't manipulate schema or truncate tables. - * If this test needs to manipulate schema or truncate tables, then either: - * a. Do all that using setupHeadless() and Civi\Test. - * b. Disable TransactionalInterface, and handle all setup/teardown yourself. - * - * @group e2e - */ -class OmnirecipientLoadTest extends OmnimailBaseTestClass implements EndToEndInterface, TransactionalInterface { - - public function setUpHeadless() { - // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). - // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md - return \Civi\Test::e2e() - ->installMe(__DIR__) - ->apply(); - } - - public function setUp() { - parent::setUp(); - } - - public function tearDown() { - CRM_Core_DAO::executeQuery('DELETE FROM civicrm_mailing_provider_data'); - parent::tearDown(); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnirecipientLoad() { - $client = $this->setupSuccessfulDownloadClient(); - - civicrm_api3('Omnirecipient', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Donald', 'password' => 'Duck', 'debug' => 1, 'client' => $client)); - $providers = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_mailing_provider_data')->fetchAll(); - $this->assertEquals(array( - 0 => array( - 'contact_identifier' => '126312673126', - 'mailing_identifier' => '54132674', - 'email' => 'sa...@example.com', - 'event_type' => 'Open', - 'recipient_action_datetime' => '2017-06-30 23:32:00', - 'contact_id' => '', - 'is_civicrm_updated' => '0', - ), - 1 => array( - 'contact_identifier' => '15915939159', - 'mailing_identifier' => '54132674', - 'email' => 'cl...@example.com', - 'event_type' => 'Open', - 'recipient_action_datetime' => '2017-06-30 23:32:00', - 'contact_id' => '', - 'is_civicrm_updated' => '0', - ), - 2 => array( - 'contact_identifier' => '248248624848', - 'mailing_identifier' => '54132674', - 'email' => 'b...@example.com', - 'event_type' => 'Open', - 'recipient_action_datetime' => '2017-06-30 23:32:00', - 'contact_id' => '123', - 'is_civicrm_updated' => '0', - ), - 3 => array( - 'contact_identifier' => '508505678505', - 'mailing_identifier' => '54132674', - 'email' => 'st...@example.com', - 'event_type' => 'Open', - 'recipient_action_datetime' => '2017-07-01 17:28:00', - 'contact_id' => '456', - 'is_civicrm_updated' => '0', - ), - ), $providers); - $this->assertEquals(array ('last_timestamp' => '1488495600'), $this->getJobSettings()); - - } - - /** - * Test for no errors when using 'insert_batch_size' parameter. - * - * It's hard to test that it does batch, but at least we can check it - * succeeds. - */ - public function testOmnirecipientLoadIncreasedBatchInsert() { - $client = $this->setupSuccessfulDownloadClient(); - - civicrm_api3('Omnirecipient', 'load', array( - 'mail_provider' => 'Silverpop', - 'username' => 'Donald', - 'password' => 'Duck', - 'debug' => 1, - 'client' => $client, - 'insert_batch_size' => 4, - )); - $this->assertEquals(4, CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_mailing_provider_data')); - } - - /** - * Test for no errors when using 'insert_batch_size' parameter. - * - * It's hard to test that it does batch, but at least we can check it - * succeeds. - */ - public function testOmnirecipientLoadIncreasedBatchInsertExceedsAvailable() { - $client = $this->setupSuccessfulDownloadClient(); - - civicrm_api3('Omnirecipient', 'load', array( - 'mail_provider' => 'Silverpop', - 'username' => 'Donald', - 'password' => 'Duck', - 'debug' => 1, - 'client' => $client, - 'insert_batch_size' => 6, - )); - $this->assertEquals(4, CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_mailing_provider_data')); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnirecipientLoadLimitAndOffset() { - $client = $this->setupSuccessfulDownloadClient(); - - civicrm_api3('Omnirecipient', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Donald', 'password' => 'Duck', 'debug' => 1, 'client' => $client, 'options' => array('limit' => 2, 'offset' => 1))); - $providers = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_mailing_provider_data')->fetchAll(); - $this->assertEquals(array( - 0 => array( - 'contact_identifier' => '126312673126', - 'mailing_identifier' => '54132674', - 'email' => 'sa...@example.com', - 'event_type' => 'Open', - 'recipient_action_datetime' => '2017-06-30 23:32:00', - 'contact_id' => '', - 'is_civicrm_updated' => '0', - ), - 1 => array( - 'contact_identifier' => '15915939159', - 'mailing_identifier' => '54132674', - 'email' => 'cl...@example.com', - 'event_type' => 'Open', - 'recipient_action_datetime' => '2017-06-30 23:32:00', - 'contact_id' => '', - 'is_civicrm_updated' => '0', - ), - ), $providers); - - $this->assertEquals(array( - 'last_timestamp' => '1487890800', - 'progress_end_date' => '1488495600', - 'offset' => 3, - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip' - ), - ), $this->getJobSettings()); - - } - - /** - * Test when download does not complete in time. - */ - public function testOmnirecipientLoadIncomplete() { - civicrm_api3('Setting', 'create', array( - 'omnimail_omnirecipient_load' => array( - 'Silverpop' => array('last_timestamp' => '1487890800'), - ), - )); - $responses = array( - file_get_contents(__DIR__ . '/Responses/RawRecipientDataExportResponse.txt'), - ); - for ($i = 0; $i < 15; $i++) { - $responses[] = file_get_contents(__DIR__ . '/Responses/JobStatusWaitingResponse.txt'); - } - civicrm_api3('setting', 'create', array('omnimail_job_retry_interval' => 0.01)); - civicrm_api3('Omnirecipient', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Donald', 'password' => 'Duck', 'client' => $this->getMockRequest($responses))); - $this->assertEquals(0, CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_mailing_provider_data')); - - $this->assertEquals(array( - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip', - ), - 'progress_end_date' => '1488495600', - ), $this->getJobSettings()); - } - - /** - * After completing an incomplete download the end date should be the progress end date. - */ - public function testCompleteIncomplete() { - $client = $this->setupSuccessfulDownloadClient(); - civicrm_api3('setting', 'create', array( - 'omnimail_omnirecipient_load' => array( - 'Silverpop' => array( - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip', - ), - 'progress_end_date' => '1488495600', - ), - ), - )); - - civicrm_api3('Omnirecipient', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Donald', 'password' => 'Duck', 'client' => $client)); - $this->assertEquals(4, CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_mailing_provider_data')); - $this->assertEquals(array( - 'last_timestamp' => '1488495600', - ), $this->getJobSettings(array('mail_provider' => 'Silverpop'))); - } - - /** - * Test the suffix works for multiple jobs.. - */ - public function testCompleteIncompleteUseSuffix() { - $client = $this->setupSuccessfulDownloadClient(); - civicrm_api3('setting', 'create', array( - 'omnimail_omnirecipient_load' => array( - 'Silverpop_woot' => array( - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip', - ), - 'progress_end_date' => '1488495600', - ), - 'Silverpop' => array('last_timestamp' => '1487890800'), - ), - )); - $settings = $this->getJobSettings(array('mail_provider' => 'Silverpop')); - - civicrm_api3('Omnirecipient', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Donald', 'password' => 'Duck', 'client' => $client, 'job_suffix' => '_woot')); - $this->assertEquals(4, CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_mailing_provider_data')); - $this->assertEquals(array( - 'last_timestamp' => '1488495600', - ), $this->getJobSettings(array('mail_provider' => 'Silverpop', 'job_suffix' => '_woot'))); - - $this->assertEquals($settings, $this->getJobSettings(array('mail_provider' => 'Silverpop'))); - } - - - /** - * An exception should be thrown if the download is incomplete & we pass in a timestamp. - * - * This is because the incomplete download will continue, and we will incorrectly - * think it is taking our parameters. - * - */ - public function testIncompleteRejectTimestamps() { - civicrm_api3('setting', 'create', array( - 'omnimail_omnirecipient_load' => array( - 'Silverpop' => array( - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip', - ), - 'progress_end_date' => '1488495600', - ), - ), - )); - try { - civicrm_api3('Omnirecipient', 'load', array( - 'mail_provider' => 'Silverpop', - 'start_date' => 'last week', - 'username' => 'Donald', - 'password' => 'Duck', - 'client' => $this->getMockRequest(array()) - )); - } - catch (Exception $e) { - $this->assertEquals('A prior retrieval is in progress. Do not pass in dates to complete a retrieval', $e->getMessage()); - return; - } - $this->fail('No exception'); - } - - /** - * Get job settings. - * - * @param array $params - * - * @return array - */ - public function getJobSettings($params = array('mail_provider' => 'Silverpop')) { - $omnimail = new CRM_Omnimail_Omnirecipients($params); - return $omnimail->getJobSettings(); - } -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientProcessUnsubscribesTest.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientProcessUnsubscribesTest.php deleted file mode 100644 index cac739d..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientProcessUnsubscribesTest.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php - -use Civi\Test\EndToEndInterface; -use Civi\Test\HookInterface; -use Civi\Test\TransactionalInterface; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\Response; -require_once __DIR__ . '/OmnimailBaseTestClass.php'; - -/** - * FIXME - Add test description. - * - * Tips: - * - With HookInterface, you may implement CiviCRM hooks directly in the test class. - * Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar). - * - With TransactionalInterface, any data changes made by setUp() or test****() functions will - * rollback automatically -- as long as you don't manipulate schema or truncate tables. - * If this test needs to manipulate schema or truncate tables, then either: - * a. Do all that using setupHeadless() and Civi\Test. - * b. Disable TransactionalInterface, and handle all setup/teardown yourself. - * - * @group e2e - */ -class OmnirecipientProcessUnsubscribesTest extends OmnimailBaseTestClass implements EndToEndInterface, TransactionalInterface { - - /** - * IDs of contacts created for the test. - * - * @var array - */ - protected $contactIDs = array(); - - public function setUpHeadless() { - // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). - // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md - return \Civi\Test::e2e() - ->installMe(__DIR__) - ->apply(); - } - - public function setUp() { - parent::setUp(); - Civi::service('settings_manager')->flush(); - $contact = civicrm_api3('Contact', 'create', array('first_name' => 'Charles', 'last_name' => 'Darwin', 'contact_type' => 'Individual')); - $this->contactIDs[] = $contact['id']; - $contact = civicrm_api3('Contact', 'create', array('first_name' => 'Charlie', 'last_name' => 'Darwin', 'contact_type' => 'Individual', 'api.email.create' => array('is_bulkmail' => 1, 'email' => 'char...@example.com'))); - $this->contactIDs[] = $contact['id']; - - $contact = civicrm_api3('Contact', 'create', array('first_name' => 'Marie', 'last_name' => 'Currie', 'contact_type' => 'Individual')); - $this->contactIDs[] = $contact['id']; - $contact = civicrm_api3('Contact', 'create', array('first_name' => 'Isaac', 'last_name' => 'Newton', 'contact_type' => 'Individual')); - $this->contactIDs[] = $contact['id']; - } - - public function tearDown() { - parent::tearDown(); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnirecipientProcessUnsubscribes() { - - $this->createMailingProviderData(); - civicrm_api3('Omnirecipient', 'process_unsubscribes', array('mail_provider' => 'Silverpop')); - $data = civicrm_api3('MailingProviderData', 'get', array('sequential' => 1)); - $this->assertEquals(1, $data['values'][0]['is_civicrm_updated']); - $contact = civicrm_api3('Contact', 'getsingle', array('id' => $this->contactIDs[0])); - $this->assertEquals(1, $contact['is_opt_out']); - $email = civicrm_api3('Email', 'getsingle', array('email' => 'char...@example.com')); - $this->assertEquals(0, $email['is_bulkmail']); - $activity = civicrm_api3('Activity', 'getsingle', array('contact_id' => $this->contactIDs[0])); - $this->assertEquals('Unsubscribed via Silverpop', $activity['subject']); - - $contact = civicrm_api3('Contact', 'getsingle', array('id' => $this->contactIDs[2])); - $this->assertEquals(0, $contact['is_opt_out']); - - $contact = civicrm_api3('Contact', 'getsingle', array('id' => $this->contactIDs[3])); - $this->assertEquals(1, $contact['is_opt_out']); - - } - - public function createMailingProviderData() { - civicrm_api3('Campaign', 'create', array('name' => 'xyz', 'title' => 'Cool Campaign')); - civicrm_api3('Mailing', 'create', array('campaign_id' => 'xyz', 'hash' => 'xyz', 'name' => 'Mail')); - civicrm_api3('MailingProviderData', 'create', array( - 'contact_id' => $this->contactIDs[0], - 'email' => 'char...@example.com', - 'event_type' => 'Opt Out', - 'mailing_identifier' => 'xyz', - 'recipient_action_datetime' => '2017-02-02', - 'contact_identifier' => 'a', - )); - civicrm_api3('MailingProviderData', 'create', array( - 'contact_id' => $this->contactIDs[2], - 'event_type' => 'Open', - 'mailing_identifier' => 'xyz', - 'recipient_action_datetime' => '2017-03-03', - 'contact_identifier' => 'b', - )); - civicrm_api3('MailingProviderData', 'create', array( - 'contact_id' => $this->contactIDs[3], - 'event_type' => 'Suppressed', - 'mailing_identifier' => 'xyuuuz', - 'recipient_action_datetime' => '2017-04-04', - 'contact_identifier' => 'c', - )); - } - -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv deleted file mode 100644 index b3e791d..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv +++ /dev/null @@ -1,4 +0,0 @@ -Email,Opt In Date,Opted Out,Opt In Details,Email Type,Opted Out Date,Opt Out Details,ContactID,IsoLang,LastClickDate,LastOpenDate,LastSentDate,Segment,Segment_AOL,Segment_Newsletter,Segment_Newsletter2,SendHour,firstname,lastname,postal_code,rml_country,rml_device,rml_language,rml_phone,rml_segment,rml_source,rml_submitDate,state,timezone -e...@example.com,10/18/16 08:01 PM,T,Added by WebForms,0,07/04/17 11:11 AM,Opt out via email opt out.,,,,12/04/16,10/22/16,0,0,0,0,9,,,,FR,,fr,,35,,10/18/16,, -sa...@example.com,12/13/16 12:27 AM,T,Added by WebForms,0,07/03/17 03:34 PM,Optout by WebForms,,,,,12/24/16,0,0,0,0,0,,,,US,,en,,83,,12/12/16,, -l...@example.com,04/26/17 02:18 PM,F,Added by WebForms,0,,,,,,,,0,0,0,0,0,,,,US,,en,,28,clever place,07/04/17,, diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/AggregateGetResponse1.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/AggregateGetResponse1.txt deleted file mode 100644 index e9ae66a..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/AggregateGetResponse1.txt +++ /dev/null @@ -1,39 +0,0 @@ -<Envelope> - <Body> - <RESULT> - <SUCCESS>TRUE</SUCCESS> - <Mailing> - <MailingId>7877</MailingId> - <ReportId>6655</ReportId> - <ScheduledTS>2017-06-02 08:00:00.0</ScheduledTS> - <MailingName><![CDATA[My mailing]]></MailingName> - <ListName><![CDATA[My mailing list]]></ListName> - <ListId>266</ListId> - <ParentListId>238</ParentListId> - <UserName>Donald Duck</UserName> - <SentTS>2017-06-02 08:01:39.0</SentTS> - <NumSent>6047</NumSent> - <Subject><![CDATA[cool email]]></Subject> - <Visibility>Shared</Visibility> - <ParentTemplateId>419</ParentTemplateId> - </Mailing> - <Mailing> - <MailingId>737</MailingId> - <ReportId>841</ReportId> - <ScheduledTS>2017-06-02 08:00:00.0</ScheduledTS> - <MailingName><![CDATA[Another riveting email]]></MailingName> - <ListName><![CDATA[another list)]]></ListName> - <ListId>824</ListId> - <ParentListId>238</ParentListId> - <UserName>Mickey Mouse</UserName> - <SentTS>2017-06-02 08:02:20.0</SentTS> - <NumSent>6041</NumSent> - <Subject><![CDATA[Whatsup doc]]></Subject> - <Visibility>Shared</Visibility> - <ParentTemplateId>323</ParentTemplateId> - </Mailing> - </RESULT> - - - </Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/AuthenticateResponse.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/AuthenticateResponse.txt deleted file mode 100644 index d66a137..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/AuthenticateResponse.txt +++ /dev/null @@ -1,10 +0,0 @@ -<Envelope> -<Body> -<RESULT> -<SUCCESS>true</SUCCESS> -<SESSIONID>8C669563FE07A0118118FD6BF6C7960C</SESSIONID> -<ORGANIZATION_ID>6866f946-13a511eb673-b76467ac68f4177bd55690ce16678686</ORGANIZATION_ID> -<SESSION_ENCODING>;jsessionid=8C669563FE07A0118118FD6BF6C7960C</SESSION_ENCODING> -</RESULT> -</Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/ExportListResponse.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/ExportListResponse.txt deleted file mode 100644 index 99f0e3b..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/ExportListResponse.txt +++ /dev/null @@ -1,11 +0,0 @@ -<Envelope> -<Body> - <RESULT> -<SUCCESS>TRUE</SUCCESS> -<JOB_ID>101719657</JOB_ID> -<FILE_PATH>/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv</FILE_PATH> -</RESULT> - - - </Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/GetMailingTemplateResponse.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/GetMailingTemplateResponse.txt deleted file mode 100644 index f03a7b0..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/GetMailingTemplateResponse.txt +++ /dev/null @@ -1,64 +0,0 @@ -<Envelope> -<Body> - <RESULT> -<SUCCESS>TRUE</SUCCESS> -<Mailing> -<MailingId>724</MailingId> -<ReportId>435</ReportId> -<MailingName><![CDATA[My mail]]></MailingName> -<SentDateTime>2017-06-02 08:01:39.0</SentDateTime> -<NumSent>6047</NumSent> -<NumSeeds>17</NumSeeds> -<NumSuppressed>273</NumSuppressed> -<NumInboxMonitored>0</NumInboxMonitored> -<NumBounceHard>2</NumBounceHard> -<NumBounceSoft>45</NumBounceSoft> -<NumUniqueOpen>1891</NumUniqueOpen> -<NumGrossOpen>10908</NumGrossOpen> -<NumUniqueClick>0</NumUniqueClick> -<NumGrossClick>0</NumGrossClick> -<NumUniqueAttach>0</NumUniqueAttach> -<NumGrossAttach>0</NumGrossAttach> -<NumUniqueClickstreams>18</NumUniqueClickstreams> -<NumGrossClickstreams>31</NumGrossClickstreams> -<NumUniqueMedia>0</NumUniqueMedia> -<NumGrossMedia>0</NumGrossMedia> -<NumGrossAbuse>7</NumGrossAbuse> -<NumGrossChangeAddress>0</NumGrossChangeAddress> -<NumGrossMailBlock>5</NumGrossMailBlock> -<NumGrossMailRestriction>0</NumGrossMailRestriction> -<NumGrossOther>0</NumGrossOther> -<NumConversions>0</NumConversions> -<NumConversionAmount>0</NumConversionAmount> -<NumBounceHardFwd>0</NumBounceHardFwd> -<NumBounceSoftFwd>0</NumBounceSoftFwd> -<NumConversionAmountFwd>0</NumConversionAmountFwd> -<NumAttachOpenFwd>0</NumAttachOpenFwd> -<NumClickFwd>0</NumClickFwd> -<NumUniqueForwardFwd>0</NumUniqueForwardFwd> -<NumGrossForwardFwd>0</NumGrossForwardFwd> -<NumUniqueConversionsFwd>0</NumUniqueConversionsFwd> -<NumGrossConversionsFwd>0</NumGrossConversionsFwd> -<NumUniqueClickstreamFwd>0</NumUniqueClickstreamFwd> -<NumGrossClickstreamFwd>0</NumGrossClickstreamFwd> -<NumUniqueClickFwd>0</NumUniqueClickFwd> -<NumGrossClickFwd>0</NumGrossClickFwd> -<NumUniqueAttachOpenFwd>0</NumUniqueAttachOpenFwd> -<NumGrossAttachOpenFwd>0</NumGrossAttachOpenFwd> -<NumUniqueMediaFwd>0</NumUniqueMediaFwd> -<NumGrossMediaFwd>0</NumGrossMediaFwd> -<NumUniqueOpenFwd>0</NumUniqueOpenFwd> -<NumGrossOpenFwd>0</NumGrossOpenFwd> -<NumAbuseFwd>0</NumAbuseFwd> -<NumChangeAddressFwd>0</NumChangeAddressFwd> -<NumMailRestrictionFwd>0</NumMailRestrictionFwd> -<NumMailBlockFwd>0</NumMailBlockFwd> -<NumOtherFwd>0</NumOtherFwd> -<NumSuppressedFwd>0</NumSuppressedFwd> -<NumUnsubscribes>21</NumUnsubscribes> -</Mailing> -</RESULT> - - - </Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/GetMailingTemplateResponse2.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/GetMailingTemplateResponse2.txt deleted file mode 100644 index f03a7b0..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/GetMailingTemplateResponse2.txt +++ /dev/null @@ -1,64 +0,0 @@ -<Envelope> -<Body> - <RESULT> -<SUCCESS>TRUE</SUCCESS> -<Mailing> -<MailingId>724</MailingId> -<ReportId>435</ReportId> -<MailingName><![CDATA[My mail]]></MailingName> -<SentDateTime>2017-06-02 08:01:39.0</SentDateTime> -<NumSent>6047</NumSent> -<NumSeeds>17</NumSeeds> -<NumSuppressed>273</NumSuppressed> -<NumInboxMonitored>0</NumInboxMonitored> -<NumBounceHard>2</NumBounceHard> -<NumBounceSoft>45</NumBounceSoft> -<NumUniqueOpen>1891</NumUniqueOpen> -<NumGrossOpen>10908</NumGrossOpen> -<NumUniqueClick>0</NumUniqueClick> -<NumGrossClick>0</NumGrossClick> -<NumUniqueAttach>0</NumUniqueAttach> -<NumGrossAttach>0</NumGrossAttach> -<NumUniqueClickstreams>18</NumUniqueClickstreams> -<NumGrossClickstreams>31</NumGrossClickstreams> -<NumUniqueMedia>0</NumUniqueMedia> -<NumGrossMedia>0</NumGrossMedia> -<NumGrossAbuse>7</NumGrossAbuse> -<NumGrossChangeAddress>0</NumGrossChangeAddress> -<NumGrossMailBlock>5</NumGrossMailBlock> -<NumGrossMailRestriction>0</NumGrossMailRestriction> -<NumGrossOther>0</NumGrossOther> -<NumConversions>0</NumConversions> -<NumConversionAmount>0</NumConversionAmount> -<NumBounceHardFwd>0</NumBounceHardFwd> -<NumBounceSoftFwd>0</NumBounceSoftFwd> -<NumConversionAmountFwd>0</NumConversionAmountFwd> -<NumAttachOpenFwd>0</NumAttachOpenFwd> -<NumClickFwd>0</NumClickFwd> -<NumUniqueForwardFwd>0</NumUniqueForwardFwd> -<NumGrossForwardFwd>0</NumGrossForwardFwd> -<NumUniqueConversionsFwd>0</NumUniqueConversionsFwd> -<NumGrossConversionsFwd>0</NumGrossConversionsFwd> -<NumUniqueClickstreamFwd>0</NumUniqueClickstreamFwd> -<NumGrossClickstreamFwd>0</NumGrossClickstreamFwd> -<NumUniqueClickFwd>0</NumUniqueClickFwd> -<NumGrossClickFwd>0</NumGrossClickFwd> -<NumUniqueAttachOpenFwd>0</NumUniqueAttachOpenFwd> -<NumGrossAttachOpenFwd>0</NumGrossAttachOpenFwd> -<NumUniqueMediaFwd>0</NumUniqueMediaFwd> -<NumGrossMediaFwd>0</NumGrossMediaFwd> -<NumUniqueOpenFwd>0</NumUniqueOpenFwd> -<NumGrossOpenFwd>0</NumGrossOpenFwd> -<NumAbuseFwd>0</NumAbuseFwd> -<NumChangeAddressFwd>0</NumChangeAddressFwd> -<NumMailRestrictionFwd>0</NumMailRestrictionFwd> -<NumMailBlockFwd>0</NumMailBlockFwd> -<NumOtherFwd>0</NumOtherFwd> -<NumSuppressedFwd>0</NumSuppressedFwd> -<NumUnsubscribes>21</NumUnsubscribes> -</Mailing> -</RESULT> - - - </Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/JobStatusCompleteResponse.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/JobStatusCompleteResponse.txt deleted file mode 100644 index d16bf3e..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/JobStatusCompleteResponse.txt +++ /dev/null @@ -1,14 +0,0 @@ -<Envelope> -<Body> - <RESULT> -<SUCCESS>TRUE</SUCCESS> -<JOB_ID>101569750</JOB_ID> -<JOB_STATUS>COMPLETE</JOB_STATUS> -<JOB_DESCRIPTION>Export raw recipient data.</JOB_DESCRIPTION> -<PARAMETERS> -</PARAMETERS> -</RESULT> - - - </Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/JobStatusWaitingResponse.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/JobStatusWaitingResponse.txt deleted file mode 100644 index 726f005..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/JobStatusWaitingResponse.txt +++ /dev/null @@ -1,14 +0,0 @@ -<Envelope> -<Body> - <RESULT> -<SUCCESS>TRUE</SUCCESS> -<JOB_ID>101574812</JOB_ID> -<JOB_STATUS>WAITING</JOB_STATUS> -<JOB_DESCRIPTION>Export raw recipient data.</JOB_DESCRIPTION> -<PARAMETERS> -</PARAMETERS> -</RESULT> - - - </Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/MailingGetResponse1.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/MailingGetResponse1.txt deleted file mode 100644 index e9ae66a..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/MailingGetResponse1.txt +++ /dev/null @@ -1,39 +0,0 @@ -<Envelope> - <Body> - <RESULT> - <SUCCESS>TRUE</SUCCESS> - <Mailing> - <MailingId>7877</MailingId> - <ReportId>6655</ReportId> - <ScheduledTS>2017-06-02 08:00:00.0</ScheduledTS> - <MailingName><![CDATA[My mailing]]></MailingName> - <ListName><![CDATA[My mailing list]]></ListName> - <ListId>266</ListId> - <ParentListId>238</ParentListId> - <UserName>Donald Duck</UserName> - <SentTS>2017-06-02 08:01:39.0</SentTS> - <NumSent>6047</NumSent> - <Subject><![CDATA[cool email]]></Subject> - <Visibility>Shared</Visibility> - <ParentTemplateId>419</ParentTemplateId> - </Mailing> - <Mailing> - <MailingId>737</MailingId> - <ReportId>841</ReportId> - <ScheduledTS>2017-06-02 08:00:00.0</ScheduledTS> - <MailingName><![CDATA[Another riveting email]]></MailingName> - <ListName><![CDATA[another list)]]></ListName> - <ListId>824</ListId> - <ParentListId>238</ParentListId> - <UserName>Mickey Mouse</UserName> - <SentTS>2017-06-02 08:02:20.0</SentTS> - <NumSent>6041</NumSent> - <Subject><![CDATA[Whatsup doc]]></Subject> - <Visibility>Shared</Visibility> - <ParentTemplateId>323</ParentTemplateId> - </Mailing> - </RESULT> - - - </Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.csv b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.csv deleted file mode 100644 index 2ea59e2..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.csv +++ /dev/null @@ -1,5 +0,0 @@ -Recipient Id,Recipient Type,Mailing Id,Report Id,Campaign Id,Email,Event Type,Event Timestamp,Body Type,Content Id,Click Name,URL,Conversion Action,Conversion Detail,Conversion Amount,Suppression Reason,ContactID -248248624848,Normal,54132674,1164058778,,b...@example.com,Open,06/30/17 11:32 PM,HTML,,,,,,,,123 -126312673126,Normal,54132674,1164058778,,sa...@example.com,Open,06/30/17 11:32 PM,HTML,,,,,,,, -15915939159,Normal,54132674,1164058778,,cl...@example.com,Open,06/30/17 11:32 PM,HTML,,,,,,,, -508505678505,Normal,54132674,1164058778,,st...@example.com,Open,07/01/17 05:28 PM,HTML,,,,,,,,456 diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/RawRecipientDataExportResponse.txt b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/RawRecipientDataExportResponse.txt deleted file mode 100644 index 9a02625..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/Responses/RawRecipientDataExportResponse.txt +++ /dev/null @@ -1,13 +0,0 @@ -<Envelope> -<Body> - <RESULT> -<SUCCESS>TRUE</SUCCESS> -<MAILING> -<JOB_ID>101569750</JOB_ID> -<FILE_PATH>Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip</FILE_PATH> -</MAILING> -</RESULT> - - - </Body> -</Envelope> diff --git a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/bootstrap.php b/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/bootstrap.php deleted file mode 100644 index a98ba80..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/bootstrap.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -// checking if the file exists allows compilation elsewhere if desired. -if (file_exists( __DIR__ . '/vendor/autoload.php')) { - require_once __DIR__ . '/vendor/autoload.php'; -} -ini_set('memory_limit', '2G'); -ini_set('safe_mode', 0); -eval(cv('php:boot --level=classloader', 'phpcode')); - -/** - * Call the "cv" command. - * - * @param string $cmd - * The rest of the command to send. - * @param string $decode - * Ex: 'json' or 'phpcode'. - * @return string - * Response output (if the command executed normally). - * @throws \RuntimeException - * If the command terminates abnormally. - */ -function cv($cmd, $decode = 'json') { - $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); - $oldOutput = getenv('CV_OUTPUT'); - putenv("CV_OUTPUT=json"); - $process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__); - putenv("CV_OUTPUT=$oldOutput"); - fclose($pipes[0]); - $result = stream_get_contents($pipes[1]); - fclose($pipes[1]); - if (proc_close($process) !== 0) { - throw new RuntimeException("Command failed ($cmd):\n$result"); - } - switch ($decode) { - case 'raw': - return $result; - - case 'phpcode': - // If the last output is /*PHPCODE*/, then we managed to complete execution. - if (substr(trim($result), 0, 12) !== "/*BEGINPHP*/" || substr(trim($result), -10) !== "/*ENDPHP*/") { - throw new \RuntimeException("Command failed ($cmd):\n$result"); - } - return $result; - - case 'json': - return json_decode($result, 1); - - default: - throw new RuntimeException("Bad decoder format ($decode)"); - } -} -- To view, visit https://gerrit.wikimedia.org/r/383957 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I924a1d028ebaaa33879bdb74b8e817b8247481d6 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: deployment Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits