You are here

public function JQueryColorpickerServiceTest::providerTestValidateColor in Jquery Colorpicker 8

Provides data for the testValidateColor test.

File

tests/src/Unit/Service/jQueryColorpickerServiceTest.php, line 76

Class

JQueryColorpickerServiceTest
@coversDefaultClass \Drupal\jquery_colorpicker\Service\JQueryColorpickerService @group jquery_colorpicker

Namespace

Drupal\Test\jquery_colorpicker\Service

Code

public function providerTestValidateColor() {
  $container = new ContainerBuilder();
  $container
    ->set('string_translation', $this
    ->getStringTranslationStub());
  \Drupal::setContainer($container);
  $type_error = $this
    ->t('Color must be a string or an integer');
  $length_error = $this
    ->t('Color values must be exactly six characters in length');
  $hex_error = $this
    ->t("You entered an invalid value for the color. Colors must be hexadecimal, and can only contain the characters '0-9', 'a-f' and/or 'A-F'.");
  $data = [];
  $data[] = [
    $type_error,
    TRUE,
  ];
  $data[] = [
    $type_error,
    FALSE,
  ];
  $data[] = [
    $type_error,
    [],
  ];
  $test = new \stdClass();
  $data[] = [
    $type_error,
    $test,
  ];
  $data[] = [
    $type_error,
    1.23,
  ];
  $data[] = [
    $length_error,
    12345,
  ];
  $data[] = [
    $length_error,
    "12345",
  ];
  $data[] = [
    $hex_error,
    "11111g",
  ];
  $data[] = [
    $hex_error,
    "11111G",
  ];
  $data[] = [
    $hex_error,
    "fffffg",
  ];
  $data[] = [
    $hex_error,
    "fffffG",
  ];
  $data[] = [
    $hex_error,
    "FFFFFg",
  ];
  $data[] = [
    $hex_error,
    "FFFFFG",
  ];

  // Valid submissions.
  $data[] = [
    FALSE,
    123456,
  ];
  $data[] = [
    FALSE,
    "123456",
  ];
  $data[] = [
    FALSE,
    "11111f",
  ];
  $data[] = [
    FALSE,
    "11111F",
  ];
  $data[] = [
    FALSE,
    "FFFFF1",
  ];
  $data[] = [
    FALSE,
    "fffff1",
  ];
  return $data;
}