Adamw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/74679


Change subject: clean up, better encapsulation of Job
......................................................................

clean up, better encapsulation of Job

Change-Id: Ifd0f7fde8d2e108fb3c7f18d504f703765da7f8f
---
M sites/all/modules/wmf_common/wmf_communication/Job.php
M sites/all/modules/wmf_common/wmf_communication/tests/Job.test
2 files changed, 17 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/79/74679/1

diff --git a/sites/all/modules/wmf_common/wmf_communication/Job.php 
b/sites/all/modules/wmf_common/wmf_communication/Job.php
index 3dd677a..1c88d14 100644
--- a/sites/all/modules/wmf_common/wmf_communication/Job.php
+++ b/sites/all/modules/wmf_common/wmf_communication/Job.php
@@ -38,6 +38,16 @@
         return $job;
     }
 
+    static function create( $templateClass ) {
+        $jobId = db_insert( 'wmf_communication_job' )
+            ->fields( array(
+                'template_class' => $templateClass,
+            ) )
+            ->execute();
+
+        return Job::getJob( $jobId );
+    }
+
     /**
      * Find all queued recipients and send letters.
      */
@@ -83,4 +93,8 @@
                 WATCHDOG_INFO );
         }
     }
+
+    function getId() {
+        return $this->id;
+    }
 }
diff --git a/sites/all/modules/wmf_common/wmf_communication/tests/Job.test 
b/sites/all/modules/wmf_common/wmf_communication/tests/Job.test
index 51d5ee0..31a4d22 100644
--- a/sites/all/modules/wmf_common/wmf_communication/tests/Job.test
+++ b/sites/all/modules/wmf_common/wmf_communication/tests/Job.test
@@ -50,14 +50,10 @@
         $contact = array_pop( $result );
         $this->contactId = $contact->id;
 
-        $this->jobId = db_insert( 'wmf_communication_job' )
-            ->fields( array(
-                'template_class' => 'TestThankyouTemplate',
-            ) )
-            ->execute();
+        $this->job = Job::create( 'TestThankyouTemplate' );
 
         Recipient::create(
-            $this->jobId,
+            $this->job->getId(),
             $this->contactId,
             array(
                 'amount' => 'EUR 22.11',
@@ -67,9 +63,7 @@
     }
 
     public function testRun() {
-        $job = Job::getJob( $this->jobId );
-        $this->assertNotNull( $job, "Got the job" );
-        $job->run();
+        $this->job->run();
 
         $mails = $this->drupalGetMails();
         $this->assertEqual( count( $mails ), 1,

-- 
To view, visit https://gerrit.wikimedia.org/r/74679
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd0f7fde8d2e108fb3c7f18d504f703765da7f8f
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to