Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Runs unit tests.
- *
- * @package Elgg
- * @subpackage Test
- */
- $thisDirectory = dirname(__FILE__) . '/';
- require_once($thisDirectory . '../../../engine/start.php');
- $vendor_path = "$CONFIG->path/vendors/simpletest";
- $test_path = "$CONFIG->path/engine/tests";
- require_once("$vendor_path/unit_tester.php");
- require_once("$vendor_path/mock_objects.php");
- require_once("$vendor_path/reporter.php");
- require_once("$vendor_path/browser.php");
- require_once("$test_path/elgg_unit_test.php");
- // turn off system log
- elgg_unregister_event_handler('all', 'all', 'system_log_listener');
- elgg_unregister_event_handler('log', 'systemlog', 'system_log_default_logger');
- // Disable maximum execution time.
- // Tests take a while...
- set_time_limit(0);
- // EDIT THE FOLLOWING
- $suite = new TestSuite('YOUR TEST SUITE NAME HERE');
- $suite->addFile('/path/to/test/class.php');
- $suite->addFile('/path/to/test/class2.php');
- $suite->addFile('/path/to/test/class3.php');
- // Only run tests in debug mode.
- if (!isset($CONFIG->debug))
- {
- exit ("The site must be in debug mode to run unit tests.\n");
- }
- if (TextReporter::inCli()) {
- if (empty($argv[1]))
- {
- exit ("You must specify an output file for the XML report.\n");
- }
- elgg_set_ignore_access(TRUE);
- if ($argv[1] == 'OUT')
- {
- $response = $suite->Run(new TextReporter());
- }
- else
- {
- ini_set('implicit_flush', FALSE);
- ob_start();
- require_once("$thisDirectory/xmltime.php");
- $response = $suite->Run(new XmlTimeReporter());
- file_put_contents($argv[1], ob_get_contents());
- ob_end_clean();
- ini_set('implicit_flush', TRUE);
- }
- // In CLI error codes are returned: 0 is success
- exit ($response ? 0 : 1 );
- } else {
- // Admin access only
- admin_gatekeeper();
- $suite->Run(new HtmlReporter());
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement