You are here

function ShoutboxUserAccessTest::testModeratedUserAccess in Shoutbox 6

File

tests/shoutbox_user_access.test, line 125
shoutbox unit test for shoutbox_user_access and shoutbox_is_user_owned

Class

ShoutboxUserAccessTest
@file shoutbox unit test for shoutbox_user_access and shoutbox_is_user_owned

Code

function testModeratedUserAccess() {

  // test add, edit and delete for a regular moderated user
  $this
    ->drupalLoginUser($this->basic_user);

  // Create a moderated piece of content.
  $shout = array();
  $shout['nick'] = $this
    ->randomName(2, 'shout');
  $shout['message'] = $this
    ->randomName(10, 'shout');
  $shout['url'] = 'http://slashdot.org';
  $this
    ->drupalPost('node', $shout, 'Shout');
  $this
    ->assertWantedRaw(t('Your shout has been submitted for approval by a moderator. Others will not see this shout until it is approved.'));

  // get the shout id
  $sid = $this
    ->_get_shout_id($shout);

  // edit the shout
  $edited_shout = array();
  $edited_shout['shout'] = $this
    ->randomName(10, 'shout');
  $url = 'shoutbox/' . $sid . '/edit';
  $this
    ->drupalPost($url, $edited_shout, 'Update');
  $this
    ->assertWantedRaw(t('Your shout has been saved.'));
  $this
    ->assertWantedRaw(t($edited_shout['shout']));

  // delete the shout
  $url = 'shoutbox/' . $sid . '/delete';
  $this
    ->drupalPost($url, NULL, 'Confirm');
  $this
    ->assertWantedRaw(t('Your shout was deleted.'));
  $this
    ->assertNoText(t($edited_shout['shout']));
  $url = url('logout', array(
    'absolute' => TRUE,
  ));
  $this
    ->get($url);
}