You are here

protected function AgreementEntityTest::setUp in Agreement 8.2

Same name and namespace in other branches
  1. 3.0.x tests/src/Unit/Plugin/views/field/AgreementEntityTest.php \Drupal\Tests\agreement\Unit\Plugin\views\field\AgreementEntityTest::setUp()

Overrides UnitTestCase::setUp

File

tests/src/Unit/Plugin/views/field/AgreementEntityTest.php, line 28

Class

AgreementEntityTest
Tests the agreement entity views field plugin.

Namespace

Drupal\Tests\agreement\Unit\Plugin\views\field

Code

protected function setUp() {
  $agreement = new Agreement([
    'id' => 'default',
    'label' => 'Default agreement',
    'path' => '/agreement',
    'agreement' => '',
    'settings' => [
      'visibility' => [
        'settings' => 0,
        'pages' => [],
      ],
      'roles' => [
        'authenticated',
      ],
      'frequency' => -1,
      'title' => 'Our agreement',
    ],
  ], 'agreement');
  $styleProphet = $this
    ->prophesize('\\Drupal\\views\\Plugin\\views\\style\\DefaultStyle');
  $viewProphet = $this
    ->prophesize('\\Drupal\\views\\ViewExecutable');
  $viewProphet
    ->getStyle()
    ->willReturn($styleProphet
    ->reveal());
  $storageProphet = $this
    ->prophesize('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
  $storageProphet
    ->loadMultiple()
    ->willReturn([
    'default' => $agreement,
  ]);
  $entityManagerProphet = $this
    ->prophesize('\\Drupal\\Core\\Entity\\EntityTypeManagerInterface');
  $entityManagerProphet
    ->getStorage('agreement')
    ->willReturn($storageProphet
    ->reveal());
  $definition = [
    'id' => 'agreement_entity',
  ];
  $container = new ContainerBuilder();
  $container
    ->set('entity_type.manager', $entityManagerProphet
    ->reveal());
  $container
    ->set('string_translation', $this
    ->getStringTranslationStub());
  \Drupal::setContainer($container);
  $this->plugin = new AgreementEntity([], 'agreement_entity', $definition, $container
    ->get('entity_type.manager'));
  $this->plugin->view = $viewProphet
    ->reveal();
  $this->plugin->field_alias = 'type';
}