Permalink
Browse files

[task/functional] Logout test now works

PHPBB3-10758
  • Loading branch information...
1 parent edd03f6 commit 9289401c646c214bb2a14b541c931435206bd6ed @imkingdavid committed Apr 7, 2012
Showing with 16 additions and 20 deletions.
  1. +14 −19 tests/functional/auth_test.php
  2. +2 −1 tests/test_framework/phpbb_functional_test_case.php
@@ -12,6 +12,7 @@
*/
class phpbb_functional_auth_test extends phpbb_functional_test_case
{
+ private $sid = '';
// since we need to login for each test (sessions aren't held) let's make it simple
private function login()
{
@@ -20,6 +21,17 @@ private function login()
$form = $crawler->selectButton('Login')->form();
$login = $this->client->submit($form, array('username' => 'admin', 'password' => 'admin'));
+
+ $cookies = $this->cookieJar->all();
+ $sid = '';
+ // get the SID from the cookie
+ foreach ($cookies as $key => $cookie);
+ {
+ if (substr($key, -4) == '_sid')
+ {
+ $this->sid = $cookie->getValue();
+ }
+ }
}
public function test_login()
@@ -34,33 +46,16 @@ public function test_login()
/**
* @depends test_login
*/
- // comment this test out for now while I get the logout test to work
- /*
- public function test_new_topic()
- {
- $this->login();
-
- //navigate to posting
- // $crawler = $this->request('GET', 'posting.php?f=2&mode=new');
-
- // $form = $crawler->selectButton('Submit')->form();
- //$post_topic = $this->client->submit($form, array('subject' => 'Test', 'message' => 'This is a test'));
- }
- */
-
- /**
- * @depends test_login
- */
public function test_logout()
{
$this->login();
// logout
- $crawler = $this->request('GET', 'ucp.php?mode=logout');
+ $crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
$this->assertContains('You have been successfully logged out.', $crawler->filter('#message')->text());
// look for a register link, which should be visible only when logged out
$crawler = $this->request('GET', 'index.php');
- $this->assertContains('Register', $crawler->filter('.linklist')->text());
+ $this->assertContains('Register', $crawler->filter('.navbar')->text());
}
}
@@ -39,7 +39,8 @@ public function setUp()
$this->markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.');
}
- $this->client = new Goutte\Client(array(), array(), null, new CookieJar);
+ $this->cookieJar = new CookieJar;
+ $this->client = new Goutte\Client(array(), array(), null, $this->cookieJar);
$this->root_url = self::$config['phpbb_functional_url'];
}

0 comments on commit 9289401

Please sign in to comment.