function TimeZoneFormHelperTest::testGetList

Same name in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Datetime/TimeZoneFormHelperTest.php \Drupal\Tests\Core\Datetime\TimeZoneFormHelperTest::testGetList()

@covers ::getOptionsList @covers ::getOptionsListByRegion

File

core/tests/Drupal/Tests/Core/Datetime/TimeZoneFormHelperTest.php, line 32

Class

TimeZoneFormHelperTest
@coversDefaultClass \Drupal\Core\Datetime\TimeZoneFormHelper @group Datetime

Namespace

Drupal\Tests\Core\Datetime

Code

public function testGetList() : void {
    // Test the default parameters for getOptionsList().
    $result = TimeZoneFormHelper::getOptionsList();
    $this->assertIsArray($result);
    $this->assertArrayHasKey('Africa/Dar_es_Salaam', $result);
    $this->assertEquals('Africa/Dar es Salaam', $result['Africa/Dar_es_Salaam']);
    // Test that the ungrouped and grouped results have the same number of
    // items.
    $ungrouped_count = count(TimeZoneFormHelper::getOptionsList());
    $grouped_result = TimeZoneFormHelper::getOptionsListByRegion();
    $grouped_count = 0;
    array_walk_recursive($grouped_result, function () use (&$grouped_count) {
        $grouped_count++;
    });
    $this->assertEquals($ungrouped_count, $grouped_count);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.