public function send($email, $name = null, array $variables = array()) { /** @var $mailqueue Codex_Xtest_Xtest_Helper_Mailqueue */ $mailqueue = Xtest::getXtest('xtest/helper_mailqueue'); $mailqueue->addMail($this, $email, $name, $variables); return true; }
/** * @return Codex_Xtest_Xtest_Fixture_Quote */ public function getFixtureQuote() { if (!$this->quote) { /** @var $quote */ $this->quote = Xtest::getXtest('xtest/fixture_quote'); } return $this->quote; }
/** * Do not Queue empty recipients */ public function testThrowExceptionBecauseEmptyRecipient() { $this->setExpectedMageException('Codex_Xtest', Codex_Xtest_Exception::EMPTY_MAIL_RECIPIENT); $customerFixture = Xtest::getXtest('xtest/fixture_customer'); /** @var $customer Mage_Customer_Model_Customer */ $customer = $customerFixture->getTest(); $customer->setEmail(''); $customer->sendNewAccountEmail(); }
/** * @param null $title */ public function takeResponsiveScreenshots($title = null) { if (!$title) { $title = $this->title(); } $sizes = Xtest::getArg('breakpoints', $this->getSeleniumConfig('screenshot/breakpoints')); foreach (explode(',', $sizes) as $size) { list($w, $h) = explode('x', $size); $this->resizeBrowserWindow((int) $w, (int) $h); $this->takeScreenshot($title . ' w' . $w); } }
public function setCustomerAsLoggedIn($customer = null) { if ($customer === null) { /** @var $customerFixture Codex_Xtest_Xtest_Fixture_Customer */ $customerFixture = Xtest::getXtest('xtest/fixture_customer'); $customer = $customerFixture->getTest(); $customer->setConfirmation(null); $customer->save(); } Mage::getSingleton('customer/session')->setCustomer($customer); Mage::dispatchEvent('customer_login', array('customer' => $customer)); return $this; }
protected function body() { $questions = $this->getParams('questions'); if ($questions === null || $questions === '') { return $this->death(StringID::ChooseAtLeastOneQuestion); // Put this in front to have a more specific, comprehensible error message } $inputs = array('description' => 'isNotEmpty', 'count' => 'isNonNegativeInt', 'questions' => 'isNotEmpty'); if (!$this->isInputValid($inputs)) { return false; } $description = $this->getParams('description'); $count = $this->getParams('count'); $questions = $this->getParams('questions'); $questionsArray = explode(',', $questions); $visibleQuestions = CommonQueries::GetQuestionsVisibleToActiveUser(); /** * @var $lecture \Lecture */ $lecture = null; foreach ($visibleQuestions as $vq) { $qId = $vq->getId(); $index = array_search($qId, $questionsArray); if ($index !== false) { array_splice($questionsArray, $index, 1); if ($lecture === null) { $lecture = $vq->getLecture(); } elseif ($lecture->getId() !== $vq->getLecture()->getId()) { return $this->death(StringID::TestCannotContainQuestionsOfDifferentLectures); } } } if (count($questionsArray)) { return $this->stop(ErrorCause::invalidInput('Following question IDs are invalid or inaccessible: ' . implode(', ', $questionsArray) . '.', 'questions')); } if ($lecture === null) { return $this->death(StringID::ChooseAtLeastOneQuestion); } if (!$this->checkTestGenerationPrivileges($lecture->getId())) { return $this->death(StringID::InsufficientPrivileges); } $randomized = $this->generateTest($questions, $count); $xtest = new \Xtest(); $xtest->setDescription($description); $xtest->setCount($count); $xtest->setLecture($lecture); $xtest->setTemplate($questions); $xtest->setGenerated(implode(',', $randomized)); Repositories::persistAndFlush($xtest); return true; }
/** * Parse input arguments * * @return Mage_Shell_Abstract */ protected function _parseArgs() { self::$args = array(); $current = null; foreach ($_SERVER['argv'] as $arg) { $match = array(); if (preg_match('#^--([\\w\\d_-]{1,})$#', $arg, $match) || preg_match('#^-([\\w\\d_]{1,})$#', $arg, $match)) { $current = $match[1]; self::$args[$current] = true; } else { if ($current) { self::$args[$current] = $arg; } else { if (preg_match('#^([\\w\\d_]{1,})$#', $arg, $match)) { self::$args[$match[1]] = true; } } } } return $this; }
protected function runTest() { try { return parent::runTest(); } catch (Exception $e) { if (Xtest::getArg('debug')) { echo PHP_EOL . "got '" . $e->getMessage() . "' exception. press any key to continue.." . PHP_EOL; ob_end_flush(); fgets(STDIN); } throw $e; } }
protected function setUp() { parent::setUp(); Xtest::initAdmin(); }
public function testDoubleParameter() { $this->assertEquals('Mage_Catalog_Test_Double_Model_Product', get_class(Mage::getModel('catalog/product'))); Xtest::getConfig()->setDisableDoubles(true); $this->assertEquals('Mage_Catalog_Model_Product', get_class(Mage::getModel('catalog/product'))); }
protected function assertMailTemplateIdSent($templateId) { /** @var $mailqueue Codex_Xtest_Xtest_Helper_Mailqueue */ $mailqueue = Xtest::getXtest('xtest/helper_mailqueue'); $templateIds = array(); foreach ($mailqueue->getQueue() as $queueItem) { $templateIds[] = $queueItem['object']->getId(); } $this->assertTrue(in_array($templateId, $templateIds), "{$templateId} is not send: " . join(',', $templateIds)); }