.

SimpleTestController Class Reference
[Simpletest]

Controller for running SimpleTest unit tests. More...

Inheritance diagram for SimpleTestController:
ControllerBase IController IEventSink

List of all members.

Public Member Functions

  action_run_tests ($page_data)
  Run Tests.
  action_simpletest_send_test_mail (PageData $page_data)
  Sends two test mails to the mail admin, one containing plain text, and the other one containing HTML.
  get_routes ()
  Return array of urls which are handled by this controller.

Detailed Description

Controller for running SimpleTest unit tests.

Defines action simpletest/run, which starts the tests

Author:
Gerd Riesselmann

Definition at line 10 of file simpletest.controller.php.


Member Function Documentation

SimpleTestController::action_run_tests ( page_data  ) 

Run Tests.

Parameters:
PageData  $page_data

Definition at line 26 of file simpletest.controller.php.

00026                                                      {
00027                 ob_start();
00028                 Load::components('GyroUnitTestCase');
00029                 
00030                 // load all test classes
00031                 $suite = new TestSuite('Gyro Tests');
00032                 $base_dirs = Load::get_base_directories();
00033                 foreach($base_dirs as $dir) {
00034                         foreach (gyro_glob($dir . 'simpletests/*.test.php') as $inc) {
00035                                 $suite->addFile($inc);
00036                         }
00037                 }
00038                 
00039                 Load::directories('simpletests/mocks');
00040                 $suite->run(new DefaultReporter());
00041                 ob_flush();
00042                 exit();                 
00043         }                                                       
SimpleTestController::action_simpletest_send_test_mail ( PageData page_data  ) 

Sends two test mails to the mail admin, one containing plain text, and the other one containing HTML.

Parameters:
$page_data 

Definition at line 51 of file simpletest.controller.php.

00051                                                                               {
00052                 $err = new Status();
00053                 Load::components('mailmessage');
00054                 
00055                 // 1. TextMail
00056                 $text = 'This is a text message with ümlauts';
00057                 $mail = new MailMessage('Testmail 1 (Plain) with Ümlauts', $text, Config::get_value(Config::MAIL_ADMIN));
00058                 $err->merge($mail->send());
00059                 
00060                 // 2. HTML Mail
00061                 $text = html::h('Heading', 1) . html::p('This is a HTML message with ümlauts');
00062                 $mail = new MailMessage('Testmail 2 (HTML)', $text, Config::get_value(Config::MAIL_ADMIN), '', MailMessage::MIME_HTML);
00063                 $err->merge($mail->send());
00064 
00065                 // 3. HTML Mail with attachment
00066                 $text = html::h('Heading', 1) . html::p('This is a HTML message with ümlauts and 1 Attachment');
00067                 $mail = new MailMessage('Testmail 3 (HTML + Attachment)', $text, Config::get_value(Config::MAIL_ADMIN), '', MailMessage::MIME_HTML);
00068                 $mail->add_attachment(dirname(__FILE__) . '/test.pdf', 'a_test.pdf');
00069                 $err->merge($mail->send());
00070                 
00071                 // 4. Alternative Message + attachment
00072                 $text = html::h('Heading', 1) . html::p('This is the HTML part of a alternate message');
00073                 $mail = new MailMessage('Testmail 4 (HTML + Alternate + Attachment)', $text, Config::get_value(Config::MAIL_ADMIN), '', MailMessage::MIME_HTML);
00074                 $mail->set_alt_message('This is the plain text alternative text.');
00075                 $mail->add_attachment(dirname(__FILE__) . '/test.pdf', 'a_test.pdf');
00076                 $err->merge($mail->send());
00077                 
00078                 if ($err->is_ok()) {
00079                         $err = new Message('OK. Mail was probably send successful');
00080                 }
00081                 $page_data->status = $err;
00082         }
SimpleTestController::get_routes (  ) 

Return array of urls which are handled by this controller.

Reimplemented from ControllerBase.

Definition at line 14 of file simpletest.controller.php.

00014                                      {
00015                 return array(
00016                         new ExactMatchRoute('simpletest/run', $this, 'run_tests', new NoCacheCacheManager()),
00017                         new ExactMatchRoute('simpletest/send_test_mail', $this, 'simpletest_send_test_mail', new NoCacheCacheManager())
00018                 );
00019         }

The documentation for this class was generated from the following file: