diff --git a/uc_stock/tests/uc_stock.test b/uc_stock/tests/uc_stock.test index 47fa7a1..35fa09c 100644 --- a/uc_stock/tests/uc_stock.test +++ b/uc_stock/tests/uc_stock.test @@ -21,11 +21,12 @@ class UbercartStockTestCase extends UbercartTestHelper { protected function setUp($modules = array(), $permissions = array()) { parent::setUp(array('uc_stock'), array('administer product stock')); $this->drupalLogin($this->adminUser); + $this->product = $this->createProduct(array('uid' => $this->adminUser->uid, 'title' => $this->randomName(8) . '&><"')); } public function testProductStock() { $this->drupalGet('node/' . $this->product->nid . '/edit/stock'); - $this->assertText($this->product->title); + $this->assertText(check_plain($this->product->title)); $this->assertText($this->product->model, 'Product SKU found.'); $this->assertNoFieldChecked('edit-stock-0-active', 'Stock tracking is not active.'); diff --git a/uc_store/classes/mail.inc b/uc_store/classes/mail.inc index 0c78630..20e5b81 100644 --- a/uc_store/classes/mail.inc +++ b/uc_store/classes/mail.inc @@ -25,3 +25,23 @@ class UbercartMailSystem extends DefaultMailSystem { } } + +/** + * A mail sending implementation that captures sent messages to a variable. + * + * This class is for running tests or for development. + */ +class UbercartTestingMailSystem extends UbercartMailSystem implements MailSystemInterface { + /** + * Accept an e-mail message and store it in a variable. + * + * @param $message + * An e-mail message. + */ + public function mail(array $message) { + $captured_emails = variable_get('drupal_test_email_collector', array()); + $captured_emails[] = $message; + variable_set('drupal_test_email_collector', $captured_emails); + return TRUE; + } +} diff --git a/uc_store/tests/uc_store.test b/uc_store/tests/uc_store.test index 709974b..7e386bd 100644 --- a/uc_store/tests/uc_store.test +++ b/uc_store/tests/uc_store.test @@ -57,6 +57,22 @@ class UbercartTestHelper extends DrupalWebTestCase { // Create a test product. $this->product = $this->createProduct(array('uid' => $this->adminUser->uid)); + + // Use the Ubercart test mail class instead of the default test mail class + // for all Ubercart modules. + variable_set('mail_system', + array_merge( + variable_get('mail_system', array('default-system' => 'DefaultMailSystem')), + array( + 'uc_cart' => 'UbercartTestingMailSystem', + 'uc_order' => 'UbercartTestingMailSystem', + 'uc_file' => 'UbercartTestingMailSystem', + 'uc_roles' => 'UbercartTestingMailSystem', + 'uc_stock' => 'UbercartTestingMailSystem', + 'uc_store' => 'UbercartTestingMailSystem', + ) + ) + ); } /**