Esempio n. 1
0
 /**
  * Return the list of the available tests or a single test if a test id
  * is provide
  *
  * @return mixed
  */
 public static function getTests($test_id = null)
 {
     return Litmus_Test::getTests($test_id);
 }
Esempio n. 2
0
 /**
  * Implemet the pages/create ane emails/create methods to ceate a new web
  * page test or a new email test.
  *
  * @param string $test_type Type of the test (TYPE_PAGE||TYPE_EMAIL)
  * @param array $params Parameters of the test
  * @return Litmus_Test
  */
 public static function create($test_type, $params)
 {
     $dom = new DomDocument('1.0', null);
     $root = $dom->createElement('test_set');
     $dom->appendChild($root);
     // application element
     $applications = $dom->createElement('applications');
     $type = $dom->createAttribute('type');
     $type->appendChild($dom->createTextNode('array'));
     $applications->appendChild($type);
     $root->appendChild($applications);
     if (isset($params['applications'])) {
         foreach ($params['applications'] as $app) {
             $app_node = $dom->createElement('application');
             $code_node = $dom->createElement('code', $app);
             $app_node->appendChild($code_node);
             $applications->appendChild($app_node);
         }
     }
     // url node
     if (isset($params['url'])) {
         $node = $dom->createElement('url', $params['url']);
         $root->appendChild($node);
     }
     // save defaults node
     $node = $dom->createElement('save_defaults', isset($params['save_defaults']) && $params['save_defaults'] ? 'true' : 'false');
     $root->appendChild($node);
     // use defaults node
     $node = $dom->createElement('use_defaults', isset($params['use_defaults']) && $params['use_defaults'] ? 'true' : 'false');
     $root->appendChild($node);
     if (isset($params['email_source'])) {
         $email_node = $dom->createElement('email_source');
         $root->appendChild($email_node);
         $node = $dom->createElement('body');
         $data = $dom->createCDATASection($params['email_source']['body']);
         $node->appendChild($data);
         $email_node->appendChild($node);
         $node = $dom->createElement('subject', $params['email_source']['subject']);
         $email_node->appendChild($node);
     }
     $request = $dom->saveXML();
     $rc = Litmus_RESTful_Client::singleton();
     $res = $rc->post($test_type . '.xml', $request);
     $test = Litmus_Test::load($res);
     return $test;
 }