You are here

protected function ContentHubInternalRequestTest::setUp in Acquia Content Hub 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/ContentHubInternalRequestTest.php, line 88

Class

ContentHubInternalRequestTest
PHPUnit for the ContentHubInternalRequest class.

Namespace

Drupal\Tests\acquia_contenthub\Unit

Code

protected function setUp() {
  parent::setUp();

  // Setting up Drupal container.
  $this->container = $this
    ->createMock('Drupal\\Core\\DependencyInjection\\Container');
  \Drupal::setContainer($this->container);
  $prophecy = $this
    ->prophesize(Config::class);
  $prophecy
    ->get('user_role')
    ->willReturn(AccountInterface::ANONYMOUS_ROLE);
  $config = $prophecy
    ->reveal();
  $config_factory = $this
    ->prophesize(ConfigFactoryInterface::class);
  $config_factory
    ->get('acquia_contenthub.entity_config')
    ->willReturn($config);
  $config_factory
    ->getEditable('acquia_contenthub.admin_settings')
    ->willReturn($config);
  $this->loggerFactory = $this
    ->prophesize(LoggerChannelFactoryInterface::class)
    ->reveal();
  $this->kernel = $this
    ->createMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
  $this->accountSwitcher = $this
    ->prophesize(AccountSwitcherInterface::class)
    ->reveal();
  $this->requestStack = $this
    ->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack')
    ->disableOriginalConstructor()
    ->getMock();
  $this->clientManager = $this
    ->getMockBuilder('Drupal\\acquia_contenthub\\Client\\ClientManager')
    ->disableOriginalConstructor()
    ->getMock();
  $state = $this
    ->prophesize(StateInterface::class);
  $state
    ->get('acquia_contenthub.shared_secret')
    ->willReturn('shared_secret');
  $this->contentHubSubscription = new ContentHubSubscription($this->loggerFactory, $config_factory
    ->reveal(), $this->clientManager, $state
    ->reveal());

  // Initializing service.
  $this->contentHubInternalRequest = new ContentHubInternalRequest($this->kernel, $this->contentHubSubscription, $this->accountSwitcher, $config_factory
    ->reveal(), $this->loggerFactory, $this->requestStack);
}