[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/plugins/styling/_test/ -> colors.test.php (source)

   1  <?php
   2  
   3  /**
   4   * Color handling tests for the styling plugin
   5   *
   6   * @group plugin_styling
   7   * @group plugins
   8   */
   9  class colors_plugin_styling_test extends DokuWikiTest
  10  {
  11  
  12      /**
  13       * @return array
  14       * @see testColorType
  15       */
  16      public function provideColorType()
  17      {
  18          return [
  19              ['foobar', 'text'],
  20              ['white', 'text'],
  21              ['#fff', 'color'],
  22              ['#f0f0f0', 'color'],
  23              ['#f0f0', 'text'],
  24              ['some #f0f0f0 color', 'text'],
  25          ];
  26      }
  27  
  28      /**
  29       * @param string $input
  30       * @param string $expect
  31       * @dataProvider provideColorType
  32       * @noinspection PhpUnhandledExceptionInspection
  33       * @noinspection PhpDocMissingThrowsInspection
  34       */
  35      public function testColorType($input, $expect)
  36      {
  37          $plugin = new admin_plugin_styling();
  38          $output = $this->callInaccessibleMethod($plugin, 'colorType', [$input]);
  39          $this->assertEquals($expect, $output);
  40      }
  41  
  42      /**
  43       * @return array
  44       * @see testColorValue
  45       */
  46      public function provideColorValue()
  47      {
  48          return [
  49              ['foobar', 'foobar'],
  50              ['white', 'white'],
  51              ['#fff', '#ffffff'],
  52              ['#123', '#112233'],
  53              ['#f0f0f0', '#f0f0f0'],
  54              ['#f0f0', '#f0f0'],
  55              ['some #f0f0f0 color', 'some #f0f0f0 color'],
  56          ];
  57      }
  58  
  59      /**
  60       * @param string $input
  61       * @param string $expect
  62       * @dataProvider provideColorValue
  63       * @noinspection PhpUnhandledExceptionInspection
  64       * @noinspection PhpDocMissingThrowsInspection
  65       */
  66      public function testColorValue($input, $expect)
  67      {
  68          $plugin = new admin_plugin_styling();
  69          $output = $this->callInaccessibleMethod($plugin, 'colorValue', [$input]);
  70          $this->assertEquals($expect, $output);
  71      }
  72  }