You are here

class ChartsDefaultColorsTest in Charts 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Unit/Settings/ChartsDefaultColorsTest.php \Drupal\Tests\charts\Unit\Settings\ChartsDefaultColorsTest
  2. 5.0.x tests/src/Unit/Settings/ChartsDefaultColorsTest.php \Drupal\Tests\charts\Unit\Settings\ChartsDefaultColorsTest

Tests the ChartDefaultColors class.

@coversDefaultClass \Drupal\charts\Settings\ChartsDefaultColors @group charts

Hierarchy

Expanded class hierarchy of ChartsDefaultColorsTest

File

tests/src/Unit/Settings/ChartsDefaultColorsTest.php, line 14

Namespace

Drupal\Tests\charts\Unit\Settings
View source
class ChartsDefaultColorsTest extends UnitTestCase {

  /**
   * @var \Drupal\charts\Settings\ChartsDefaultColors
   */
  private $chartsDefaultColors;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $this->chartsDefaultColors = new ChartsDefaultColors();
  }

  /**
   * {@inheritdoc}
   */
  public function tearDown() {
    parent::tearDown();
    $this->chartsDefaultColors = NULL;
  }

  /**
   * Tests the number of default colors.
   */
  public function testNumberOfDefaultColors() {
    $this
      ->assertCount(10, $this->chartsDefaultColors
      ->getDefaultColors());
  }

  /**
   * Tests getter and setter for default colors.
   *
   * @param array $color
   *   An array of color codes.
   *
   * @dataProvider colorProvider
   */
  public function testDefaultColors(array $color) {
    $this->chartsDefaultColors
      ->setDefaultColors($color);
    $this
      ->assertArrayEquals($color, $this->chartsDefaultColors
      ->getDefaultColors());
  }

  /**
   * Data provider for setDefaultColors().
   */
  public function colorProvider() {
    (yield [
      [
        '#2f7ed8',
      ],
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ChartsDefaultColorsTest::$chartsDefaultColors private property
ChartsDefaultColorsTest::colorProvider public function Data provider for setDefaultColors().
ChartsDefaultColorsTest::setUp public function Overrides UnitTestCase::setUp
ChartsDefaultColorsTest::tearDown public function
ChartsDefaultColorsTest::testDefaultColors public function Tests getter and setter for default colors.
ChartsDefaultColorsTest::testNumberOfDefaultColors public function Tests the number of default colors.
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.
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.