You are here

public function RegexTest::provideHtmlPatterns in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/validator/Tests/Constraints/RegexTest.php \Constraints\RegexTest::provideHtmlPatterns()

File

vendor/symfony/validator/Tests/Constraints/RegexTest.php, line 28

Class

RegexTest
@author Bernhard Schussek <bschussek@gmail.com>

Namespace

Constraints

Code

public function provideHtmlPatterns() {
  return array(
    // HTML5 wraps the pattern in ^(?:pattern)$
    array(
      '/^[0-9]+$/',
      '[0-9]+',
    ),
    array(
      '/[0-9]+$/',
      '.*[0-9]+',
    ),
    array(
      '/^[0-9]+/',
      '[0-9]+.*',
    ),
    array(
      '/[0-9]+/',
      '.*[0-9]+.*',
    ),
    // We need a smart way to allow matching of patterns that contain
    // ^ and $ at various sub-clauses of an or-clause
    // .*(pattern).* seems to work correctly
    array(
      '/[0-9]$|[a-z]+/',
      '.*([0-9]$|[a-z]+).*',
    ),
    array(
      '/[0-9]$|^[a-z]+/',
      '.*([0-9]$|^[a-z]+).*',
    ),
    array(
      '/^[0-9]|[a-z]+$/',
      '.*(^[0-9]|[a-z]+$).*',
    ),
    // Unescape escaped delimiters
    array(
      '/^[0-9]+\\/$/',
      '[0-9]+/',
    ),
    array(
      '#^[0-9]+\\#$#',
      '[0-9]+#',
    ),
    // Cannot be converted
    array(
      '/^[0-9]+$/i',
      null,
    ),
    // Inverse matches are simple, just wrap in
    // ((?!pattern).)*
    array(
      '/^[0-9]+$/',
      '((?!^[0-9]+$).)*',
      false,
    ),
    array(
      '/[0-9]+$/',
      '((?![0-9]+$).)*',
      false,
    ),
    array(
      '/^[0-9]+/',
      '((?!^[0-9]+).)*',
      false,
    ),
    array(
      '/[0-9]+/',
      '((?![0-9]+).)*',
      false,
    ),
    array(
      '/[0-9]$|[a-z]+/',
      '((?![0-9]$|[a-z]+).)*',
      false,
    ),
    array(
      '/[0-9]$|^[a-z]+/',
      '((?![0-9]$|^[a-z]+).)*',
      false,
    ),
    array(
      '/^[0-9]|[a-z]+$/',
      '((?!^[0-9]|[a-z]+$).)*',
      false,
    ),
    array(
      '/^[0-9]+\\/$/',
      '((?!^[0-9]+/$).)*',
      false,
    ),
    array(
      '#^[0-9]+\\#$#',
      '((?!^[0-9]+#$).)*',
      false,
    ),
    array(
      '/^[0-9]+$/i',
      null,
      false,
    ),
  );
}