MDL-19698 deprecated assign new by ref in simpletest lib

This commit is contained in:
Petr Skoda
2010-07-19 08:53:16 +00:00
parent 0ad09db03b
commit 0a8f8a65cd
21 changed files with 68 additions and 69 deletions
@@ -289,13 +289,13 @@ test case expansion against the ease of writing user interfaces.
Code such as...
$test = &new MyTestCase();
$test = new MyTestCase();
$test->attachObserver(new TestHtmlDisplay());
$test->run();
...should be rewritten as...
$test = &new MyTestCase();
$test = new MyTestCase();
$test->run(new HtmlReporter());
If you previously attached multiple observers then the workaround
+6 -6
View File
@@ -177,7 +177,7 @@ class SimpleBrowser {
SimpleTest::getDefaultProxy(),
SimpleTest::getDefaultProxyUsername(),
SimpleTest::getDefaultProxyPassword());
$this->_page = &new SimplePage();
$this->_page = new SimplePage();
$this->_history = &$this->_createHistory();
$this->_ignore_frames = false;
$this->_maximum_nested_frames = DEFAULT_MAX_NESTED_FRAMES;
@@ -189,7 +189,7 @@ class SimpleBrowser {
* @access protected
*/
function &_createUserAgent() {
$user_agent = &new SimpleUserAgent();
$user_agent = new SimpleUserAgent();
return $user_agent;
}
@@ -199,7 +199,7 @@ class SimpleBrowser {
* @access protected
*/
function &_createHistory() {
$history = &new SimpleBrowserHistory();
$history = new SimpleBrowserHistory();
return $history;
}
@@ -250,7 +250,7 @@ class SimpleBrowser {
if ($this->_ignore_frames || ! $page->hasFrames() || ($depth > $this->_maximum_nested_frames)) {
return $page;
}
$frameset = &new SimpleFrameset($page);
$frameset = new SimpleFrameset($page);
foreach ($page->getFrameset() as $key => $url) {
$frame = &$this->_fetch($url, new SimpleGetEncoding(), $depth + 1);
$frameset->addFrame($frame, $key);
@@ -267,7 +267,7 @@ class SimpleBrowser {
* @access protected
*/
function &_buildPage($response) {
$builder = &new SimplePageBuilder();
$builder = new SimplePageBuilder();
$page = &$builder->parse($response);
$builder->free();
unset($builder);
@@ -286,7 +286,7 @@ class SimpleBrowser {
function &_fetch($url, $encoding, $depth = 0) {
$response = &$this->_user_agent->fetchResponse($url, $encoding);
if ($response->isError()) {
$page = &new SimplePage($response);
$page = new SimplePage($response);
} else {
$page = &$this->_parse($response, $depth);
}
+4 -4
View File
@@ -111,20 +111,20 @@ class DefaultReporter extends SimpleReporterDecorator {
global $argv;
$parser = new SimpleCommandLineParser($argv);
$interfaces = $parser->isXml() ? array('XmlReporter') : array('TextReporter');
$reporter = &new SelectiveReporter(
$reporter = new SelectiveReporter(
SimpleTest::preferred($interfaces),
$parser->getTestCase(),
$parser->getTest());
if ($parser->noSkips()) {
$reporter = &new NoSkipsReporter($reporter);
$reporter = new NoSkipsReporter($reporter);
}
} else {
$reporter = &new SelectiveReporter(
$reporter = new SelectiveReporter(
SimpleTest::preferred('HtmlReporter'),
@$_GET['c'],
@$_GET['t']);
if (@$_GET['skips'] == 'no' || @$_GET['show-skips'] == 'no') {
$reporter = &new NoSkipsReporter($reporter);
$reporter = new NoSkipsReporter($reporter);
}
}
$this->SimpleReporterDecorator($reporter);
+3 -3
View File
@@ -53,7 +53,7 @@ class DetachedTestCase {
* @access public
*/
function run(&$reporter) {
$shell = &new SimpleShell();
$shell = new SimpleShell();
$shell->execute($this->_command);
$parser = &$this->_createParser($reporter);
if (! $parser->parse($shell->getOutput())) {
@@ -70,9 +70,9 @@ class DetachedTestCase {
*/
function getSize() {
if ($this->_size === false) {
$shell = &new SimpleShell();
$shell = new SimpleShell();
$shell->execute($this->_dry_command);
$reporter = &new SimpleReporter();
$reporter = new SimpleReporter();
$parser = &$this->_createParser($reporter);
if (! $parser->parse($shell->getOutput())) {
trigger_error('Cannot parse incoming XML from [' . $this->_dry_command . ']');
+2 -2
View File
@@ -53,7 +53,7 @@ class EclipseReporter extends SimpleScorer {
* @return SimpleSocket Connection to Eclipse.
*/
function &createListener($port, $host="127.0.0.1"){
$tmplistener = &new SimpleSocket($host, $port, 5);
$tmplistener = new SimpleSocket($host, $port, 5);
return $tmplistener;
}
@@ -64,7 +64,7 @@ class EclipseReporter extends SimpleScorer {
* @access public
*/
function &createInvoker(&$invoker){
$eclinvoker = &new EclipseInvoker($invoker, $this->_listener);
$eclinvoker = new EclipseInvoker($invoker, $this->_listener);
return $eclinvoker;
}
+1 -1
View File
@@ -75,7 +75,7 @@ class SimpleExpectation {
*/
function &_getDumper() {
if (! $this->_dumper) {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
return $dumper;
}
return $this->_dumper;
@@ -44,9 +44,9 @@
*/
function assertEquals($first, $second, $message = "%s", $delta = 0) {
if ($this->_loosely_typed) {
$expectation = &new EqualExpectation($first);
$expectation = new EqualExpectation($first);
} else {
$expectation = &new IdenticalExpectation($first);
$expectation = new IdenticalExpectation($first);
}
$this->assert($expectation, $second, $message);
}
@@ -80,7 +80,7 @@
* @public
*/
function assertSame(&$first, &$second, $message = "%s") {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
$message = sprintf(
$message,
"[" . $dumper->describeValue($first) .
@@ -101,7 +101,7 @@
* @public
*/
function assertNotSame(&$first, &$second, $message = "%s") {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
$message = sprintf(
$message,
"[" . $dumper->describeValue($first) .
+2 -2
View File
@@ -172,7 +172,7 @@ class SimpleForm {
*/
function _addRadioButton(&$tag) {
if (! isset($this->_radios[$tag->getName()])) {
$this->_widgets[] = &new SimpleRadioGroup();
$this->_widgets[] = new SimpleRadioGroup();
$this->_radios[$tag->getName()] = count($this->_widgets) - 1;
}
$this->_widgets[$this->_radios[$tag->getName()]]->addWidget($tag);
@@ -191,7 +191,7 @@ class SimpleForm {
$index = $this->_checkboxes[$tag->getName()];
if (! SimpleTestCompatibility::isA($this->_widgets[$index], 'SimpleCheckboxGroup')) {
$previous = &$this->_widgets[$index];
$this->_widgets[$index] = &new SimpleCheckboxGroup();
$this->_widgets[$index] = new SimpleCheckboxGroup();
$this->_widgets[$index]->addWidget($previous);
}
$this->_widgets[$index]->addWidget($tag);
+6 -6
View File
@@ -98,9 +98,9 @@ class SimpleRoute {
*/
function &_createSocket($scheme, $host, $port, $timeout) {
if (in_array($scheme, array('https'))) {
$socket = &new SimpleSecureSocket($host, $port, $timeout);
$socket = new SimpleSecureSocket($host, $port, $timeout);
} else {
$socket = &new SimpleSocket($host, $port, $timeout);
$socket = new SimpleSocket($host, $port, $timeout);
}
return $socket;
}
@@ -279,7 +279,7 @@ class SimpleHttpRequest {
* @access protected
*/
function &_createResponse(&$socket) {
$response = &new SimpleHttpResponse(
$response = new SimpleHttpResponse(
$socket,
$this->_route->getUrl(),
$this->_encoding);
@@ -516,13 +516,13 @@ class SimpleHttpResponse extends SimpleStickyError {
function _parse($raw) {
if (! $raw) {
$this->_setError('Nothing fetched');
$this->_headers = &new SimpleHttpHeaders('');
$this->_headers = new SimpleHttpHeaders('');
} elseif (! strstr($raw, "\r\n\r\n")) {
$this->_setError('Could not split headers from content');
$this->_headers = &new SimpleHttpHeaders($raw);
$this->_headers = new SimpleHttpHeaders($raw);
} else {
list($headers, $this->_content) = split("\r\n\r\n", $raw, 2);
$this->_headers = &new SimpleHttpHeaders($headers);
$this->_headers = new SimpleHttpHeaders($headers);
}
}
+5 -5
View File
@@ -151,7 +151,7 @@ class ParametersExpectation extends SimpleExpectation {
$descriptions = array();
if (is_array($args)) {
foreach ($args as $arg) {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
$descriptions[] = $dumper->describeValue($arg);
}
}
@@ -652,8 +652,8 @@ class SimpleMock {
* @access public
*/
function SimpleMock() {
$this->_actions = &new SimpleCallSchedule();
$this->_expectations = &new SimpleCallSchedule();
$this->_actions = new SimpleCallSchedule();
$this->_expectations = new SimpleCallSchedule();
$this->_call_counts = array();
$this->_expected_counts = array();
$this->_max_counts = array();
@@ -1320,7 +1320,7 @@ class MockGenerator {
$code .= $this->_addMethodList(array_merge($methods, $this->_reflection->getMethods()));
$code .= "\n";
$code .= " function " . $this->_mock_class . "() {\n";
$code .= " \$this->_mock = &new " . $this->_mock_base . "();\n";
$code .= " \$this->_mock = new " . $this->_mock_base . "();\n";
$code .= " \$this->_mock->disableExpectationNameChecks();\n";
$code .= " }\n";
$code .= $this->_chainMockReturns();
@@ -1346,7 +1346,7 @@ class MockGenerator {
$code .= $this->_addMethodList($methods);
$code .= "\n";
$code .= " function " . $this->_mock_class . "() {\n";
$code .= " \$this->_mock = &new " . $this->_mock_base . "();\n";
$code .= " \$this->_mock = new " . $this->_mock_base . "();\n";
$code .= " \$this->_mock->disableExpectationNameChecks();\n";
$code .= " }\n";
$code .= $this->_chainMockReturns();
+4 -4
View File
@@ -163,7 +163,7 @@ class SimplePageBuilder extends SimpleSaxListener {
* @access protected
*/
function &_createPage($response) {
$page = &new SimplePage($response);
$page = new SimplePage($response);
return $page;
}
@@ -175,7 +175,7 @@ class SimplePageBuilder extends SimpleSaxListener {
* @access protected
*/
function &_createParser(&$listener) {
$parser = &new SimpleHtmlSaxParser($listener);
$parser = new SimpleHtmlSaxParser($listener);
return $parser;
}
@@ -188,7 +188,7 @@ class SimplePageBuilder extends SimpleSaxListener {
* @access public
*/
function startElement($name, $attributes) {
$factory = &new SimpleTagBuilder();
$factory = new SimpleTagBuilder();
$tag = $factory->createTag($name, $attributes);
if (! $tag) {
return true;
@@ -641,7 +641,7 @@ class SimplePage {
* @access public
*/
function acceptFormStart(&$tag) {
$this->_open_forms[] = &new SimpleForm($tag, $this);
$this->_open_forms[] = new SimpleForm($tag, $this);
}
/**
+2 -2
View File
@@ -197,7 +197,7 @@ class SimpleLexer {
$this->_case = $case;
$this->_regexes = array();
$this->_parser = &$parser;
$this->_mode = &new SimpleStateStack($start);
$this->_mode = new SimpleStateStack($start);
$this->_mode_handlers = array($start => $start);
}
@@ -579,7 +579,7 @@ class SimpleHtmlSaxParser {
* @static
*/
function &createLexer(&$parser) {
$lexer = &new SimpleHtmlLexer($parser);
$lexer = new SimpleHtmlLexer($parser);
return $lexer;
}
+1 -2
View File
@@ -10,7 +10,6 @@ Changes:
//moodlefix ends comments. This has been reported back to the simpletest mailing
list. Hopefully will be included in a future release.
* modified run() in test_case.php - skipping tests that need fake db if prefix not set
* search replace deprecated "=& new"
skodak, Tim
$Id$
+3 -3
View File
@@ -75,7 +75,7 @@ class RemoteTestCase {
* @access protected
*/
function &_createBrowser() {
$browser = &new SimpleBrowser();
$browser = new SimpleBrowser();
return $browser;
}
@@ -86,7 +86,7 @@ class RemoteTestCase {
* @access protected
*/
function &_createParser(&$reporter) {
$parser = &new SimpleTestXmlParser($reporter);
$parser = new SimpleTestXmlParser($reporter);
return $parser;
}
@@ -103,7 +103,7 @@ class RemoteTestCase {
trigger_error('Cannot read remote test URL [' . $this->_dry_url . ']');
return false;
}
$reporter = &new SimpleReporter();
$reporter = new SimpleReporter();
$parser = &$this->_createParser($reporter);
if (! $parser->parse($xml)) {
trigger_error('Cannot parse incoming XML from [' . $this->_dry_url . ']');
+1 -1
View File
@@ -326,7 +326,7 @@ class ShellTestCase extends SimpleTestCase {
* @access protected
*/
function &_createShell() {
$shell = &new SimpleShell();
$shell = new SimpleShell();
return $shell;
}
}
+1 -1
View File
@@ -327,7 +327,7 @@ class SimpleTestContext {
*/
function &get($resource) {
if (! isset($this->_resources[$resource])) {
$this->_resources[$resource] = &new $resource();
$this->_resources[$resource] = new $resource();
}
return $this->_resources[$resource];
}
+7 -7
View File
@@ -107,9 +107,9 @@ class SimpleTestCase {
* @access public
*/
function &createInvoker() {
$invoker = &new SimpleErrorTrappingInvoker(new SimpleInvoker($this));
$invoker = new SimpleErrorTrappingInvoker(new SimpleInvoker($this));
if (version_compare(phpversion(), '5') >= 0) {
$invoker = &new SimpleExceptionTrappingInvoker($invoker);
$invoker = new SimpleExceptionTrappingInvoker($invoker);
}
return $invoker;
}
@@ -467,11 +467,11 @@ class SimpleFileLoader {
*/
function &createSuiteFromClasses($title, $classes) {
if (count($classes) == 0) {
$suite = &new BadTestSuite($title, "No runnable test cases in [$title]");
$suite = new BadTestSuite($title, "No runnable test cases in [$title]");
return $suite;
}
SimpleTest::ignoreParentsIfIgnored($classes);
$suite = &new TestSuite($title);
$suite = new TestSuite($title);
foreach ($classes as $class) {
if (! SimpleTest::isIgnored($class)) {
$suite->addTestClass($class);
@@ -530,7 +530,7 @@ class TestSuite {
*/
function addTestClass($class) {
if (TestSuite::getBaseTestCase($class) == 'testsuite') {
$this->_test_cases[] = &new $class();
$this->_test_cases[] = new $class();
} else {
$this->_test_cases[] = $class;
}
@@ -548,7 +548,7 @@ class TestSuite {
if (! is_string($test_case)) {
$this->_test_cases[] = &$test_case;
} elseif (TestSuite::getBaseTestCase($class) == 'testsuite') {
$this->_test_cases[] = &new $class();
$this->_test_cases[] = new $class();
} else {
$this->_test_cases[] = $class;
}
@@ -611,7 +611,7 @@ class TestSuite {
@ini_set('max_execution_time', $currenttl);
}
// moodle hack end
$test = &new $class();
$test = new $class();
$test->run($reporter);
unset($test);
} else {
+6 -6
View File
@@ -71,7 +71,7 @@ class UnitTestCase extends SimpleTestCase {
* @access public
*/
function assertNull($value, $message = '%s') {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
$message = sprintf(
$message,
'[' . $dumper->describeValue($value) . '] should be null');
@@ -86,7 +86,7 @@ class UnitTestCase extends SimpleTestCase {
* @access public
*/
function assertNotNull($value, $message = '%s') {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
$message = sprintf(
$message,
'[' . $dumper->describeValue($value) . '] should not be null');
@@ -235,7 +235,7 @@ class UnitTestCase extends SimpleTestCase {
* @access public
*/
function assertReference(&$first, &$second, $message = '%s') {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
$message = sprintf(
$message,
'[' . $dumper->describeValue($first) .
@@ -257,13 +257,13 @@ class UnitTestCase extends SimpleTestCase {
* @access public
*/
function assertClone(&$first, &$second, $message = '%s') {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
$message = sprintf(
$message,
'[' . $dumper->describeValue($first) .
'] and [' . $dumper->describeValue($second) .
'] should not be the same object');
$identical = &new IdenticalExpectation($first);
$identical = new IdenticalExpectation($first);
return $this->assertTrue(
$identical->test($second) &&
! SimpleTestCompatibility::isReference($first, $second),
@@ -274,7 +274,7 @@ class UnitTestCase extends SimpleTestCase {
* @deprecated
*/
function assertCopy(&$first, &$second, $message = "%s") {
$dumper = &new SimpleDumper();
$dumper = new SimpleDumper();
$message = sprintf(
$message,
"[" . $dumper->describeValue($first) .
+1 -1
View File
@@ -379,7 +379,7 @@ class SimpleUrl {
*/
function clearRequest() {
$this->_raw = false;
$this->_request = &new SimpleGetEncoding();
$this->_request = new SimpleGetEncoding();
}
/**
+6 -6
View File
@@ -44,8 +44,8 @@ class SimpleUserAgent {
* @access public
*/
function SimpleUserAgent() {
$this->_cookie_jar = &new SimpleCookieJar();
$this->_authenticator = &new SimpleAuthenticator();
$this->_cookie_jar = new SimpleCookieJar();
$this->_authenticator = new SimpleAuthenticator();
}
/**
@@ -176,7 +176,7 @@ class SimpleUserAgent {
if ((strncmp($proxy, 'http://', 7) != 0) && (strncmp($proxy, 'https://', 8) != 0)) {
$proxy = 'http://'. $proxy;
}
$this->_proxy = &new SimpleUrl($proxy);
$this->_proxy = new SimpleUrl($proxy);
$this->_proxy_username = $username;
$this->_proxy_password = $password;
}
@@ -295,7 +295,7 @@ class SimpleUserAgent {
* @access protected
*/
function &_createHttpRequest($url, $encoding) {
$request = &new SimpleHttpRequest($this->_createRoute($url), $encoding);
$request = new SimpleHttpRequest($this->_createRoute($url), $encoding);
return $request;
}
@@ -307,13 +307,13 @@ class SimpleUserAgent {
*/
function &_createRoute($url) {
if ($this->_proxy) {
$route = &new SimpleProxyRoute(
$route = new SimpleProxyRoute(
$url,
$this->_proxy,
$this->_proxy_username,
$this->_proxy_password);
} else {
$route = &new SimpleRoute($url);
$route = new SimpleRoute($url);
}
return $route;
}
+1 -1
View File
@@ -503,7 +503,7 @@ class WebTestCase extends SimpleTestCase {
* @access public
*/
function &createBrowser() {
$browser = &new SimpleBrowser();
$browser = new SimpleBrowser();
return $browser;
}