Skip to content
Permalink
Browse files

Reduce db traffic

  • Loading branch information...
flack committed Oct 5, 2019
1 parent 1da0e91 commit f6e48a947b753c18213f8b18cbf2b3d158607483
Showing with 173 additions and 168 deletions.
  1. +5 −12 test/org/openpsa/directmarketing/__helper/campaign.php
  2. +1 −1 test/org/openpsa/directmarketing/campaign/messageTest.php
  3. +8 −4 test/org/openpsa/directmarketing/handler/campaign/adminTest.php
  4. +1 −1 test/org/openpsa/directmarketing/handler/campaign/campaignTest.php
  5. +8 −4 test/org/openpsa/directmarketing/handler/campaign/rulesTest.php
  6. +1 −1 test/org/openpsa/directmarketing/handler/exportTest.php
  7. +10 −8 test/org/openpsa/directmarketing/handler/importTest.php
  8. +11 −8 test/org/openpsa/directmarketing/handler/loggerTest.php
  9. +9 −6 test/org/openpsa/directmarketing/handler/message/adminTest.php
  10. +8 −4 test/org/openpsa/directmarketing/handler/message/composeTest.php
  11. +1 −1 test/org/openpsa/directmarketing/handler/message/createTest.php
  12. +1 −1 test/org/openpsa/directmarketing/handler/message/listTest.php
  13. +10 −6 test/org/openpsa/directmarketing/handler/message/reportTest.php
  14. +8 −4 test/org/openpsa/directmarketing/handler/message/sendTest.php
  15. +1 −1 test/org/openpsa/directmarketing/handler/message/viewTest.php
  16. +10 −8 test/org/openpsa/directmarketing/handler/subscriberTest.php
  17. +2 −3 test/org/openpsa/invoices/invoice/itemTest.php
  18. +17 −14 test/org/openpsa/invoices/schedulerRunTest.php
  19. +2 −2 test/org/openpsa/invoices/schedulerTest.php
  20. +12 −9 test/org/openpsa/projects/taskTest.php
  21. +3 −9 test/org/openpsa/sales/calculator/defaultTest.php
  22. +1 −9 test/org/openpsa/sales/handler/deliverable/addTest.php
  23. +0 −1 test/org/openpsa/sales/handler/deliverable/listTest.php
  24. +11 −20 test/org/openpsa/sales/handler/viewTest.php
  25. +32 −31 test/org/openpsa/sales/salesproject/deliverableTest.php
@@ -13,17 +13,10 @@
*/
class openpsa_test_campaign_helper
{
private $_testcase;
private $_campaign;
private $_member;
private $_message;
public function __construct(openpsa_testcase $testcase)
{
$this->_testcase = $testcase;
}
public function get_campaign($type = org_openpsa_directmarketing_campaign_dba::TYPE_NORMAL)
{
if (!$this->_campaign) {
@@ -33,7 +26,7 @@ public function get_campaign($type = org_openpsa_directmarketing_campaign_dba::T
'node' => $topic->id,
'orgOpenpsaObtype' => $type
];
$this->_campaign = $this->_testcase->create_object(org_openpsa_directmarketing_campaign_dba::class, $attributes);
$this->_campaign = openpsa_testcase::create_class_object(org_openpsa_directmarketing_campaign_dba::class, $attributes);
}
return $this->_campaign;
@@ -47,7 +40,7 @@ public function get_member(midcom_db_person $person)
'campaign' => $campaign->id,
'person' => $person->id
];
$this->_member = $this->_testcase->create_object(org_openpsa_directmarketing_campaign_member_dba::class, $parameters);
$this->_member = openpsa_testcase::create_class_object(org_openpsa_directmarketing_campaign_member_dba::class, $parameters);
}
return $this->_member;
}
@@ -61,7 +54,7 @@ public function get_log(org_openpsa_directmarketing_campaign_message_dba $messag
'token' => __CLASS__ . __FUNCTION__,
'target' => 'http://openpsa2.org'
];
return $this->_testcase->create_object(org_openpsa_directmarketing_link_log_dba::class, $parameters);
return openpsa_testcase::create_class_object(org_openpsa_directmarketing_link_log_dba::class, $parameters);
}
public function get_receipt(org_openpsa_directmarketing_campaign_message_dba $message, midcom_db_person $person)
@@ -73,7 +66,7 @@ public function get_receipt(org_openpsa_directmarketing_campaign_message_dba $me
'token' => __CLASS__ . __FUNCTION__,
'orgOpenpsaObtype' => org_openpsa_directmarketing_campaign_messagereceipt_dba::SENT
];
return $this->_testcase->create_object(org_openpsa_directmarketing_campaign_messagereceipt_dba::class, $parameters);
return openpsa_testcase::create_class_object(org_openpsa_directmarketing_campaign_messagereceipt_dba::class, $parameters);
}
public function get_message()
@@ -83,7 +76,7 @@ public function get_message()
$parameters = [
'campaign' => $campaign->id,
];
$this->_message = $this->_testcase->create_object(org_openpsa_directmarketing_campaign_message_dba::class, $parameters);
$this->_message = openpsa_testcase::create_class_object(org_openpsa_directmarketing_campaign_message_dba::class, $parameters);
}
return $this->_message;
}
@@ -15,7 +15,7 @@ class org_openpsa_directmarketing_campaign_messageTest extends openpsa_testcase
{
public function testCRUD()
{
$helper = new openpsa_test_campaign_helper($this);
$helper = new openpsa_test_campaign_helper;
$campaign = $helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -15,15 +15,20 @@ class org_openpsa_directmarketing_handler_campaign_adminTest extends openpsa_tes
{
protected static $_person;
/**
* @var openpsa_test_campaign_helper
*/
private static $helper;
public static function setUpBeforeClass()
{
self::$_person = self::create_user(true);
self::$helper = new openpsa_test_campaign_helper;
}
public function testHandler_edit()
{
$helper = new openpsa_test_campaign_helper($this);
$campaign = $helper->get_campaign();
$campaign = self::$helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -35,8 +40,7 @@ public function testHandler_edit()
public function testHandler_delete()
{
$helper = new openpsa_test_campaign_helper($this);
$campaign = $helper->get_campaign();
$campaign = self::$helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -22,7 +22,7 @@ public static function setUpBeforeClass()
public function testHandler_view()
{
$helper = new openpsa_test_campaign_helper($this);
$helper = new openpsa_test_campaign_helper;
$campaign = $helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -15,15 +15,20 @@ class org_openpsa_directmarketing_handler_campaign_rulesTest extends openpsa_tes
{
protected static $_person;
/**
* @var openpsa_test_campaign_helper
*/
private static $helper;
public static function setUpBeforeClass()
{
self::$_person = self::create_user(true);
self::$helper = new openpsa_test_campaign_helper;
}
public function testHandler_edit_query()
{
$helper = new openpsa_test_campaign_helper($this);
$campaign = $helper->get_campaign(org_openpsa_directmarketing_campaign_dba::TYPE_SMART);
$campaign = self::$helper->get_campaign(org_openpsa_directmarketing_campaign_dba::TYPE_SMART);
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -40,8 +45,7 @@ public function testHandler_edit_query()
public function testHandler_query()
{
$helper = new openpsa_test_campaign_helper($this);
$campaign = $helper->get_campaign(org_openpsa_directmarketing_campaign_dba::TYPE_SMART);
$campaign = self::$helper->get_campaign(org_openpsa_directmarketing_campaign_dba::TYPE_SMART);
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -22,7 +22,7 @@ public static function setUpBeforeClass()
public function testHandler_csv()
{
$helper = new openpsa_test_campaign_helper($this);
$helper = new openpsa_test_campaign_helper;
$campaign = $helper->get_campaign();
$helper->get_member(self::$_person);
@@ -15,15 +15,20 @@ class org_openpsa_directmarketing_handler_importTest extends openpsa_testcase
{
protected static $_person;
/**
* @var openpsa_test_campaign_helper
*/
private static $helper;
public static function setUpBeforeClass()
{
self::$_person = self::create_user(true);
self::$helper = new openpsa_test_campaign_helper;
}
public function testHandler_index()
{
$helper = new openpsa_test_campaign_helper($this);
$campaign = $helper->get_campaign();
$campaign = self::$helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -35,8 +40,7 @@ public function testHandler_index()
public function testHandler_simpleemails()
{
$helper = new openpsa_test_campaign_helper($this);
$campaign = $helper->get_campaign();
$campaign = self::$helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -69,8 +73,7 @@ public function testHandler_simpleemails()
public function testHandler_csv_select()
{
$helper = new openpsa_test_campaign_helper($this);
$campaign = $helper->get_campaign();
$campaign = self::$helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -81,8 +84,7 @@ public function testHandler_csv_select()
public function testHandler_vcards()
{
$helper = new openpsa_test_campaign_helper($this);
$campaign = $helper->get_campaign();
$campaign = self::$helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -15,15 +15,20 @@ class org_openpsa_directmarketing_handler_loggerTest extends openpsa_testcase
{
protected static $_person;
/**
* @var openpsa_test_campaign_helper
*/
private static $helper;
public static function setUpBeforeClass()
{
self::$_person = self::create_user(true);
self::$helper = new openpsa_test_campaign_helper;
}
public function testHandler_bounce()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
$token = uniqid();
$this->create_object(org_openpsa_directmarketing_campaign_messagereceipt_dba::class, [
'token' => $token,
@@ -42,10 +47,9 @@ public function testHandler_bounce()
public function testHandler_link()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
$token = uniqid();
$receipt = $this->create_object(org_openpsa_directmarketing_campaign_messagereceipt_dba::class, [
$this->create_object(org_openpsa_directmarketing_campaign_messagereceipt_dba::class, [
'token' => $token,
'orgOpenpsaObtype' => org_openpsa_directmarketing_campaign_messagereceipt_dba::SENT,
'message' => $message->id
@@ -74,10 +78,9 @@ public function testHandler_link()
public function testHandler_redirect()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
$token = 'a' . uniqid();
$receipt = $this->create_object(org_openpsa_directmarketing_campaign_messagereceipt_dba::class, [
$this->create_object(org_openpsa_directmarketing_campaign_messagereceipt_dba::class, [
'token' => $token,
'orgOpenpsaObtype' => org_openpsa_directmarketing_campaign_messagereceipt_dba::SENT,
'message' => $message->id
@@ -15,15 +15,20 @@ class org_openpsa_directmarketing_handler_message_adminTest extends openpsa_test
{
protected static $_person;
/**
* @var openpsa_test_campaign_helper
*/
private static $helper;
public static function setUpBeforeClass()
{
self::$_person = self::create_user(true);
self::$helper = new openpsa_test_campaign_helper;
}
public function testHandler_edit()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -35,8 +40,7 @@ public function testHandler_edit()
public function testHandler_copy()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -48,8 +52,7 @@ public function testHandler_copy()
public function testHandler_delete()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -15,15 +15,20 @@ class org_openpsa_directmarketing_handler_message_composeTest extends openpsa_te
{
protected static $_person;
/**
* @var openpsa_test_campaign_helper
*/
private static $helper;
public static function setUpBeforeClass()
{
self::$_person = self::create_user(true);
self::$helper = new openpsa_test_campaign_helper;
}
public function testHandler_compose()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -35,8 +40,7 @@ public function testHandler_compose()
public function testHandler_compose4person()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -22,7 +22,7 @@ public static function setUpBeforeClass()
public function testHandler_create()
{
$helper = new openpsa_test_campaign_helper($this);
$helper = new openpsa_test_campaign_helper;
$campaign = $helper->get_campaign();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -22,7 +22,7 @@ public static function setUpBeforeClass()
public function testHandler_list()
{
$helper = new openpsa_test_campaign_helper($this);
$helper = new openpsa_test_campaign_helper;
$campaign = $helper->get_campaign();
$helper->get_message();
@@ -15,17 +15,22 @@ class org_openpsa_directmarketing_handler_message_reportTest extends openpsa_tes
{
protected static $_person;
/**
* @var openpsa_test_campaign_helper
*/
private static $helper;
public static function setUpBeforeClass()
{
self::$_person = self::create_user(true);
self::$helper = new openpsa_test_campaign_helper;
}
public function testHandler_report()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$helper->get_log($message, self::$_person);
$helper->get_receipt($message, self::$_person);
$message = self::$helper->get_message();
self::$helper->get_log($message, self::$_person);
self::$helper->get_receipt($message, self::$_person);
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');
@@ -36,8 +41,7 @@ public function testHandler_report()
public function testHandler_status()
{
$helper = new openpsa_test_campaign_helper($this);
$message = $helper->get_message();
$message = self::$helper->get_message();
midcom::get()->auth->request_sudo('org.openpsa.directmarketing');

0 comments on commit f6e48a9

Please sign in to comment.
You can’t perform that action at this time.