class TocFilterOptionsTest in TOC filter 8.2
Tests TOC filter formatter.
@group TocFilter
@coversDefaultClass \Drupal\toc_filter\Plugin\Filter\TocFilter
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\toc_filter\Unit\TocFilterOptionsTest
Expanded class hierarchy of TocFilterOptionsTest
File
- tests/
src/ Unit/ TocFilterOptionsTest.php, line 20 - Contains \Drupal\Tests\toc_filter\Unit\TocFilterOptionsTest.
Namespace
Drupal\Tests\toc_filter\UnitView source
class TocFilterOptionsTest extends UnitTestCase {
/**
* Tests converting string of options with TocFilter::parseOptions().
*
* @param string $string
* The string to run through TocFilter::parseOptions().
* @param string $expected
* The expected result from calling the function.
*
* @see TocFilter::parseOptions()
*
* @dataProvider providerParseOptions
*/
public function testParseOptions($string, $expected) {
$result = TocFilter::parseOptions($string);
$this
->assertEquals($expected, $result);
}
/**
* Data provider for testParseOptions().
*
* @see testParseOptions()
*/
public function providerParseOptions() {
$tests[] = [
'value name=\'value\'',
[
'value' => TRUE,
'name' => 'value',
],
];
$tests[] = [
'one=\'value\' two=value three="value" four="value"',
[
'one' => 'value',
'two' => 'value',
'three' => 'value',
'four' => 'value',
],
];
$tests[] = [
'one=\'value\' two=value three="value" four="value"',
[
'one' => 'value',
'two' => 'value',
'three' => 'value',
'four' => 'value',
],
];
$tests[] = [
'one=1 two=2.0 three="3.3"',
[
'one' => 1,
'two' => 2,
'three' => 3.3,
],
];
$tests[] = [
'one=TRUE two=False three',
[
'one' => TRUE,
'two' => FALSE,
'three' => TRUE,
],
];
$tests[] = [
'parent_option.child_option=value',
[
'parent_option' => [
'child_option' => 'value',
],
],
];
$tests[] = [
'h2.number_type=decimal',
[
'headers' => [
'h2' => [
'number_type' => 'decimal',
],
],
],
];
return $tests;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
TocFilterOptionsTest:: |
public | function | Data provider for testParseOptions(). | |
TocFilterOptionsTest:: |
public | function | Tests converting string of options with TocFilter::parseOptions(). | |
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. | |
UnitTestCase:: |
protected | function | 340 |