You are here

public function PathContextTest::testShouldAttach in Acquia Lift Connector 8

Tests the shouldAttach() method.

@covers ::shouldAttach

@dataProvider providerTestShouldAttach

Parameters

boolean $set_invalid_credential:

boolean $do_match_pattern:

array $expect_should_attach:

File

tests/src/Unit/Service/Context/PathContextTest.php, line 110
Contains \Drupal\Tests\acquia_lift\Service\Context\PathContextTest.

Class

PathContextTest
PathContextTest Test.

Namespace

Drupal\Tests\acquia_lift\Service\Context

Code

public function testShouldAttach($set_invalid_credential, $do_match_pattern, $expect_should_attach) {
  $credential_settings = $this
    ->getValidCredentialSettings();
  if ($set_invalid_credential) {
    $credential_settings['api_url'] = '';
  }
  $this->settings
    ->expects($this
    ->at(0))
    ->method('get')
    ->with('credential')
    ->willReturn($credential_settings);
  $this->pathMatcher
    ->expects($this
    ->any())
    ->method('match')
    ->with('my_current_path', "/admin\n/admin/*\n/batch\n/node/add*\n/node/*/*\n/user/*/*")
    ->willReturn($do_match_pattern);
  $path_context = new PathContext($this->configFactory, $this->currentPathStack, $this->requestStack, $this->pathMatcher);
  $should_attach = $path_context
    ->shouldAttach();
  $this
    ->assertEquals($expect_should_attach, $should_attach);
}