class JQueryColorpickerServiceTest in Jquery Colorpicker 8.2
Same name and namespace in other branches
- 8 tests/src/Unit/Service/jQueryColorpickerServiceTest.php \Drupal\Test\jquery_colorpicker\Service\JQueryColorpickerServiceTest
@coversDefaultClass \Drupal\jquery_colorpicker\Service\JQueryColorpickerService @group jquery_colorpicker
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Test\jquery_colorpicker\Service\JQueryColorpickerServiceTest uses StringTranslationTrait
Expanded class hierarchy of JQueryColorpickerServiceTest
File
- tests/
src/ Unit/ Service/ jQueryColorpickerServiceTest.php, line 14
Namespace
Drupal\Test\jquery_colorpicker\ServiceView source
class JQueryColorpickerServiceTest extends UnitTestCase {
use StringTranslationTrait;
/**
* The JQuery Colorpicker Service.
*
* @var \Drupal\jquery_colorpicker\Service\JQueryColorpickerService
*/
protected $JQueryColorpickerService;
/**
* {@inheritdoc}
*/
public function setUp() {
$container = new ContainerBuilder();
$container
->set('string_translation', $this
->getStringTranslationStub());
\Drupal::setContainer($container);
$this->JQueryColorpickerService = new JQueryColorpickerService();
}
/**
* @covers ::validateHexColor
*
* @dataProvider providerTestValidateHexColor
*/
public function testValidateHexColor($expected, $color) {
$this
->assertEquals($expected, $this->JQueryColorpickerService
->validateHexColor($color));
}
/**
* Provides data for the testValidateHexColor test.
*/
public function providerTestValidateHexColor() {
$data = [];
$data[] = [
FALSE,
FALSE,
];
$data[] = [
FALSE,
[],
];
$test = new \stdClass();
$data[] = [
FALSE,
$test,
];
$data[] = [
FALSE,
1.23,
];
$data[] = [
FALSE,
12345,
];
$data[] = [
FALSE,
"12345",
];
$data[] = [
FALSE,
"11111g",
];
$data[] = [
FALSE,
"11111G",
];
$data[] = [
FALSE,
"fffffg",
];
$data[] = [
FALSE,
"fffffG",
];
$data[] = [
FALSE,
"FFFFFg",
];
$data[] = [
FALSE,
"FFFFFG",
];
$data[] = [
FALSE,
"#12345",
];
$data[] = [
FALSE,
"#11111g",
];
$data[] = [
FALSE,
"#11111G",
];
$data[] = [
FALSE,
"#fffffg",
];
$data[] = [
FALSE,
"#fffffG",
];
$data[] = [
FALSE,
"#FFFFFg",
];
$data[] = [
FALSE,
"#FFFFFG",
];
// Valid submissions.
$data[] = [
TRUE,
"#FFF",
];
$data[] = [
TRUE,
"#123456",
];
$data[] = [
TRUE,
"#11111f",
];
$data[] = [
TRUE,
"#11111F",
];
$data[] = [
TRUE,
"#FFFFF1",
];
$data[] = [
TRUE,
"#fffff1",
];
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JQueryColorpickerServiceTest:: |
protected | property | The JQuery Colorpicker Service. | |
JQueryColorpickerServiceTest:: |
public | function | Provides data for the testValidateHexColor test. | |
JQueryColorpickerServiceTest:: |
public | function |
Overrides UnitTestCase:: |
|
JQueryColorpickerServiceTest:: |
public | function | @covers ::validateHexColor | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |