Commit bdf980c4 authored by Dries's avatar Dries

- Patch by boombatower: fixed code style of simpletests.

parent a96ffc11
......@@ -23,7 +23,7 @@ class DrupalReporter extends SimpleReporter {
function DrupalReporter($character_set = 'ISO-8859-1') {
$this->SimpleReporter();
drupal_add_css(drupal_get_path('module', 'simpletest') .'/simpletest.css');
drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');
$this->_character_set = $character_set;
}
......@@ -226,7 +226,7 @@ function writeContent($msg, $weight = NULL, $class = 'simpletest') {
if (!$weight) {
$weight = $this->weight++;
}
$write['content'.$this->content_count++] = array(
$write['content' . $this->content_count++] = array(
'#value' => '<div class=' . $class .'>' . $msg . '</div>',
'#weight' => $weight,
);
......
......@@ -135,8 +135,8 @@ function drupalGetTestFiles($type, $size = NULL) {
// Make sure type is valid.
if (in_array($type, array('binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'))) {
// Use original file directory instead of one created during setUp().
$path = $this->original_file_directory .'/simpletest';
$files = file_scan_directory($path, $type .'\-.*');
$path = $this->original_file_directory . '/simpletest';
$files = file_scan_directory($path, $type . '\-.*');
// If size is set then remove any files that are not of that size.
if ($size !== NULL) {
......@@ -203,6 +203,11 @@ function drupalModuleEnable($name) {
menu_rebuild();
cache_clear_all('schema', 'cache');
module_rebuild_cache();
if (module_exists($name)) {
$this->pass(t('@name enabled.', array('@name' => $name)), t('Module'));
return TRUE;
}
}
/**
......@@ -227,6 +232,11 @@ function drupalModuleDisable($name) {
menu_rebuild();
cache_clear_all('schema', 'cache');
module_rebuild_cache();
if (!module_exists($name)) {
$this->pass(t('@name disabled.', array('@name' => $name)), t('Module'));
return TRUE;
}
}
/**
......@@ -247,7 +257,7 @@ function drupalCreateUser($permissions = NULL) {
// Create a user assigned to that role.
$edit = array();
$edit['name'] = $this->randomName();
$edit['mail'] = $edit['name'] .'@example.com';
$edit['mail'] = $edit['name'] . '@example.com';
$edit['roles'] = array($rid => $rid);
$edit['pass'] = user_password();
$edit['status'] = 1;
......@@ -355,7 +365,7 @@ function setUp() {
global $db_prefix;
$this->db_prefix_original = $db_prefix;
$clean_url_original = variable_get('clean_url', 0);
$db_prefix = 'simpletest'. mt_rand(1000, 1000000);
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
include_once './includes/install.inc';
drupal_install_system();
$modules = array_unique(array_merge(func_get_args(), drupal_verify_profile('default', 'en')));
......@@ -373,7 +383,7 @@ function setUp() {
// Use temporary files directory with the same prefix as database.
$this->original_file_directory = file_directory_path();
variable_set('file_directory_path', file_directory_path() .'/'. $db_prefix);
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
file_check_directory(file_directory_path(), TRUE); // Create the files directory.
parent::setUp();
}
......@@ -436,7 +446,7 @@ protected function curlConnect() {
}
if (!isset($curl_options[CURLOPT_USERPWD]) && ($auth = variable_get('simpletest_httpauth_username', ''))) {
if ($pass = variable_get('simpletest_httpauth_pass', '')) {
$auth .= ':'. $pass;
$auth .= ':' . $pass;
}
$curl_options[CURLOPT_USERPWD] = $auth;
}
......@@ -560,7 +570,7 @@ function drupalPost($path, $edit, $submit, $tamper = FALSE) {
}
}
foreach ($upload as $key => $file) {
$post[$key] = '@'. realpath($file);
$post[$key] = '@' . realpath($file);
}
}
else {
......@@ -569,7 +579,7 @@ function drupalPost($path, $edit, $submit, $tamper = FALSE) {
foreach ($post_array as $key => $value) {
// Whethet this needs to be urlencode or rawurlencode, is not
// quite clear, but this seems to be the better choice.
$post[] = urlencode($key) .'='. urlencode($value);
$post[] = urlencode($key) . '=' . urlencode($value);
}
$post = implode('&', $post);
}
......@@ -644,7 +654,7 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
if (is_array($new_value)) {
$option_value= (string)$option['value'];
if (in_array($option_value, $new_value)) {
$post[$key .'['. $index++ .']'] = $option_value;
$post[$key . '[' . $index++ . ']'] = $option_value;
$done = TRUE;
unset($edit[$name]);
}
......@@ -682,7 +692,7 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
$post[$name] = (string)$option['value'];
}
else {
$post[$key .'['. $index++ .']'] = (string)$option['value'];
$post[$key . '[' . $index++ . ']'] = (string)$option['value'];
}
}
}
......@@ -748,7 +758,7 @@ function clickLink($label, $index = 0) {
$url_before = $this->getUrl();
$ret = FALSE;
if ($this->parse()) {
$urls = $this->elements->xpath('//a[text()="'. $label .'"]');
$urls = $this->elements->xpath('//a[text()="' . $label . '"]');
if (isset($urls[$index])) {
$url_target = $this->getAbsoluteUrl($urls[$index]['href']);
$curl_options = array(CURLOPT_URL => $url_target);
......@@ -867,7 +877,7 @@ protected function assertTextHelper($text, $message, $group, $not_exists) {
$this->plain_text = filter_xss($this->_content, array());
}
if (!$message) {
$message = '"'. $text .'"'. ($not_exists ? ' not found.' : ' found.');
$message = '"' . $text . '"' . ($not_exists ? ' not found.' : ' found.');
}
return $this->assertTrue($not_exists == (strpos($this->plain_text, $text) === FALSE), $message, $group);
}
......@@ -902,7 +912,7 @@ function assertNoPattern($pattern, $message = '%s', $group = 'Other') {
* @return boolean TRUE on pass.
*/
function assertTitle($title, $message, $group = 'Other') {
return $this->assertTrue($this->parse() && $this->elements->xpath('//title[text()="'. $title .'"]'), $message, $group);
return $this->assertTrue($this->parse() && $this->elements->xpath('//title[text()="' . $title . '"]'), $message, $group);
}
/**
......@@ -1015,7 +1025,7 @@ function assertNoFieldById($id, $value = '', $message = '') {
* @return boolean Assertion result.
*/
function assertField($field, $message = '', $group = 'Other') {
return $this->assertFieldByXPath($this->_constructFieldXpath('name', $field) .'|'. $this->_constructFieldXpath('id', $field), '', $message, $group);
return $this->assertFieldByXPath($this->_constructFieldXpath('name', $field) . '|' . $this->_constructFieldXpath('id', $field), '', $message, $group);
}
/**
......@@ -1026,7 +1036,7 @@ function assertField($field, $message = '', $group = 'Other') {
* @return boolean Assertion result.
*/
function assertNoField($field, $message = '', $group = 'Other') {
return $this->assertNoFieldByXPath($this->_constructFieldXpath('name', $field) .'|'. $this->_constructFieldXpath('id', $field), '', $message, $group);
return $this->assertNoFieldByXPath($this->_constructFieldXpath('name', $field) . '|' . $this->_constructFieldXpath('id', $field), '', $message, $group);
}
/**
......@@ -1037,7 +1047,7 @@ function assertNoField($field, $message = '', $group = 'Other') {
* @return string XPath for specified values.
*/
function _constructFieldXpath($attribute, $value) {
return '//textarea[@'. $attribute .'="'. $value .'"]|//input[@'. $attribute .'="'. $value .'"]|//select[@'. $attribute .'="'. $value .'"]';
return '//textarea[@' . $attribute . '="' . $value . '"]|//input[@' . $attribute . '="' . $value . '"]|//select[@' . $attribute . '="' . $value . '"]';
}
/**
......
......@@ -48,7 +48,7 @@ function getType($value) {
}
$functions = array('bool', 'string', 'integer', 'float', 'array', 'resource', 'object');
foreach ($functions as $function) {
$function_name = 'is_'. $function;
$function_name = 'is_' . $function;
if ($function_name($value)) {
return ucfirst($function);
}
......
......@@ -108,7 +108,7 @@ function test($compare) {
*/
function testMessage($compare) {
$dumper = &$this->_getDumper();
return 'Anything always matches ['. $dumper->describeValue($compare) .']';
return 'Anything always matches [' . $dumper->describeValue($compare) . ']';
}
}
......@@ -138,7 +138,7 @@ function test($compare) {
*/
function testMessage($compare) {
$dumper = &$this->_getDumper();
return 'Expected true, got ['. $dumper->describeValue($compare) .']';
return 'Expected true, got [' . $dumper->describeValue($compare) . ']';
}
}
......@@ -128,7 +128,7 @@ function paintException($exception) {
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print implode(" -&gt; ", $breadcrumb);
$message = 'Unexpected exception of type ['. get_class($exception) .'] with message ['. $exception->getMessage() .'] in ['. $exception->getFile() .' line '. $exception->getLine() .']';
$message = 'Unexpected exception of type [' . get_class($exception) . '] with message [' . $exception->getMessage() . '] in [' . $exception->getFile() . ' line ' . $exception->getLine() . ']';
print " -&gt; <strong>". $this->_htmlEntities($message) ."</strong><br />\n";
}
......@@ -152,7 +152,7 @@ function paintSkip($message) {
* @access public
*/
function paintFormattedMessage($message) {
print '<pre>'. $this->_htmlEntities($message) .'</pre>';
print '<pre>' . $this->_htmlEntities($message) . '</pre>';
}
/**
......@@ -253,7 +253,7 @@ function paintError($message) {
*/
function paintException($exception) {
parent::paintException($exception);
$message = 'Unexpected exception of type ['. get_class($exception) .'] with message ['. $exception->getMessage() .'] in ['. $exception->getFile() .' line '. $exception->getLine() .']';
$message = 'Unexpected exception of type [' . get_class($exception) . '] with message [' . $exception->getMessage() . '] in [' . $exception->getFile() . ' line ' . $exception->getLine() . ']';
print "Exception ". $this->getExceptionCount() ."!\n$message\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
......
......@@ -29,10 +29,10 @@ function simpletest_install() {
// Copy other test files for consistency.
$files = file_scan_directory($path, '(html|image|javascript|php|sql)-.*');
if (count($files) == 0) {
$original = drupal_get_path('module', 'simpletest') .'/files';
$original = drupal_get_path('module', 'simpletest') . '/files';
$files = file_scan_directory($original, '(html|image|javascript|php|sql)-.*');
foreach ($files as $file) {
file_copy($file->filename, $path .'/'. $file->basename);
file_copy($file->filename, $path . '/' . $file->basename);
}
$generated = TRUE;
}
......@@ -70,7 +70,7 @@ function simpletest_generate_file($filename, $width, $lines, $type = 'binary-tex
// Create filename.
$path = file_directory_path() . '/simpletest/';
$count = simpletest_get_file_count($path, $filename);
file_put_contents($path . $filename .'-'. ($count + 1) .'.txt', $text);
file_put_contents($path . $filename . '-' . ($count + 1) . '.txt', $text);
}
/**
......@@ -80,7 +80,7 @@ function simpletest_get_file_count($directory, $filename) {
$files = scandir($directory);
$count = 0;
foreach ($files as $file) {
if (preg_match('/'. $filename .'.*?/', $file)) {
if (preg_match('/' . $filename . '.*?/', $file)) {
$count++;
}
}
......
......@@ -7,11 +7,11 @@
function simpletest_help($path, $arg) {
switch ($path) {
case 'admin/help#simpletest':
$output = '<p>'. t('The SimpleTest module is a framework for running automated unit tests in Drupal. It can be used to verify a working state of Drupal before and after any code changes, or as a means for developers to write and execute tests for their modules.') .'</p>';
$output .= '<p>'. t('Visit <a href="@admin-simpletest">Administer >> Site building >> SimpleTest</a> to display a list of available tests. For comprehensive testing, select <em>all</em> tests, or individually select tests for more targeted testing. Note that it might take several minutes for all tests to complete.)', array('@admin-simpletest' => url('admin/build/testing'))) .'</p>';
$output .= '<p>'. t('After the tests have run, a message will be displayed next to each test group indicating whether tests within it passed, failed, or had exceptions. A pass means that a test returned the expected results, while fail means that it did not. An exception normally indicates an error outside of the test, such as a PHP warning or notice. If there were fails or exceptions, the results are expanded, and the tests that had issues will be indicated in red or pink rows. Use these results to refine your code and tests until all tests return a pass.') .'</p>';
$output .= '<p>'. t('For more information on creating and modifying your own tests, see the <a href="@simpletest-api">SimpleTest API Documentation</a> in the Drupal handbook.', array('@simpletest-api' => 'http://drupal.org/simpletest')) .'</p>';
$output .= '<p>'. t('For more information, see the online handbook entry for <a href="@simpletest">SimpleTest module</a>.', array('@simpletest' => 'http://drupal.org/handbook/modules/simpletest')) .'</p>';
$output = '<p>' . t('The SimpleTest module is a framework for running automated unit tests in Drupal. It can be used to verify a working state of Drupal before and after any code changes, or as a means for developers to write and execute tests for their modules.') .'</p>';
$output .= '<p>' . t('Visit <a href="@admin-simpletest">Administer >> Site building >> SimpleTest</a> to display a list of available tests. For comprehensive testing, select <em>all</em> tests, or individually select tests for more targeted testing. Note that it might take several minutes for all tests to complete.)', array('@admin-simpletest' => url('admin/build/testing'))) .'</p>';
$output .= '<p>' . t('After the tests have run, a message will be displayed next to each test group indicating whether tests within it passed, failed, or had exceptions. A pass means that a test returned the expected results, while fail means that it did not. An exception normally indicates an error outside of the test, such as a PHP warning or notice. If there were fails or exceptions, the results are expanded, and the tests that had issues will be indicated in red or pink rows. Use these results to refine your code and tests until all tests return a pass.') .'</p>';
$output .= '<p>' . t('For more information on creating and modifying your own tests, see the <a href="@simpletest-api">SimpleTest API Documentation</a> in the Drupal handbook.', array('@simpletest-api' => 'http://drupal.org/simpletest')) .'</p>';
$output .= '<p>' . t('For more information, see the online handbook entry for <a href="@simpletest">SimpleTest module</a>.', array('@simpletest' => 'http://drupal.org/handbook/modules/simpletest')) .'</p>';
return $output;
}
}
......@@ -68,7 +68,7 @@ function simpletest_load() {
if ($user->uid != 1) {
drupal_set_message(t('It is strongly suggested to run the tests with the first user!'));
}
$path = drupal_get_path('module', 'simpletest') .'/';
$path = drupal_get_path('module', 'simpletest') . '/';
foreach (array('simpletest.php', 'unit_tester.php', 'reporter.php', 'drupal_reporter.php', 'drupal_web_test_case.php', 'drupal_test_suite.php') as $file) {
require_once($path . $file);
}
......@@ -80,8 +80,8 @@ function simpletest_load() {
*/
function simpletest_entrypoint() {
simpletest_load();
drupal_add_css(drupal_get_path('module', 'simpletest') .'/simpletest.css', 'module');
drupal_add_js(drupal_get_path('module', 'simpletest') .'/simpletest.js', 'module');
drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css', 'module');
drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', 'module');
$output = drupal_get_form('simpletest_overview_form');
if (simpletest_running_output()) {
......@@ -204,30 +204,30 @@ function theme_simpletest_overview_form($form) {
$row = array();
$row[] = array('id' => $test_class, 'class' => 'simpletest-select-all');
$row[] = array(
'data' => '<div class="simpletest-image" id="simpletest-test-group-'. $test_class .'">'. $js['images'][0] .'</div>&nbsp;<label for="'. $test_class .'-select-all" class="simpletest-group-label">'. $element['#title'] .'</label>',
'data' => '<div class="simpletest-image" id="simpletest-test-group-' . $test_class . '">' . $js['images'][0] . '</div>&nbsp;<label for="' . $test_class . '-select-all" class="simpletest-group-label">' . $element['#title'] . '</label>',
'style' => 'font-weight: bold;'
);
$row[] = $element['#description'];
$rows[] = array('data' => $row, 'class' => 'simpletest-group');
$current_js = array('testClass' => $test_class .'-test', 'testNames' => array(), 'imageDirection' => 0, 'clickActive' => FALSE);
$current_js = array('testClass' => $test_class . '-test', 'testNames' => array(), 'imageDirection' => 0, 'clickActive' => FALSE);
// Go through each test in the group and create table rows setting them to invisible:
foreach (element_children($element['tests']) as $test_name) {
$current_js['testNames'][] = 'edit-'. $test_name;
$current_js['testNames'][] = 'edit-' . $test_name;
$test = $element['tests'][$test_name];
foreach (array('title', 'description') as $key) {
$$key = $test['#'. $key];
unset($test['#'. $key]);
$$key = $test['#' . $key];
unset($test['#' . $key]);
}
$test['#name'] = $test_name;
$themed_test = drupal_render($test);
$row = array();
$row[] = $themed_test;
$row[] = theme('indentation', 1) .'<label for="edit-'. $test_name .'">'. $title .'</label>';
$row[] = '<div class="description">'. $description .'</div>';
$rows[] = array('data' => $row, 'style' => 'display: none;', 'class' => $test_class .'-test');
$row[] = theme('indentation', 1) . '<label for="edit-' . $test_name . '">' . $title . '</label>';
$row[] = '<div class="description">' . $description . '</div>';
$rows[] = array('data' => $row, 'style' => 'display: none;', 'class' => $test_class . '-test');
}
$js['simpletest-test-group-'. $test_class] = $current_js;
$js['simpletest-test-group-' . $test_class] = $current_js;
unset($form[$gid]); // Remove test group from form.
}
}
......@@ -343,7 +343,7 @@ function simpletest_clean_temporary_directories() {
$files = scandir(file_directory_path());
$count = 0;
foreach ($files as $file) {
$path = file_directory_path() .'/'. $file;
$path = file_directory_path() . '/' . $file;
if (is_dir($path) && preg_match('/^simpletest\d+/', $file)) {
simpletest_clean_temporary_directory($path);
$count++;
......
<?php
// $Id$
require_once dirname(__FILE__) .'/test_case.php';
require_once dirname(__FILE__) .'/unit_tester.php';
require_once dirname(__FILE__) .'/expectation.php';
require_once dirname(__FILE__) .'/invoker.php';
require_once dirname(__FILE__) .'/scorer.php';
require_once dirname(__FILE__) .'/reporter.php';
require_once dirname(__FILE__) .'/default_reporter.php';
require_once dirname(__FILE__) .'/dumper.php';
require_once dirname(__FILE__) .'/errors.php';
require_once dirname(__FILE__) .'/exceptions.php';
require_once dirname(__FILE__) .'/xml.php';
require_once dirname(__FILE__) . '/test_case.php';
require_once dirname(__FILE__) . '/unit_tester.php';
require_once dirname(__FILE__) . '/expectation.php';
require_once dirname(__FILE__) . '/invoker.php';
require_once dirname(__FILE__) . '/scorer.php';
require_once dirname(__FILE__) . '/reporter.php';
require_once dirname(__FILE__) . '/default_reporter.php';
require_once dirname(__FILE__) . '/dumper.php';
require_once dirname(__FILE__) . '/errors.php';
require_once dirname(__FILE__) . '/exceptions.php';
require_once dirname(__FILE__) . '/xml.php';
/**
* Registry and test context. Includes a few
......
......@@ -52,7 +52,7 @@ function skip() {}
function skipIf($should_skip, $message = '%s') {
if ($should_skip && !$this->_should_skip) {
$this->_should_skip = true;
$message = sprintf($message, 'Skipping ['. get_class($this) .']');
$message = sprintf($message, 'Skipping [' . get_class($this) . ']');
$this->_reporter->paintSkip($message . $this->getAssertionLine());
}
}
......@@ -589,8 +589,8 @@ function getLabel() {
*/
function run(&$reporter) {
$reporter->paintGroupStart($this->getLabel(), $this->getSize());
$reporter->paintFail('Bad TestSuite ['. $this->getLabel() .
'] with error ['. $this->_error .']');
$reporter->paintFail('Bad TestSuite [' . $this->getLabel() .
'] with error [' . $this->_error . ']');
$reporter->paintGroupEnd($this->getLabel());
return $reporter->getStatus();
}
......
......@@ -47,7 +47,7 @@ function assertTrue($result, $message = FALSE, $group = 'Other') {
*/
function assertFalse($result, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$message = sprintf($message, 'Expected false, got ['. $dumper->describeValue($result) .']');
$message = sprintf($message, 'Expected false, got [' . $dumper->describeValue($result) . ']');
return $this->assertTrue(!$result, $message, $group);
}
......@@ -60,7 +60,7 @@ function assertFalse($result, $message = '%s', $group = 'Other') {
*/
function assertNull($value, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$message = sprintf($message, '['. $dumper->describeValue($value) .'] should be null');
$message = sprintf($message, '[' . $dumper->describeValue($value) . '] should be null');
return $this->assertTrue(!isset($value), $message, $group);
}
......@@ -73,7 +73,7 @@ function assertNull($value, $message = '%s', $group = 'Other') {
*/
function assertNotNull($value, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$message = sprintf($message, '['. $dumper->describeValue($value) .'] should not be null');
$message = sprintf($message, '[' . $dumper->describeValue($value) . '] should not be null');
return $this->assertTrue(isset($value), $message, $group);
}
......@@ -88,7 +88,7 @@ function assertNotNull($value, $message = '%s', $group = 'Other') {
*/
function assertEqual($first, $second, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$message = sprintf($message, 'Expected '. $dumper->describeValue($first) .', got ['. $dumper->describeValue($second) .']');
$message = sprintf($message, 'Expected ' . $dumper->describeValue($first) . ', got [' . $dumper->describeValue($second) . ']');
$this->assertTrue($first == $second, $message, $group);
}
......@@ -103,7 +103,7 @@ function assertEqual($first, $second, $message = '%s', $group = 'Other') {
*/
function assertNotEqual($first, $second, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$message = sprintf($message, 'Expected '. $dumper->describeValue($first) .', not equal to '. $dumper->describeValue($second));
$message = sprintf($message, 'Expected ' . $dumper->describeValue($first) . ', not equal to ' . $dumper->describeValue($second));
$this->assertTrue($first != $second, $message, $group);
}
......@@ -118,7 +118,7 @@ function assertNotEqual($first, $second, $message = '%s', $group = 'Other') {
*/
function assertIdentical($first, $second, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$message = sprintf($message, 'Expected '. $dumper->describeValue($first) .', got ['. $dumper->describeValue($second) .']');
$message = sprintf($message, 'Expected ' . $dumper->describeValue($first) . ', got [' . $dumper->describeValue($second) . ']');
$this->assertTrue($first === $second, $message, $group);
}
......@@ -133,7 +133,7 @@ function assertIdentical($first, $second, $message = '%s', $group = 'Other') {
*/
function assertNotIdentical($first, $second, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$message = sprintf($message, 'Expected '. $dumper->describeValue($first) .', not identical to '. $dumper->describeValue($second));
$message = sprintf($message, 'Expected ' . $dumper->describeValue($first) . ', not identical to ' . $dumper->describeValue($second));
$this->assertTrue($first !== $second, $message, $group);
}
......@@ -149,11 +149,11 @@ function assertNotIdentical($first, $second, $message = '%s', $group = 'Other')
*/
function assertPattern($pattern, $subject, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$replace = 'Pattern '. $pattern .' detected in ['. $dumper->describeValue($subject) .']';
$replace = 'Pattern ' . $pattern . ' detected in [' . $dumper->describeValue($subject) . ']';
$found = preg_match($pattern, $subject, $matches);
if ($found) {
$position = strpos($subject, $matches[0]);
$replace .= ' in region ['. $dumper->clipString($subject, 100, $position) .']';
$replace .= ' in region [' . $dumper->clipString($subject, 100, $position) . ']';
}
$message = sprintf($message, $replace);
$this->assertTrue($found, $message, $group);
......@@ -172,7 +172,7 @@ function assertPattern($pattern, $subject, $message = '%s', $group = 'Other') {
function assertNoPattern($pattern, $subject, $message = '%s', $group = 'Other') {
$dumper = &new SimpleDumper();
$found = preg_match($pattern, $subject);
$message = sprintf($message, 'Pattern '. $pattern .' not detected in ['. $dumper->describeValue($subject) .']');
$message = sprintf($message, 'Pattern ' . $pattern . ' not detected in [' . $dumper->describeValue($subject) . ']');
$this->assertFalse($found, $message, $group = 'Other');
}
}
\ No newline at end of file
......@@ -184,8 +184,8 @@ function paintException($exception) {
print $this->_getIndent(1);
print "<" . $this->_namespace . "exception>";
$message = 'Unexpected exception of type [' . get_class($exception) .
'] with message ['. $exception->getMessage() .
'] in ['. $exception->getFile() .
'] with message [' . $exception->getMessage() .
'] in [' . $exception->getFile() .
' line ' . $exception->getLine() . ']';
print $this->toParsedXml($message);
print "</" . $this->_namespace . "exception>\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment