public function FeedAccessControlHandlerTest::testAccess in Feeds 8.3
@covers ::access
File
- tests/
src/ Unit/ FeedAccessControlHandlerTest.php, line 55
Class
- FeedAccessControlHandlerTest
- @coversDefaultClass \Drupal\feeds\FeedAccessControlHandler @group feeds
Namespace
Drupal\Tests\feeds\UnitCode
public function testAccess() {
$feed = $this
->getMockBuilder('\\Drupal\\feeds\\FeedInterface')
->disableOriginalConstructor()
->getMock();
$feed
->expects($this
->any())
->method('bundle')
->will($this
->returnValue('feed_bundle'));
$feed
->expects($this
->any())
->method('language')
->will($this
->returnValue(new Language()));
$account = $this
->createMock('\\Drupal\\Core\\Session\\AccountInterface');
$this
->assertFalse($this->controller
->access($feed, 'beep', $account));
$this
->assertFalse($this->controller
->access($feed, 'unlock', $account));
$this->controller
->resetCache();
$this
->assertFalse($this->controller
->access($feed, 'unlock', $account));
$account
->expects($this
->any())
->method('hasPermission')
->with($this
->equalTo('administer feeds'))
->will($this
->returnValue(TRUE));
$this
->assertTrue($this->controller
->access($feed, 'clear', $account));
$this
->assertTrue($this->controller
->access($feed, 'view', $account));
$account = $this
->createMock('\\Drupal\\Core\\Session\\AccountInterface');
$account
->expects($this
->exactly(2))
->method('hasPermission')
->with($this
->logicalOr($this
->equalTo('administer feeds'), $this
->equalTo('delete feed_bundle feeds')))
->will($this
->onConsecutiveCalls(FALSE, TRUE));
$this
->assertTrue($this->controller
->access($feed, 'delete', $account));
}