You are here

public function WebformBreadcrumbBuilderTest::testBuildSourceEntityUserResults in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Kernel/Breadcrumb/WebformBreadcrumbBuilderTest.php \Drupal\Tests\webform\Kernel\Breadcrumb\WebformBreadcrumbBuilderTest::testBuildSourceEntityUserResults()

Test build source entity submissions breadcrumbs.

File

tests/src/Kernel/Breadcrumb/WebformBreadcrumbBuilderTest.php, line 321

Class

WebformBreadcrumbBuilderTest
Test webform breadcrumb builder.

Namespace

Drupal\Tests\webform\Kernel\Breadcrumb

Code

public function testBuildSourceEntityUserResults() {
  $this
    ->setSourceEntity($this->node);
  $webform_submission_access = $this
    ->getMockBuilder('Drupal\\webform\\WebformSubmissionInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $webform_submission_access
    ->expects($this
    ->any())
    ->method('access')
    ->will($this
    ->returnCallback(function ($operation) {
    return $operation === 'view_own';
  }));
  $route_match = $this
    ->getMockRouteMatch('entity.node.webform_submission.canonical', [
    [
      'webform_submission',
      $webform_submission_access,
    ],
    [
      'webform',
      $this->webform,
    ],
    [
      'node',
      $this->node,
    ],
  ]);
  $links = [
    Link::createFromRoute('Home', '<front>'),
    $this->node
      ->toLink(),
    Link::createFromRoute('Results', 'entity.node.webform.user.submissions', [
      'node' => 1,
    ]),
  ];
  $this
    ->assertLinks($route_match, $links);
}