You are here

protected function InvoiceOrderAccessCheckTest::getRouteMatch in Commerce Invoice 8.2

Returns a route match object for the access check.

Parameters

\Drupal\commerce_order\Entity\OrderInterface|null $order: A commerce order entity.

\Drupal\commerce_invoice\Entity\InvoiceTypeInterface|null $invoice_type: An invoice type entity.

Return value

\Drupal\Core\Routing\RouteMatchInterface|object|\Prophecy\Prophecy\ProphecySubjectInterface A test route match object.

3 calls to InvoiceOrderAccessCheckTest::getRouteMatch()
InvoiceOrderAccessCheckTest::testAccessForDraftOrders in tests/src/Kernel/InvoiceOrderAccessCheckTest.php
@covers ::access
InvoiceOrderAccessCheckTest::testAccessWithoutPermission in tests/src/Kernel/InvoiceOrderAccessCheckTest.php
@covers ::access
InvoiceOrderAccessCheckTest::testAccessWithPartialInvoices in tests/src/Kernel/InvoiceOrderAccessCheckTest.php
@covers ::access

File

tests/src/Kernel/InvoiceOrderAccessCheckTest.php, line 198

Class

InvoiceOrderAccessCheckTest
Tests the 'access_check.invoice_order' access checker.

Namespace

Drupal\Tests\commerce_invoice\Kernel

Code

protected function getRouteMatch($order = NULL, $invoice_type = NULL) {
  if (!$order) {
    $order = $this
      ->prophesize(OrderInterface::class)
      ->reveal();
  }
  if (!$invoice_type) {
    $invoice_type = $this
      ->prophesize(InvoiceTypeInterface::class);
    $invoice_type
      ->id()
      ->willReturn('default');
    $invoice_type = $invoice_type
      ->reveal();
  }

  /** @var \Drupal\Core\Routing\RouteMatchInterface|\Prophecy\Prophecy\ObjectProphecy $route_match */
  $route_match = $this
    ->prophesize(RouteMatchInterface::class);
  $route_match
    ->getRawParameter('commerce_order')
    ->willReturn($order
    ->id());
  $route_match
    ->getParameter('commerce_order')
    ->willReturn($order);
  $route_match
    ->getRawParameter('commerce_invoice_type')
    ->willReturn($invoice_type
    ->id());
  $route_match
    ->getParameter('commerce_invoice_type')
    ->willReturn($invoice_type);
  return $route_match
    ->reveal();
}