Skip to content

Commit

Permalink
BUGFIX: Fixed text runner for PHP 5.1
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sam Minnee committed Feb 2, 2011
1 parent 8c9b7b2 commit 2263aaa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dev/CliTestReporter.php
Expand Up @@ -30,7 +30,10 @@ public function writeResults() {
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";
Expand Down
14 changes: 13 additions & 1 deletion dev/FunctionalTest.php
Expand Up @@ -251,7 +251,19 @@ function assertExactHTMLMatchBySelector($selector, $expectedMatches) {
. "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.
Expand Down
2 changes: 1 addition & 1 deletion dev/TestRunner.php
Expand Up @@ -123,7 +123,7 @@ function coverage() {
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));
Expand Down

0 comments on commit 2263aaa

Please sign in to comment.