protected function AgreementEntityTest::setUp in Agreement 3.0.x
Same name and namespace in other branches
- 8.2 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\fieldCode
protected function setUp() : void {
$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';
}