Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
CommentsWidgetTest.php
1 <?php
2 /**
3  * Gentics Portal.Node PHP
4  * Author & Copyright (c) by Gentics Software GmbH
5  * sales@gentics.com
6  * http://www.gentics.com
7  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8  * You must not use this software without a valid license agreement.
9  *
10  */
12 {
13  public function setUp()
14  {
15  parent::setUp();
16  $this->setSleep(1);
17  }
18 
19  public function testLoginInvitation()
20  {
21  $this->open('widgetsTests/commentsComments');
22  $this->assertElementPresent('css=#comments-form-12300123');
23  $this->assertElementNotPresent('css=#comments-form-12300123 .comments-form-widget-login');
24 
25  $this->assertElementPresent('css=#comments-form-12300124');
26  $this->assertElementPresent('css=#comments-form-12300124 .comments-form-widget-login');
27  }
28 
29  public function testValidationErrors()
30  {
31  $this->open('widgetsTests/commentsComments');
32  $this->clickAndWait('css=#comments-form-12300123 input[value="Submit"]');
33 
34  $this->assertTextPresent('First name cannot be blank');
35  $this->assertTextPresent('Last name cannot be blank');
36  $this->assertTextPresent('The verification code is incorrect');
37  $this->assertTextPresent('Email cannot be blank');
38  $this->assertTextPresent('Subject cannot be blank');
39  $this->assertTextPresent('Description cannot be blank');
40  }
41 
42  public function testEmailValidationError()
43  {
44  $this->open('widgetsTests/commentsComments');
45 
46  $this->type('css=#comments-form-12300123 [name="Comment[firstname]"]', 'John');
47  $this->type('css=#comments-form-12300123 [name="Comment[lastname]"]', 'Malkovitch');
48  $this->type('css=#comments-form-12300123 [name="Comment[email]"]', 'malkovitch');
49  $this->type('css=#comments-form-12300123 [name="Comment[subject]"]', 'TEST');
50  $this->type('css=#comments-form-12300123 [name="Comment[description]"]', 'TEST');
51  $this->type('css=#comments-form-12300123 [name="Comment[verifyCode]"]', Yii::app()->params['captcha']);
52 
53  $this->clickAndWait('css=#comments-form-12300123 input[value="Submit"]');
54 
55  $this->assertTextPresent('Email is not a valid email address');
56  }
57 
58  public function testAnonymousComment()
59  {
60  $this->open('widgetsTests/commentsComments');
61 
62  $this->type('css=#comments-form-12300123 [name="Comment[firstname]"]', 'John');
63  $this->type('css=#comments-form-12300123 [name="Comment[lastname]"]', 'Malkovitch');
64  $this->type('css=#comments-form-12300123 [name="Comment[email]"]', 'malkovitch@malkovitch.com');
65  $this->type('css=#comments-form-12300123 [name="Comment[subject]"]', 'TEST');
66  $this->type('css=#comments-form-12300123 [name="Comment[description]"]', 'TEST');
67  $this->type('css=#comments-form-12300123 [name="Comment[verifyCode]"]', Yii::app()->params['captcha']);
68 
69  $this->clickAndWait('css=#comments-form-12300123 input[value="Submit"]');
70  $this->assertTextPresent('Your comment added successfully and will be displayed');
71  }
72 
73 
74  public function testLoggedInComment()
75  {
76  $this->open('widgetsTests/commentsComments');
77  $this->clickAndWait('link=Log in to leave a Comment');
78 
79  $this->type('name=UserLogin[authField]', 'webmaster@example.com');
80  $this->type('name=UserLogin[password]', 'admin');
81  $this->clickAndWait("//input[@value='Login']");
82  $this->assertElementNotPresent('css=#comments-form-12300124 .comments-form-widget-login');
83 
84  $this->type('css=#comments-form-12300124 [name="Comment[subject]"]', 'TEST');
85  $this->type('css=#comments-form-12300124 [name="Comment[description]"]', 'TEST');
86  $this->type('css=#comments-form-12300124 [name="Comment[verifyCode]"]', Yii::app()->params['captcha']);
87  $this->clickAndWait('css=#comments-form-12300124 input[value="Submit"]');
88  $this->assertTextPresent('Your comment added successfully and will be displayed');
89 
90  $this->type('css=#comments-form-12300123 [name="Comment[subject]"]', 'TEST');
91  $this->type('css=#comments-form-12300123 [name="Comment[description]"]', 'TEST');
92  $this->type('css=#comments-form-12300123 [name="Comment[verifyCode]"]', Yii::app()->params['captcha']);
93  $this->clickAndWait('css=#comments-form-12300123 input[value="Submit"]');
94  $this->assertTextPresent('Your comment added successfully and will be displayed');
95  }
96 
97  public function testModerator()
98  {
99  $this->open('widgetsTests/commentsComments');
100  $this->clickAndWait('link=Log in to leave a Comment');
101 
102  $this->type('name=UserLogin[authField]', 'webmaster@example.com');
103  $this->type('name=UserLogin[password]', 'admin');
104  $this->clickAndWait("//input[@value='Login']");
105 
106  $this->assertTextPresent('Approve');
107  $this->assertTextPresent('Not approve');
108  $this->assertTextPresent('Delete');
109  }
110 
111  public function testDelete()
112  {
113  $this->open('widgetsTests/commentsComments');
114  $this->clickAndWait('link=Log in to leave a Comment');
115 
116  $this->type('name=UserLogin[authField]', 'webmaster@example.com');
117  $this->type('name=UserLogin[password]', 'admin');
118  $this->clickAndWait("//input[@value='Login']");
119 
120  $this->assertElementPresent('link=Delete');
121  $this->clickAndWait('link=Delete');
122  $this->assertTextPresent('Comment deleted successfully');
123  }
124 
125 
126  public function testApprove()
127  {
128  $this->open('widgetsTests/commentsComments');
129  $this->clickAndWait('link=Log in to leave a Comment');
130 
131  $this->type('name=UserLogin[authField]', 'webmaster@example.com');
132  $this->type('name=UserLogin[password]', 'admin');
133  $this->clickAndWait("//input[@value='Login']");
134 
135  $this->assertElementPresent('link=Approve');
136  $this->clickAndWait('link=Approve');
137  $this->assertTextPresent('Comment approved');
138  }
139 
140 
141  public function testNotApprove()
142  {
143  $this->open('widgetsTests/commentsComments');
144  $this->clickAndWait('link=Log in to leave a Comment');
145 
146  $this->type('name=UserLogin[authField]', 'webmaster@example.com');
147  $this->type('name=UserLogin[password]', 'admin');
148  $this->clickAndWait("//input[@value='Login']");
149 
150  $this->assertElementPresent('link=Not approve');
151  $this->clickAndWait('link=Not approve');
152  $this->assertTextPresent('Comment not approved');
153  }
154 
155 }