You are here

function UserRelationshipsNodeAccessTestCase::testUserRelationshipsNodeAccessUpdate in User Relationships 6

File

user_relationship_node_access/tests/user_relationship_node_access.test, line 140
User Relationships Node Access Tests

Class

UserRelationshipsNodeAccessTestCase
@file User Relationships Node Access Tests

Code

function testUserRelationshipsNodeAccessUpdate() {
  $this
    ->drupalLogin($this->users['u3']);
  $node = array();
  $node['title'] = $this
    ->randomName(8);
  $node['body'] = $this
    ->randomName(16);
  $node['user_relationship_node_access[update][1_yt]'] = TRUE;
  $node['user_relationship_node_access[update][2]'] = TRUE;
  $this
    ->drupalPost('node/add/page', $node, t('Save'));
  $this
    ->assertTrue(preg_match('|node/(\\d+)$|', $this
    ->getUrl(), $matches), 'Node created');
  $this
    ->drupalLogout();

  // Can my relation update after they log in?
  $this
    ->drupalLogin($this->users['u1']);
  $edit['title'] = 'foo';
  $edit['body'] = 'bar';
  $this
    ->drupalPost("node/{$matches[1]}/edit", $edit, t('Save'));
  $this
    ->assertText(t('has been updated.'), 'Updated message appears.');
  $this
    ->drupalLogout();

  // Can unrelated user update?
  $this
    ->drupalLogin($this->users['u5']);
  $this
    ->drupalGet("node/{$matches[1]}/edit");
  $this
    ->assertResponse(403, 'Outside user cannot update.');
  $this
    ->drupalLogout();
}