You are here

public function FeedAccessControlHandlerTest::testCheckCreateAccess in Feeds 8.3

@covers ::createAccess

File

tests/src/Unit/FeedAccessControlHandlerTest.php, line 98

Class

FeedAccessControlHandlerTest
@coversDefaultClass \Drupal\feeds\FeedAccessControlHandler @group feeds

Namespace

Drupal\Tests\feeds\Unit

Code

public function testCheckCreateAccess() {
  $account = $this
    ->createMock('\\Drupal\\Core\\Session\\AccountInterface');
  $account
    ->expects($this
    ->exactly(2))
    ->method('hasPermission')
    ->with($this
    ->logicalOr($this
    ->equalTo('administer feeds'), $this
    ->equalTo('create feed_bundle feeds')))
    ->will($this
    ->onConsecutiveCalls(FALSE, FALSE));
  $this
    ->assertFalse($this->controller
    ->createAccess('feed_bundle', $account));
  $this->controller
    ->resetCache();
  $account = $this
    ->createMock('\\Drupal\\Core\\Session\\AccountInterface');
  $account
    ->expects($this
    ->exactly(2))
    ->method('hasPermission')
    ->with($this
    ->logicalOr($this
    ->equalTo('administer feeds'), $this
    ->equalTo('create feed_bundle feeds')))
    ->will($this
    ->onConsecutiveCalls(FALSE, TRUE));
  $this
    ->assertTrue($this->controller
    ->createAccess('feed_bundle', $account));
}