public function NgLightboxTest::testPatternMatching in NG Lightbox 8
Same name and namespace in other branches
- 2.x src/Tests/NgLightboxTest.php \Drupal\ng_lightbox\Tests\NgLightboxTest::testPatternMatching()
Test the pattern matching for link paths.
File
- src/
Tests/ NgLightboxTest.php, line 47 - NG Lightbox tests.
Class
- NgLightboxTest
- Test basic functionality of the lightbox.
Namespace
Drupal\ng_lightbox\TestsCode
public function testPatternMatching() {
// Test the patterns are enabled on links as expected.
$node = Node::create([
'type' => 'page',
'title' => $this
->randomString(),
]);
$node
->save();
$config = \Drupal::configFactory()
->getEditable('ng_lightbox.settings');
$config
->set('patterns', $node
->toUrl())
->save();
$this
->assertLightboxEnabled(Link::fromTextAndUrl('Normal Path', $node
->toUrl()));
// Create a second node and make sure it doesn't get lightboxed.
$node = Node::create([
'type' => 'page',
'title' => $this
->randomString(),
]);
$node
->save();
$this
->assertLightboxNotEnabled(Link::fromTextAndUrl('Normal Path', $node
->toUrl()));
// @TODO, these were in D7 but in D8, I can't see how you can even generate
// a link with such a format so maybe it isn't needed at all?
// The uppercase path should still be matched for a lightbox.
// $this->assertLightboxNotEnabled(\Drupal::l('Uppercase Path', 'NODE/1'));
// $this->assertLightboxNotEnabled(\Drupal::l('Alaised Path', $alias));
// $this->assertLightboxNotEnabled(\Drupal::l('Empty Path', ''));
}