function DateHelperTest::setUp

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Datetime/DateHelperTest.php \Drupal\Tests\Core\Datetime\DateHelperTest::setUp()
  2. 10 core/tests/Drupal/Tests/Core/Datetime/DateHelperTest.php \Drupal\Tests\Core\Datetime\DateHelperTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Datetime/DateHelperTest.php, line 28

Class

DateHelperTest
@coversDefaultClass \Drupal\Core\Datetime\DateHelper @group Datetime

Namespace

Drupal\Tests\Core\Datetime

Code

protected function setUp() : void {
    parent::setUp();
    $container = new ContainerBuilder();
    $config = [
        'system.date' => [
            'first_day' => 'Sunday',
        ],
    ];
    $container->set('config.factory', $this->getConfigFactoryStub($config));
    $this->languageManager = $this->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
    $language = new Language([
        'langcode' => 'en',
    ]);
    $this->languageManager
        ->expects($this->any())
        ->method('getDefaultLanguage')
        ->willReturn($language);
    $this->languageManager
        ->expects($this->any())
        ->method('getCurrentLanguage')
        ->willReturn($language);
    $container->set('language_manager', $this->languageManager);
    \Drupal::setContainer($container);
}

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