jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/390084 )
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment And update vendor a126d53f4 Update donation-interface for new ty message subject 79462ced1 Update English thank you letter for 2017 470ee09c7 English TY letter updates 7dcaa28f8 Use shell-safe verp when not making CiviMail records Change-Id: Ieaec47d10fd9f1f7f8ddec57bf9277fab0dbfa6e --- D sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php 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 D sites/default/civicrm/extensions/org.wikimedia.rip/tests/phpunit/CRM/RipTest.php D sites/default/civicrm/extensions/org.wikimedia.rip/tests/phpunit/bootstrap.php M vendor 24 files changed, 1 insertion(+), 1,695 deletions(-) Approvals: jenkins-bot: Verified Ejegg: Looks good to me, approved diff --git a/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php b/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php deleted file mode 100644 index 587ced2..0000000 --- a/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php +++ /dev/null @@ -1,164 +0,0 @@ -<<<<<<< HEAD (dc1b27 Revert "Update English thank you letter for 2017") -======= -<?php - -use wmf_communication\TestMailer; - -/** - * @group ThankYou - */ -class ThankYouTest extends BaseWmfDrupalPhpUnitTestCase { - - /** - * Id of the contribution created in the setup function. - * - * @var int - */ - protected $contribution_id; - protected $contact_id; - protected $old_civimail; - protected $old_civimail_rate; - protected $message; - - public function setUp() { - if ( !defined( 'WMF_UNSUB_SALT' ) ) { - define( 'WMF_UNSUB_SALT', 'abc123' ); - } - parent::setUp(); - civicrm_initialize(); - TestMailer::setup(); - $this->message = array( - 'city' => 'Somerville', - 'country' => 'US', - 'currency' => 'USD', - 'date' => time(), - 'email' => 'generousdo...@example.org', - 'first_name' => 'Test', - 'last_name' => 'Es', - 'language' => 'en', - 'gateway' => 'test_gateway', - 'gateway_txn_id' => mt_rand(), - 'gross' => '1.23', - 'payment_method' => 'cc', - 'postal_code' => '02144', - 'state_province' => 'MA', - 'street_address' => '1 Davis Square', - ); - $this->old_civimail = variable_get( 'thank_you_add_civimail_records', 'false' ); - $this->old_civimail_rate = variable_get( 'thank_you_civimail_rate', 1.0 ); - - $contribution = wmf_civicrm_contribution_message_import( $this->message ); - - $this->contact_id = $contribution['contact_id']; - $this->contribution_id = $contribution['id']; - } - - public function tearDown() { - parent::cleanUpContact( $this->contact_id ); - variable_set( 'thank_you_add_civimail_records', $this->old_civimail ); - variable_get( 'thank_you_civimail_rate', $this->old_civimail_rate ); - parent::tearDown(); - } - - /** - * FIXME: This test has to be first, because we have to make sure - * those tags exist before anyone calls the helper function, which - * stashes stuff in a function-level staticvar - * - * @throws \CiviCRM_API3_Exception - */ - public function testGetEntityTagDetail() { - $tag1 = $this->ensureTagExists( 'smurfy' ); - $tag2 = $this->ensureTagExists( 'smurfalicious' ); - - $this->callAPISuccess( - 'EntityTag', - 'create', - array( - 'entity_id' => $this->contribution_id, - 'entity_table' => 'civicrm_contribution', - 'tag_id' => 'smurfy' - ) - ); - $this->callAPISuccess( - 'EntityTag', - 'create', - array( - 'entity_id' => $this->contribution_id, - 'entity_table' => 'civicrm_contribution', - 'tag_id' => 'smurfalicious' - ) - ); - - $smurfiestTags = wmf_thank_you_get_tag_names( $this->contribution_id ); - $this->assertEquals( array( 'smurfy', 'smurfalicious' ), $smurfiestTags ); - - $this->callAPISuccess( 'Tag', 'delete', array( 'id' => $tag1 ) ); - $this->callAPISuccess( 'Tag', 'delete', array( 'id' => $tag2 ) ); - } - - public function testSendThankYou() { - variable_set( 'thank_you_add_civimail_records', 'false' ); - $result = thank_you_for_contribution( $this->contribution_id ); - $this->assertTrue( $result ); - $this->assertEquals( 1, TestMailer::countMailings() ); - $sent = TestMailer::getMailing( 0 ); - $this->assertEquals( $this->message['email'], $sent['to_address'] ); - $this->assertEquals( - "{$this->message['first_name']} {$this->message['last_name']}", - $sent['to_name'] - ); - $expectedBounce = "ty.{$this->contact_id}.{$this->contribution_id}" . - '@donate.wikimedia.org'; - $this->assertEquals( $expectedBounce, $sent['reply_to'] ); - $this->assertRegExp( '/\$ 1.23/', $sent['html'] ); - } - - public function testSendThankYouAddCiviMailActivity() { - variable_set( 'thank_you_add_civimail_records', 'true' ); - variable_set( 'thank_you_civimail_rate', 1.0 ); - $result = thank_you_for_contribution( $this->contribution_id ); - $this->assertTrue( $result ); - $activity = civicrm_api3( - 'Activity', - 'getSingle', - array( - 'contact_id' => $this->contact_id, - 'activity_type_id' => CRM_Core_PseudoConstant::getKey( - 'CRM_Activity_BAO_Activity', - 'activity_type_id', - 'Email' - ) - ) - ); - $this->assertEquals( 1, TestMailer::countMailings() ); - $sent = TestMailer::getMailing( 0 ); - $this->assertEquals( $activity['details'], $sent['html'] ); - } - - /** - * Helper function to protect test against cleanup issues. - * - * @param string $name - * @return int - */ - public function ensureTagExists( $name ) { - $tags = $this->callAPISuccess( 'EntityTag', 'getoptions', array( - 'field' => 'tag_id' - ) ); - if ( in_array( $name, $tags['values'] ) ) { - return array_search( $name, $tags['values'] ); - } - $tag = $this->callAPISuccess( - 'Tag', - 'create', - array( - 'used_for' => 'civicrm_contribution', - 'name' => $name - ) - ); - $this->callAPISuccess( 'Tag', 'getfields', array( 'cache_clear' => 1 ) ); - return $tag['id']; - } -} ->>>>>>> BRANCH (1e0dbd Merge "English TY letter updates") 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 9e3c7c7..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberGetTest.php +++ /dev/null @@ -1,79 +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 - * - * @param string $job - */ - protected function setupSuccessfulDownloadClient($job = 'omnimail_omnigroupmembers_load') { - $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(array('job' => $job, 'mailing_provider' => 'Silverpop', '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 42cc909..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnigroupmemberLoadTest.php +++ /dev/null @@ -1,297 +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' => '2017-02-23 23:00:00', - 'offset' => 2, - 'retrieval_parameters' => array( - 'jobId' => '101719657', - 'filePath' => '/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', - ), - 'progress_end_timestamp' => '2017-03-02 23:00:00', - ), $this->getUtcDateFormattedJobSettings()); - - } - - /** - * Test when download does not complete in time. - */ - public function testOmnigroupmemberLoadIncomplete() { - $this->createSetting(array( - 'job' => 'omnimail_omnigroupmembers_load', - 'mailing_provider' => 'Silverpop', - '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' => '2017-02-23 23:00:00', - 'retrieval_parameters' => array( - 'jobId' => '101719657', - 'filePath' => '/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', - ), - 'progress_end_timestamp' => '2017-03-02 23:00:00', - 'offset' => 0, - ), $this->getUtcDateFormattedJobSettings()); - $this->cleanupGroup($group); - } - - /** - * Test when download does not complete in time. - */ - public function testOmnigroupmemberLoadIncompleteUseSuffix() { - $this->createSetting(array( - 'job' => 'omnimail_omnigroupmembers_load', - 'mailing_provider' => 'Silverpop', - 'job_identifier' => '_woot', - '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_identifier' => '_woot', - )); - - $groupMembers = civicrm_api3('GroupContact', 'get', array('group_id' => $group['id'])); - $this->assertEquals(0, $groupMembers['count']); - - $this->assertEquals(array( - 'last_timestamp' => '2017-02-23 23:00:00', - 'retrieval_parameters' => array( - 'jobId' => '101719657', - 'filePath' => '/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', - ), - 'progress_end_timestamp' => '2017-03-02 23:00:00', - 'offset' => 0, - ), $this->getUtcDateFormattedJobSettings(array('mail_provider' => 'Silverpop', 'job_identifier' => '_woot'))); - $this->cleanupGroup($group); - } - - /** - * After completing an incomplete download the end date should be the progress end date. - */ - public function testCompleteIncomplete() { - $client = $this->setupSuccessfulDownloadClient(FALSE); - $group = civicrm_api3('Group', 'create', array('name' => 'Omnimailers3', 'title' => 'Omni3')); - $this->createSetting(array( - 'job' => 'omnimail_omnigroupmembers_load', - 'mailing_provider' => 'Silverpop', - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101719657', - 'filePath' => '/download/20170509_noCID - All - Jul 5 2017 06-27-45 AM.csv', - ), - 'progress_end_timestamp' => '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' => '2017-03-02 23:00:00', - ), $this->getUtcDateFormattedJobSettings(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(array('job' => 'omnimail_omnigroupmembers_load', 'mailing_provider' => 'Silverpop', '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); - $result = $omnimail->getJobSettings(); - unset($result['id'], $result['mailing_provider'], $result['job'], $result['job_identifier']); - return $result; - } - - /** - * @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 6830f14..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnimailBaseTestClass.php +++ /dev/null @@ -1,114 +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() { - civicrm_initialize(); - 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)); - } - - - /** - * Set up the mock client to imitate a success result. - * - * @param string $job - * - * @return \GuzzleHttp\Client - */ - protected function setupSuccessfulDownloadClient($job = 'omnimail_omnigroupmembers_load') { - $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(array('job' => $job, 'mailing_provider' => 'Silverpop', 'last_timestamp' => '1487890800')); - $client = $this->getMockRequest($responses); - return $client; - } - - /** - * Create a CiviCRM setting with some extra debugging if it fails. - * - * @param array $values - */ - protected function createSetting($values) { - foreach (array('last_timestamp', 'progress_end_timestamp') as $dateField) { - if (!empty($values[$dateField])) { - $values[$dateField] = gmdate('YmdHis', $values[$dateField]); - } - } - try { - civicrm_api3('OmnimailJobProgress', 'create', $values); - } - catch (CiviCRM_API3_Exception $e) { - $this->fail(print_r($values, 1), $e->getMessage() . $e->getTraceAsString() . print_r($e->getExtraParams(), TRUE)); - } - } - - /** - * Get job settings with dates rendered to UTC string. - * - * @param array $params - * - * @return array - */ - public function getUtcDateFormattedJobSettings($params = array('mail_provider' => 'Silverpop')) { - $settings = $this->getJobSettings($params); - $dateFields = array('last_timestamp', 'progress_end_timestamp'); - foreach ($dateFields as $dateField) { - if (!empty($settings[$dateField])) { - $settings[$dateField] = date('Y-m-d H:i:s', $settings[$dateField]); - } - } - return $settings; - } - -} 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 f9ca8d3..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.omnimail/tests/phpunit/OmnirecipientLoadTest.php +++ /dev/null @@ -1,309 +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'); - CRM_Core_DAO::executeQuery('DELETE FROM civicrm_omnimail_job_progress'); - parent::tearDown(); - } - - /** - * Example: Test that a version is returned. - */ - public function testOmnirecipientLoad() { - $client = $this->setupSuccessfulDownloadClient('omnimail_omnirecipient_load'); - - 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' => '2017-03-02 23:00:00'), $this->getUtcDateFormattedJobSettings()); - - } - - /** - * 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('omnimail_omnirecipient_load'); - - 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('omnimail_omnirecipient_load'); - - 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('omnimail_omnirecipient_load'); - - 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' => '2017-02-23 23:00:00', - 'progress_end_timestamp' => '2017-03-02 23:00:00', - 'offset' => 3, - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip' - ), - ), $this->getUtcDateFormattedJobSettings()); - - } - - /** - * Test when download does not complete in time. - */ - public function testOmnirecipientLoadIncomplete() { - $this->createSetting(array( - 'job' => 'omnimail_omnirecipient_load', - 'mailing_provider' => 'Silverpop', - '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' => '2017-02-23 23:00:00', - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip', - ), - 'progress_end_timestamp' => '2017-03-02 23:00:00', - ), $this->getUtcDateFormattedJobSettings()); - } - - /** - * After completing an incomplete download the end date should be the progress end date. - */ - public function testCompleteIncomplete() { - $client = $this->setupSuccessfulDownloadClient('omnimail_omnirecipient_load'); - $this->createSetting(array( - 'job' => 'omnimail_omnirecipient_load', - 'mailing_provider' => 'Silverpop', - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip', - ), - 'progress_end_timestamp' => '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' => '2017-03-02 23:00:00', - ), $this->getUtcDateFormattedJobSettings(array('mail_provider' => 'Silverpop'))); - } - - /** - * Test the suffix works for multiple jobs.. - */ - public function testCompleteIncompleteUseSuffix() { - $client = $this->setupSuccessfulDownloadClient('omnimail_omnirecipient_load'); - $this->createSetting(array( - 'job' => 'omnimail_omnirecipient_load', - 'mailing_provider' => 'Silverpop', - 'last_timestamp' => '1487890800', - )); - $this->createSetting(array( - 'job' => 'omnimail_omnirecipient_load', - 'job_identifier' => '_woot', - 'mailing_provider' => 'Silverpop', - 'last_timestamp' => '1487890800', - 'retrieval_parameters' => array( - 'jobId' => '101569750', - 'filePath' => 'Raw Recipient Data Export Jul 03 2017 00-47-42 AM 1295.zip', - ), - 'progress_end_timestamp' => '1488495600', - )); - $settings = $this->getJobSettings(array('mail_provider' => 'Silverpop')); - - civicrm_api3('Omnirecipient', 'load', array('mail_provider' => 'Silverpop', 'username' => 'Donald', 'password' => 'Duck', 'client' => $client, 'job_identifier' => '_woot')); - $this->assertEquals(4, CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_mailing_provider_data')); - $this->assertEquals(array( - 'last_timestamp' => '2017-03-02 23:00:00', - ), $this->getUtcDateFormattedJobSettings(array('mail_provider' => 'Silverpop', 'job_identifier' => '_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() { - $this->createSetting(array( - 'job' => 'omnimail_omnirecipient_load', - 'mailing_provider' => 'Silverpop', - '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); - $result = $omnimail->getJobSettings(); - unset($result['id'], $result['mailing_provider'], $result['job'], $result['job_identifier']); - return $result; - } -} 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)"); - } -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.rip/tests/phpunit/CRM/RipTest.php b/sites/default/civicrm/extensions/org.wikimedia.rip/tests/phpunit/CRM/RipTest.php deleted file mode 100644 index 0231c29..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.rip/tests/phpunit/CRM/RipTest.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -use Civi\Test\HeadlessInterface; -use Civi\Test\HookInterface; -use Civi\Test\TransactionalInterface; - -/** - * 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 headless - */ -class CRM_RipTest extends \PHPUnit_Framework_TestCase implements HeadlessInterface, 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::headless() - ->installMe(__DIR__) - ->apply(); - } - - public function setUp() { - parent::setUp(); - } - - public function tearDown() { - parent::tearDown(); - } - - /** - * Test that setting is deceased sets is_opt_out. - */ - public function testChanges() { - $ziggy = civicrm_api3('Contact', 'create', array('first_name' => 'David', 'last_name' => 'Bowie', 'contact_type' => 'Individual', 'is_deceased' => 1)); - $this->assertEquals(1, civicrm_api3('Contact', 'getvalue', array('id' => $ziggy['id'], 'return' => 'is_opt_out'))); - } - -} diff --git a/sites/default/civicrm/extensions/org.wikimedia.rip/tests/phpunit/bootstrap.php b/sites/default/civicrm/extensions/org.wikimedia.rip/tests/phpunit/bootstrap.php deleted file mode 100644 index 9de4be6..0000000 --- a/sites/default/civicrm/extensions/org.wikimedia.rip/tests/phpunit/bootstrap.php +++ /dev/null @@ -1,49 +0,0 @@ -<?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)"); - } -} diff --git a/vendor b/vendor index a59dbec..d626fd3 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit a59dbec33176d79280621e9c5dbf47382ad251dd +Subproject commit d626fd35ac242364af22cc522c37debac4e32905 -- To view, visit https://gerrit.wikimedia.org/r/390084 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ieaec47d10fd9f1f7f8ddec57bf9277fab0dbfa6e Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: deployment Gerrit-Owner: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits