/[openfoncier]/trunk/tests/base.php
ViewVC logotype

Contents of /trunk/tests/base.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1727 - (show annotations)
Thu Apr 18 18:04:39 2013 UTC (11 years, 9 months ago) by fmichon
File size: 2594 byte(s)
Factorisation des méthodes de login et logout

1 <?php
2 /**
3 *
4 *
5 * @package openfoncier
6 * @version SVN : $Id$
7 */
8
9 class BaseTestCase extends PHPUnit_Extensions_SeleniumTestCase {
10
11 protected function setUp() {
12 $this->setBrowser("firefox");
13 $this->setBrowserUrl("http://localhost/");
14 // $this->setSleep(1);
15 }
16
17 protected function tearDown() {
18
19 }
20
21 protected function connect($login, $password) {
22 $this->open("openfoncier/");
23 $this->type("id=login", $login);
24 $this->type("id=password", $password);
25 $this->click("name=login.action.connect");
26 $this->waitForPageToLoad("30000");
27 }
28
29 protected function deconnect() {
30 $this->click("link=Déconnexion");
31 $this->waitForPageToLoad("30000");
32 }
33
34 protected function login($login, $password) {
35 // on commence par se connecter
36 $this->connect($login, $password);
37 // On doit être connecté
38 $this->assertTrue($this->isTextPresent("Votre session est maintenant ouverte."));
39 }
40
41 protected function logout() {
42 // puis on se déconnecte
43 $this->deconnect();
44 // on doit avoir un message nous indiquant que la session est finie
45 $this->assertTrue($this->isTextPresent("Votre session est maintenant terminée."));
46 // on ne doit plus avoir de lien de déconnexion
47 $this->assertFalse($this->isElementPresent("link=Déconnexion"));
48 }
49
50 /**
51 * Cette méthode permet de fair un assert sur la NON présence d'un message
52 * indiquant une erreur de base de données ou une notice PHP
53 */
54 public function verifyNoErrors() {
55 try {
56 $this->assertFalse($this->isTextPresent("Erreur de base de données. Contactez votre administrateur."));
57 } catch (PHPUnit_Framework_AssertionFailedError $e) {
58 array_push($this->verificationErrors, "Erreur de base de données.");
59 }
60 try {
61 $this->assertFalse($this->isTextPresent("Parse error:"));
62 } catch (PHPUnit_Framework_AssertionFailedError $e) {
63 array_push($this->verificationErrors, "PHP Parse error:");
64 }
65 try {
66 $this->assertFalse($this->isTextPresent("Fatal error:"));
67 } catch (PHPUnit_Framework_AssertionFailedError $e) {
68 array_push($this->verificationErrors, "PHP Fatal error:");
69 }
70 try {
71 $this->assertFalse($this->isTextPresent("Notice:"));
72 } catch (PHPUnit_Framework_AssertionFailedError $e) {
73 array_push($this->verificationErrors, "PHP Notice:");
74 }
75 }
76
77 }
78
79 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26