You are here

public function PaymentReferenceBaseTest::setUp in Payment 8.2

Overrides UnitTestCase::setUp

File

tests/src/Unit/Element/PaymentReferenceBaseTest.php, line 160

Class

PaymentReferenceBaseTest
@coversDefaultClass \Drupal\payment\Element\PaymentReferenceBase

Namespace

Drupal\Tests\payment\Unit\Element

Code

public function setUp() : void {
  $plugin_type_id = $this
    ->randomMachineName();
  $plugin_manager_service_id = 'foo.bar';
  $plugin_configuration_schema_id = sprintf('plugin.plugin_configuration.%s.*', $plugin_type_id);
  $plugin_type_definition = [
    'id' => $plugin_type_id,
    'label' => $this
      ->randomMachineName(),
    'provider' => $this
      ->randomMachineName(),
    'plugin_manager_service_id' => $plugin_manager_service_id,
  ];
  $this->currentUser = $this
    ->createMock(AccountInterface::class);
  $this->dateFormatter = $this
    ->getMockBuilder(DateFormatter::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->linkGenerator = $this
    ->createMock(LinkGeneratorInterface::class);
  $this->paymentMethodManager = $this
    ->createMock(PaymentMethodManagerInterface::class);
  $this->container = $this
    ->prophesize(ContainerInterface::class);
  $this->container
    ->get($plugin_manager_service_id)
    ->willReturn($this->paymentMethodManager);
  $class_resolver = $this
    ->createMock(ClassResolverInterface::class);
  $this->stringTranslation = $this
    ->getStringTranslationStub();
  $this->messenger = $this
    ->createMock(MessengerInterface::class);
  $typed_config_manager = $this
    ->prophesize(TypedConfigManagerInterface::class);
  $typed_config_manager
    ->hasConfigSchema($plugin_configuration_schema_id)
    ->willReturn(TRUE);
  $this->paymentMethodType = new PluginType($plugin_type_definition, $this->container
    ->reveal(), $this->stringTranslation, $class_resolver, $typed_config_manager
    ->reveal());
  $this->paymentQueue = $this
    ->createMock(QueueInterface::class);
  $this->paymentStorage = $this
    ->createMock(EntityStorageInterface::class);
  $this->pluginSelectorManager = $this
    ->createMock(PluginSelectorManagerInterface::class);
  $this->renderer = $this
    ->createMock(RendererInterface::class);
  $this->requestStack = $this
    ->getMockBuilder(RequestStack::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->urlGenerator = $this
    ->createMock(UrlGeneratorInterface::class);
  $container = new Container();
  $container
    ->set('renderer', $this->renderer);
  \Drupal::setContainer($container);
  $configuration = [];
  $plugin_id = $this
    ->randomMachineName();
  $this->pluginDefinition['class'] = $this
    ->randomMachineName();
  $this->sut = $this
    ->getMockBuilder(PaymentReferenceBase::class)
    ->setConstructorArgs(array(
    $configuration,
    $plugin_id,
    $this->pluginDefinition,
    $this->requestStack,
    $this->paymentStorage,
    $this->stringTranslation,
    $this->dateFormatter,
    $this->linkGenerator,
    $this->renderer,
    $this->currentUser,
    $this->pluginSelectorManager,
    $this->paymentMethodType,
    new Random(),
  ))
    ->getMockForAbstractClass();
  $this->sut
    ->expects($this
    ->any())
    ->method('getPaymentQueue')
    ->willReturn($this->paymentQueue);
  $this->sut
    ->setMessenger($this->messenger);
}