/[drupal]/contributions/modules/shoutbox/tests/shoutbox_user_access.test
ViewVC logotype

Diff of /contributions/modules/shoutbox/tests/shoutbox_user_access.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1, Sun Jul 13 09:45:57 2008 UTC revision 1.1.2.2, Tue Jul 29 09:05:01 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3  // $Id:  $  // $Id: shoutbox_user_access.test,v 1.1.2.1 2008/07/13 09:45:57 disterics Exp $
4    
5  /**  /**
6   * @file   * @file
# Line 127  class ShoutboxUserAccessTest extends Dru Line 127  class ShoutboxUserAccessTest extends Dru
127      $url = url('logout', NULL, NULL, TRUE);      $url = url('logout', NULL, NULL, TRUE);
128      $this->get($url);      $this->get($url);
129    
130        $this->cleanup($sid);
131    
132    
133      // test add, edit and delete for a regular moderated user      // test add, edit and delete for a regular moderated user
134      $this->drupalLoginUser($this->basic_user);      $this->drupalLoginUser($this->basic_user);
135       // Create an  unmoderated piece of content.       // Create an  unmoderated piece of content.
# Line 156  class ShoutboxUserAccessTest extends Dru Line 159  class ShoutboxUserAccessTest extends Dru
159    
160      $url = url('logout', NULL, NULL, TRUE);      $url = url('logout', NULL, NULL, TRUE);
161      $this->get($url);      $this->get($url);
162    
163        $this->cleanup($sid);
164    
165      // now test moderation      // now test moderation
166      // create a moderated shout      // create a moderated shout
167    
# Line 213  class ShoutboxUserAccessTest extends Dru Line 218  class ShoutboxUserAccessTest extends Dru
218      $this->get($url);      $this->get($url);
219      $this->assertResponse(403);      $this->assertResponse(403);
220    
221      // save shout id for deletion  
222      $this->shout_id = $sid;      $this->cleanup($sid);
223    
224      }
225    
226      function testAdminUserAccess() {
227        // test admin access
228        $this->drupalLoginUser($this->admin_user);
229    
230        // Create an unmoderated piece of content.
231        $shout = array();
232        $shout['nick'] = $this->randomName(2, 'shout');
233        $shout['message']  = $this->randomName(10, 'shout');
234        $shout['url'] = 'http://ghanaweb.com';
235        $this->drupalPostRequest('node', $shout, 'Shout');
236        $this->assertWantedRaw(t('Your shout has been submitted.'));
237        $this->assertWantedRaw(t($shout['message']));
238    
239        // get the shout id
240        $sid = $this->_get_shout_id($shout);
241    
242        // moderate content
243        $path = 'shoutbox/'. $sid .'/unpublish';
244        // verify confirmation page
245        $url = url($path, NULL, NULL, TRUE);
246        $this->get($url);
247        $this->assertWantedRaw(t('Are you sure you want to unpublish this shout?'));
248        $this->drupalPostRequest($path, NULL, 'Confirm');
249        $this->assertText(t('The shout was unpublished.'));
250    
251        // un moderate it
252        $path = 'shoutbox/'. $sid .'/publish';
253        // verify confirmation page
254        $url = url($path, NULL, NULL, TRUE);
255        $this->get($url);
256        $this->assertText(t('Are you sure you want to publish this shout?'));
257        $this->drupalPostRequest($path, NULL, 'Confirm');
258        $this->assertText(t('The shout was published.'));
259    
260        // try and edit it
261        // edit the shout
262        $edited_shout = array();
263        $edited_shout['shout']  = $this->randomName(10, 'shout');
264        $path = 'shoutbox/'. $sid .'/edit';
265        $this->drupalPostRequest($path, $edited_shout, 'Update');
266        $this->assertWantedRaw(t('The shout has been saved.'));
267        $this->assertWantedRaw(t($edited_shout['shout']));
268    
269        //delete it
270        // delete the shout
271        $path = 'shoutbox/'. $sid .'/delete';
272        $this->drupalPostRequest($path, NULL, 'Confirm');
273        $this->assertWantedRaw(t('Your shout was deleted.'));
274        $this->assertNoText(t($edited_shout['shout']));
275    
276        // logout
277        $url = url('logout', NULL, NULL, TRUE);
278        $this->get($url);
279    
280        $this->cleanup($sid);
281    
282        // create a regular user content
283        // Login as basic user to perform initial content creation.
284        $this->drupalLoginUser($this->unmoderated_user);
285         // Create an  unmoderated piece of content.
286        $shout = array();
287        $shout['nick'] = $this->randomName(2, 'shout');
288        $shout['message']  = $this->randomName(10, 'shout');
289        $shout['url'] = 'http://slashdot.org';
290        $this->drupalPostRequest('node', $shout, 'Shout');
291        $this->assertWantedRaw(t('Your shout has been submitted.'));
292        $this->assertWantedRaw(t($shout['message']));
293    
294        // get the shout id
295        $sid = $this->_get_shout_id($shout);
296    
297        // logout
298        $url = url('logout', NULL, NULL, TRUE);
299        $this->get($url);
300    
301        // login as admin
302        $this->drupalLoginUser($this->admin_user);
303    
304        // moderate content
305        $path = 'shoutbox/'. $sid .'/unpublish';
306        // verify confirmation page
307        $url = url($path, NULL, NULL, TRUE);
308        $this->get($url);
309        $this->assertText(t('Are you sure you want to unpublish this shout?'));
310        $this->drupalPostRequest($path, NULL, 'Confirm');
311        $this->assertText(t('The shout was unpublished.'));
312    
313        // un moderate it
314        $path = 'shoutbox/'. $sid .'/publish';
315        // verify confirmation page
316        $url = url($path, NULL, NULL, TRUE);
317        $this->get($url);
318        $this->assertText(t('Are you sure you want to publish this shout?'));
319        $this->drupalPostRequest($path, NULL, 'Confirm');
320        $this->assertText(t('The shout was published.'));
321    
322        // try and edit it
323        // edit the shout
324        $edited_shout = array();
325        $edited_shout['shout']  = $this->randomName(10, 'shout');
326        $path = 'shoutbox/'. $sid .'/edit';
327        $this->drupalPostRequest($path, $edited_shout, 'Update');
328        $this->assertWantedRaw(t('The shout has been saved.'));
329        $this->assertWantedRaw(t($edited_shout['shout']));
330    
331        //delete it
332        // delete the shout
333        $path = 'shoutbox/'. $sid .'/delete';
334        $this->drupalPostRequest($path, NULL, 'Confirm');
335        $this->assertWantedRaw(t('Your shout was deleted.'));
336        $this->assertNoText(t($edited_shout['shout']));
337    
338    
339        // delete shout
340        $this->cleanup($sid);
341    
342    
343    }    }
344    
345    function tearDown() {    function cleanup($shout_id) {
346      // TODO: Put your code here.      db_query("DELETE FROM {shoutbox} WHERE shout_id = %d", $shout_id);
     db_query("DELETE FROM {shoutbox} WHERE shout_id = %d", $this->shout_id);  
     // Always call the tearDown() function from the parent class.  
     parent::tearDown();  
347    }    }
348    
349    
350  }  }
351  ?>  

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2