You are here

public function CartLinksRegexpTest::testIsValidSyntax in Ubercart 8.4

Tests that isValidSyntax() throws an exception when the status is locked.

@covers ::isValidSyntax

File

uc_cart_links/tests/src/Unit/CartLinksRegexpTest.php, line 59

Class

CartLinksRegexpTest
@coversDefaultClass \Drupal\uc_cart_links\CartLinksValidator

Namespace

Drupal\Tests\uc_cart_links\Unit

Code

public function testIsValidSyntax() {
  $links = [
    '/cart/add/p23',
    '/cart/add/p23_q5',
    '/cart/add/p23_q5-p18_q2',
    '/cart/add/e-p23_q5-m15-m32',
    '/cart/add/e-p23_q5_a12o5_a19o9_a1oA%20Text%20String_s-ispecialoffer-m77?destination=/cart/checkout',
  ];

  // Test valid links.
  foreach ($links as $link) {
    $this
      ->assertTrue($this->cartLinksValidator
      ->isValidSyntax($link, FALSE));
  }
  $links = [
    '/cart/add/q23',
  ];

  // Test invalid links.
  foreach ($links as $link) {
    $this
      ->assertFalse($this->cartLinksValidator
      ->isValidSyntax($link, FALSE));
  }
}