You are here

class TocFilterOptionsTest in TOC filter 8.2

Tests TOC filter formatter.

@group TocFilter

@coversDefaultClass \Drupal\toc_filter\Plugin\Filter\TocFilter

Hierarchy

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\Unit
View 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

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
TocFilterOptionsTest::providerParseOptions public function Data provider for testParseOptions().
TocFilterOptionsTest::testParseOptions public function Tests converting string of options with TocFilter::parseOptions().
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUp protected function 340