You are here

protected function EditEntityFieldAccessCheckTest::createMockEntity in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php \Drupal\Tests\quickedit\Unit\Access\EditEntityFieldAccessCheckTest::createMockEntity()

Returns a mock entity.

Return value

\Drupal\Core\Entity\EntityInterface|\PHPUnit_Framework_MockObject_MockObject

2 calls to EditEntityFieldAccessCheckTest::createMockEntity()
EditEntityFieldAccessCheckTest::testAccess in core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php
Tests the method for checking access to routes.
EditEntityFieldAccessCheckTest::testAccessForbidden in core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php
Tests checking access to routes that result in AccessResult::isForbidden().

File

core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php, line 133
Contains \Drupal\Tests\quickedit\Unit\Access\EditEntityFieldAccessCheckTest.

Class

EditEntityFieldAccessCheckTest
@coversDefaultClass \Drupal\quickedit\Access\EditEntityFieldAccessCheck @group Access @group quickedit

Namespace

Drupal\Tests\quickedit\Unit\Access

Code

protected function createMockEntity() {
  $entity = $this
    ->getMockBuilder('Drupal\\entity_test\\Entity\\EntityTest')
    ->disableOriginalConstructor()
    ->getMock();
  $entity
    ->expects($this
    ->any())
    ->method('hasTranslation')
    ->will($this
    ->returnValueMap(array(
    array(
      LanguageInterface::LANGCODE_NOT_SPECIFIED,
      TRUE,
    ),
    array(
      'xx-lolspeak',
      FALSE,
    ),
  )));
  $entity
    ->expects($this
    ->any())
    ->method('hasField')
    ->will($this
    ->returnValueMap(array(
    array(
      'valid',
      TRUE,
    ),
    array(
      'not_valid',
      FALSE,
    ),
  )));
  return $entity;
}