diff --git a/lib/simpletestlib/HELP_MY_TESTS_DONT_WORK_ANYMORE b/lib/simpletestlib/HELP_MY_TESTS_DONT_WORK_ANYMORE index 8ac9cf2aa51..2d6612badb4 100644 --- a/lib/simpletestlib/HELP_MY_TESTS_DONT_WORK_ANYMORE +++ b/lib/simpletestlib/HELP_MY_TESTS_DONT_WORK_ANYMORE @@ -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 diff --git a/lib/simpletestlib/browser.php b/lib/simpletestlib/browser.php index dc544708b40..423e8fbef77 100644 --- a/lib/simpletestlib/browser.php +++ b/lib/simpletestlib/browser.php @@ -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); } diff --git a/lib/simpletestlib/default_reporter.php b/lib/simpletestlib/default_reporter.php index 69b0797e385..a25844f80cc 100644 --- a/lib/simpletestlib/default_reporter.php +++ b/lib/simpletestlib/default_reporter.php @@ -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); diff --git a/lib/simpletestlib/detached.php b/lib/simpletestlib/detached.php index 708e6e1c2e6..706c4ceedc0 100644 --- a/lib/simpletestlib/detached.php +++ b/lib/simpletestlib/detached.php @@ -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 . ']'); diff --git a/lib/simpletestlib/eclipse.php b/lib/simpletestlib/eclipse.php index c5e715458ca..0cb93726ad9 100644 --- a/lib/simpletestlib/eclipse.php +++ b/lib/simpletestlib/eclipse.php @@ -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; } diff --git a/lib/simpletestlib/expectation.php b/lib/simpletestlib/expectation.php index 11bc95b148f..2b191979928 100644 --- a/lib/simpletestlib/expectation.php +++ b/lib/simpletestlib/expectation.php @@ -75,7 +75,7 @@ class SimpleExpectation { */ function &_getDumper() { if (! $this->_dumper) { - $dumper = &new SimpleDumper(); + $dumper = new SimpleDumper(); return $dumper; } return $this->_dumper; diff --git a/lib/simpletestlib/extensions/pear_test_case.php b/lib/simpletestlib/extensions/pear_test_case.php index 4f9f4ad3eeb..8ecfe1b4650 100644 --- a/lib/simpletestlib/extensions/pear_test_case.php +++ b/lib/simpletestlib/extensions/pear_test_case.php @@ -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) . diff --git a/lib/simpletestlib/form.php b/lib/simpletestlib/form.php index 8a73e5a81b3..937f2628d4a 100644 --- a/lib/simpletestlib/form.php +++ b/lib/simpletestlib/form.php @@ -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); diff --git a/lib/simpletestlib/http.php b/lib/simpletestlib/http.php index e309b0f5301..d414806f5d7 100644 --- a/lib/simpletestlib/http.php +++ b/lib/simpletestlib/http.php @@ -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); } } diff --git a/lib/simpletestlib/mock_objects.php b/lib/simpletestlib/mock_objects.php index e007ae14f4e..f37fc76120c 100644 --- a/lib/simpletestlib/mock_objects.php +++ b/lib/simpletestlib/mock_objects.php @@ -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(); diff --git a/lib/simpletestlib/page.php b/lib/simpletestlib/page.php index f36a9581f41..a134eaddd17 100644 --- a/lib/simpletestlib/page.php +++ b/lib/simpletestlib/page.php @@ -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); } /** diff --git a/lib/simpletestlib/parser.php b/lib/simpletestlib/parser.php index 37db3d0c980..ba679142c09 100644 --- a/lib/simpletestlib/parser.php +++ b/lib/simpletestlib/parser.php @@ -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; } diff --git a/lib/simpletestlib/readme_moodle.txt b/lib/simpletestlib/readme_moodle.txt index 7532b0aca45..2b881f2e742 100644 --- a/lib/simpletestlib/readme_moodle.txt +++ b/lib/simpletestlib/readme_moodle.txt @@ -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$ diff --git a/lib/simpletestlib/remote.php b/lib/simpletestlib/remote.php index 15e55c98ace..764e840a5c1 100644 --- a/lib/simpletestlib/remote.php +++ b/lib/simpletestlib/remote.php @@ -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 . ']'); diff --git a/lib/simpletestlib/shell_tester.php b/lib/simpletestlib/shell_tester.php index 4aff96fc5bf..14186796d83 100644 --- a/lib/simpletestlib/shell_tester.php +++ b/lib/simpletestlib/shell_tester.php @@ -326,7 +326,7 @@ class ShellTestCase extends SimpleTestCase { * @access protected */ function &_createShell() { - $shell = &new SimpleShell(); + $shell = new SimpleShell(); return $shell; } } diff --git a/lib/simpletestlib/simpletest.php b/lib/simpletestlib/simpletest.php index 1581fbf6123..0079a1ffaf9 100644 --- a/lib/simpletestlib/simpletest.php +++ b/lib/simpletestlib/simpletest.php @@ -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]; } diff --git a/lib/simpletestlib/test_case.php b/lib/simpletestlib/test_case.php index c812e7fd54d..be65e81f7f5 100644 --- a/lib/simpletestlib/test_case.php +++ b/lib/simpletestlib/test_case.php @@ -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 { diff --git a/lib/simpletestlib/unit_tester.php b/lib/simpletestlib/unit_tester.php index 54a13480d14..ce51b88267f 100644 --- a/lib/simpletestlib/unit_tester.php +++ b/lib/simpletestlib/unit_tester.php @@ -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) . diff --git a/lib/simpletestlib/url.php b/lib/simpletestlib/url.php index ce3765ea368..f4b501296da 100644 --- a/lib/simpletestlib/url.php +++ b/lib/simpletestlib/url.php @@ -379,7 +379,7 @@ class SimpleUrl { */ function clearRequest() { $this->_raw = false; - $this->_request = &new SimpleGetEncoding(); + $this->_request = new SimpleGetEncoding(); } /** diff --git a/lib/simpletestlib/user_agent.php b/lib/simpletestlib/user_agent.php index 5e02beded0e..e8cb32cc682 100644 --- a/lib/simpletestlib/user_agent.php +++ b/lib/simpletestlib/user_agent.php @@ -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; } diff --git a/lib/simpletestlib/web_tester.php b/lib/simpletestlib/web_tester.php index c29eb64867b..d4f9e5a085f 100644 --- a/lib/simpletestlib/web_tester.php +++ b/lib/simpletestlib/web_tester.php @@ -503,7 +503,7 @@ class WebTestCase extends SimpleTestCase { * @access public */ function &createBrowser() { - $browser = &new SimpleBrowser(); + $browser = new SimpleBrowser(); return $browser; }