You are here

public function GroupSubscribeFormatterTest::testNoSubscribePermission in Organic groups 8

Tests the formatter for no subscribe permission.

File

tests/src/Unit/GroupSubscribeFormatterTest.php, line 300

Class

GroupSubscribeFormatterTest
Tests the OG group formatter.

Namespace

Drupal\Tests\og\Unit

Code

public function testNoSubscribePermission() {
  $this->group
    ->getOwnerId()
    ->willReturn(rand(100, 200));
  foreach ([
    'subscribe without approval',
    'subscribe',
  ] as $perm) {
    $this->ogAccess
      ->userAccess($this->group
      ->reveal(), $perm, $this->user
      ->reveal())
      ->willReturn($this->accessResult
      ->reveal());
  }
  $this->accessResult
    ->isAllowed()
    ->willReturn(FALSE);
  $elements = $this
    ->getElements();
  $this
    ->assertStringStartsWith('This is a closed group.', $elements[0]['#value']
    ->render());
}