Author: rande
Date: 2010-04-28 12:32:51 +0200 (Wed, 28 Apr 2010)
New Revision: 29296
Modified:
plugins/swFunctionalTestGenerationPlugin/branches/sf1.3/lib/swTestFunctional.class.php
Log:
[swFunctionalTestGenerationPlugin] add login/logout method
Modified:
plugins/swFunctionalTestGenerationPlugin/branches/sf1.3/lib/swTestFunctional.class.php
===================================================================
---
plugins/swFunctionalTestGenerationPlugin/branches/sf1.3/lib/swTestFunctional.class.php
2010-04-28 10:19:08 UTC (rev 29295)
+++
plugins/swFunctionalTestGenerationPlugin/branches/sf1.3/lib/swTestFunctional.class.php
2010-04-28 10:32:51 UTC (rev 29296)
@@ -31,4 +31,83 @@
return
$this->browser->getContext()->getActionStack()->getLastEntry()->getActionInstance()->getVar($name);
}
+
+ /**
+ * @param string $user
+ * @param string $password
+ */
+ public function login($user = '[email protected]', $password =
'test')
+ {
+ $this
+ ->call('/login', 'post', array (
+ 'signin' =>
+ array (
+ 'username' => $user,
+ 'password' => $password,
+ ),
+ ))
+ ->with('request')->begin()
+ ->isParameter('module', 'sfGuardAuth')
+ ->isParameter('action', 'signin')
+ ->end()
+ ;
+
+ $this
+ ->with('response')->begin()
+ ->isRedirected(1)
+ ->isStatusCode(302)
+ ->followRedirect()
+ ->end()
+ ;
+
+ if (!$this->getContext()->getUser()->getGuardUser())
+ {
+ $this->test()->fail('No sfGuardUser linked to : '.$user);
+ die();
+ }
+
+
$this->test()->ok($this->getContext()->getUser()->getGuardUser()->getUsername()
== $user, 'user is '.$user);
+
+ return $this;
+ }
+
+
+ public function logout($restart = true, $redirect = true)
+ {
+ $this
+ ->call('/logout', 'post', array ())
+ ->with('request')->begin()
+ ->isParameter('module', 'sfGuardAuth')
+ ->isParameter('action', 'signout')
+ ->end()
+ ;
+
+ if($redirect)
+ {
+ $this
+ ->with('response')->begin()
+ ->isRedirected(1)
+ ->isStatusCode(302)
+ ->end()
+ ->followRedirect();
+ }
+ else
+ {
+ $this
+ ->with('response')->begin()
+ ->isStatusCode(200)
+ ->end();
+ }
+
+ if ($restart)
+ {
+ $this->info('Restarting Browser');
+ $this->browser->restart();
+ }
+
+ $this->test()->ok(!$this->getContext()->getUser()->isAuthenticated(),
'user is not authenticated anymore');
+
+ return $this;
+ }
+
}
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.