From b2e97539e7af7712b04dd5c2610a454d09aa0333 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 7 Jul 2006 23:18:19 +0000 Subject: Update simpletest --- .../docs/en/authentication_documentation.html | 48 ++++++++++++++-------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'tests/test_tools/simpletest/docs/en/authentication_documentation.html') diff --git a/tests/test_tools/simpletest/docs/en/authentication_documentation.html b/tests/test_tools/simpletest/docs/en/authentication_documentation.html index 0623023c..c90d61e5 100755 --- a/tests/test_tools/simpletest/docs/en/authentication_documentation.html +++ b/tests/test_tools/simpletest/docs/en/authentication_documentation.html @@ -21,9 +21,6 @@ Group tests
+ One theme that runs through SimpleTest is the ability to use + SimpleExpectation objects wherever a simple + match is not enough. + If you want only an approximate match to the realm for + example, you can do this... +
+class AuthenticationTest extends WebTestCase {
+ function test401Header() {
+ $this->get('http://www.lastcraft.com/protected/');
+ $this->assertRealm(new PatternExpectation('/simpletest/i'));
+ }
+}
+
Most of the time we are not interested in testing the
authentication itself, but want to get past it to test
the pages underneath.
@@ -116,7 +126,7 @@ class AuthenticationTest extends WebTestCase {
an authentication response...
class AuthenticationTest extends WebTestCase {
- function testAuthentication() {
+ function testCanAuthenticate() {
$this->get('http://www.lastcraft.com/protected/');
$this->authenticate('Me', 'Secret');
$this->assertTitle(...);
@@ -208,9 +218,15 @@ class LogInTest extends WebTestCase {
All we are doing is confirming that the cookie is set.
As the value is likely to be rather cryptic it's not
- really worth testing this.
-
- + really worth testing this with... +
+class LogInTest extends WebTestCase {
+ function testSessionCookieIsCorrectPattern() {
+ $this->get('http://www.my-site.com/login.php');
+ $this->assertCookie('SID', new PatternExpectation('/[a-f0-9]{32}/i'));
+ }
+}
+
The rest of the test would be the same as any other form,
but we might want to confirm that we still have the same
cookie after log-in as before we entered.
@@ -224,8 +240,8 @@ class LogInTest extends WebTestCase {
$session = $this->getCookie('SID');
$this->setField('u', 'Me');
$this->setField('p', 'Secret');
- $this->clickSubmit('Log in');
- $this->assertWantedPattern('/Welcome Me/');
+ $this->click('Log in');
+ $this->assertText('Welcome Me');
$this->assertCookie('SID', $session);
}
}
@@ -243,7 +259,7 @@ class LogInTest extends WebTestCase {
$this->get('http://www.my-site.com/login.php');
$this->setCookie('SID', 'Some other session');
$this->get('http://www.my-site.com/restricted.php');
- $this->assertWantedPattern('/Access denied/');
+ $this->assertText('Access denied');
}
}
@@ -266,12 +282,12 @@ class LogInTest extends WebTestCase {
$this->get('http://www.my-site.com/login.php');
$this->setField('u', 'Me');
$this->setField('p', 'Secret');
- $this->clickSubmit('Log in');
- $this->assertWantedPattern('/Welcome Me/');
+ $this->click('Log in');
+ $this->assertText('Welcome Me');
$this->restart();
$this->get('http://www.my-site.com/restricted.php');
- $this->assertWantedPattern('/Access denied/');
+ $this->assertText('Access denied');
}
}
@@ -297,13 +313,13 @@ class LogInTest extends WebTestCase {
$this->get('http://www.my-site.com/login.php');
$this->setField('u', 'Me');
$this->setField('p', 'Secret');
- $this->clickSubmit('Log in');
- $this->assertWantedPattern('/Welcome Me/');
+ $this->click('Log in');
+ $this->assertText('Welcome Me');
$this->ageCookies(3600);
$this->restart();
$this->get('http://www.my-site.com/restricted.php');
- $this->assertWantedPattern('/Access denied/');
+ $this->assertText('Access denied');
}
}
--
cgit v1.2.3