function ShoutboxUserAccessTest::testShoutboxUserAccess in Shoutbox 5
File
- tests/shoutbox_user_access.test, line 94
- 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 testShoutboxUserAccess() {
$this
->drupalLoginUser($this->unmoderated_user);
$shout = array();
$shout['nick'] = $this
->randomName(2, 'shout');
$shout['message'] = $this
->randomName(10, 'shout');
$shout['url'] = 'http://slashdot.org';
$this
->drupalPostRequest('node', $shout, 'Shout');
$this
->assertWantedRaw(t('Your shout has been submitted.'));
$this
->assertWantedRaw(t($shout['message']));
$sid = $this
->_get_shout_id($shout);
$edited_shout = array();
$edited_shout['shout'] = $this
->randomName(10, 'shout');
$url = 'shoutbox/' . $sid . '/edit';
$this
->drupalPostRequest($url, $edited_shout, 'Update');
$this
->assertWantedRaw(t('Your shout has been saved.'));
$this
->assertWantedRaw(t($edited_shout['shout']));
$url = 'shoutbox/' . $sid . '/delete';
$this
->drupalPostRequest($url, NULL, 'Confirm');
$this
->assertWantedRaw(t('Your shout was deleted.'));
$this
->assertNoText(t($edited_shout['shout']));
$url = url('logout', NULL, NULL, TRUE);
$this
->get($url);
$this
->cleanup($sid);
$this
->drupalLoginUser($this->basic_user);
$shout = array();
$shout['nick'] = $this
->randomName(2, 'shout');
$shout['message'] = $this
->randomName(10, 'shout');
$shout['url'] = 'http://slashdot.org';
$this
->drupalPostRequest('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.'));
$sid = $this
->_get_shout_id($shout);
$edited_shout = array();
$edited_shout['shout'] = $this
->randomName(10, 'shout');
$url = 'shoutbox/' . $sid . '/edit';
$this
->drupalPostRequest($url, $edited_shout, 'Update');
$this
->assertWantedRaw(t('Your shout has been saved.'));
$this
->assertWantedRaw(t($edited_shout['shout']));
$url = 'shoutbox/' . $sid . '/delete';
$this
->drupalPostRequest($url, NULL, 'Confirm');
$this
->assertWantedRaw(t('Your shout was deleted.'));
$this
->assertNoText(t($edited_shout['shout']));
$url = url('logout', NULL, NULL, TRUE);
$this
->get($url);
$this
->cleanup($sid);
$this
->drupalLoginUser($this->basic_user);
$shout = array();
$shout['nick'] = $this
->randomName(2, 'shout');
$shout['message'] = $this
->randomName(10, 'shout');
$shout['url'] = 'http://slashdot.org';
$this
->drupalPostRequest('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.'));
$sid = $this
->_get_shout_id($shout);
$path = 'shoutbox/' . $sid . '/publish';
$url = url($path, NULL, NULL, TRUE);
$this
->get($url);
$this
->assertResponse(403);
$url = url('logout', NULL, NULL, TRUE);
$this
->get($url);
$this
->drupalLoginUser($this->moderator);
$path = 'shoutbox/' . $sid . '/publish';
$url = url($path, NULL, NULL, TRUE);
$this
->get($url);
$this
->assertText(t('Are you sure you want to publish this shout?'));
$this
->drupalPostRequest($path, NULL, 'Confirm');
$this
->assertText(t('The shout was published.'));
$path = 'shoutbox/' . $sid . '/unpublish';
$url = url($path, NULL, NULL, TRUE);
$this
->get($url);
$this
->assertText(t('Are you sure you want to unpublish this shout?'));
$this
->drupalPostRequest($path, NULL, 'Confirm');
$this
->assertText(t('The shout was unpublished.'));
$path = 'shoutbox/' . $sid . '/edit';
$url = url($path, NULL, NULL, TRUE);
$this
->get($url);
$this
->assertResponse(403);
$path = 'shoutbox/' . $sid . '/delete';
$url = url($path, NULL, NULL, TRUE);
$this
->get($url);
$this
->assertResponse(403);
$this
->cleanup($sid);
}