mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed text runner for PHP 5.1
API CHANGE: Added FunctionalTest::logInAs() to simplify logging in for tests. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@76115 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
8c9b7b282c
commit
2263aaa573
@ -30,7 +30,10 @@ class CliTestReporter extends SapphireTestReporter {
|
||||
echo SSCli::text(" AT LEAST ONE FAILURE ", "white", "red");
|
||||
}
|
||||
echo "\n\n$testCount tests run: " . SSCli::text("$passCount passes", null) . ", ". SSCli::text("$failCount fails", null) . ", and 0 exceptions\n";
|
||||
echo "Maximum memory usage: " . number_format(memory_get_peak_usage()/(1024*1024), 1) . "M\n\n";
|
||||
|
||||
if(function_exists('memory_get_peak_usage')) {
|
||||
echo "Maximum memory usage: " . number_format(memory_get_peak_usage()/(1024*1024), 1) . "M\n\n";
|
||||
}
|
||||
|
||||
$totalTime = array_sum($this->testSpeeds);
|
||||
echo "Total time: " . round($totalTime,3) . " seconds\n";
|
||||
|
@ -251,7 +251,19 @@ class FunctionalTest extends SapphireTest {
|
||||
. "Instead the following elements were found:\n'" . implode("'\n'", $actuals) . "'"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log in as the given member
|
||||
* @param $member The ID, fixture codename, or Member object of the member that you want to log in
|
||||
*/
|
||||
function logInAs($member) {
|
||||
if(is_object($member)) $memberID = $member->ID;
|
||||
elseif(is_numeric($member)) $memberID = $member;
|
||||
else $memberID = $this->idFromFixture('Member', $member);
|
||||
|
||||
$this->session()->inst_set('loggedInAs', $memberID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the draft (stage) site for testing.
|
||||
|
@ -123,7 +123,7 @@ class TestRunner extends Controller {
|
||||
function only($request) {
|
||||
$className = $request->param('TestCase');
|
||||
if(class_exists($className)) {
|
||||
if(!(singleton($className) instanceof SapphireTest)) {
|
||||
if(!is_subclass_of($className, 'SapphireTest')) {
|
||||
user_error("TestRunner::only(): Invalid TestCase '$className', cannot find matching class", E_USER_ERROR);
|
||||
}
|
||||
$this->runTests(array($className));
|
||||
|
Loading…
Reference in New Issue
Block a user