You are here

protected function SubscriptionControllerTest::setUp in Organic groups 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/SubscriptionControllerTest.php, line 103

Class

SubscriptionControllerTest
Tests the subscription controller.

Namespace

Drupal\Tests\og\Unit

Code

protected function setUp() : void {
  $this->entityFormBuilder = $this
    ->prophesize(EntityFormBuilderInterface::class);
  $this->group = $this
    ->prophesize(ContentEntityInterface::class);
  $this->membershipManager = $this
    ->prophesize(MembershipManagerInterface::class);
  $this->ogAccess = $this
    ->prophesize(OgAccessInterface::class);
  $this->messenger = $this
    ->prophesize(MessengerInterface::class);
  $this->ogMembership = $this
    ->prophesize(OgMembershipInterface::class);
  $this->url = $this
    ->prophesize(Url::class);
  $this->user = $this
    ->prophesize(AccountInterface::class);
  $this->entityTypeManager = $this
    ->prophesize(EntityTypeManagerInterface::class);
  $this->userId = rand(20, 50);
  $this->user
    ->id()
    ->willReturn($this->userId);

  // Set the container for the string translation service.
  $container = new ContainerBuilder();
  $container
    ->set('current_user', $this->user
    ->reveal());
  $container
    ->set('entity.form_builder', $this->entityFormBuilder
    ->reveal());
  $container
    ->set('og.membership_manager', $this->membershipManager
    ->reveal());
  $container
    ->set('string_translation', $this
    ->getStringTranslationStub());
  $container
    ->set('entity_type.manager', $this->entityTypeManager
    ->reveal());
  \Drupal::setContainer($container);
}