public function DateTimeTest::testGetTimezoneConfiguration in Feeds 8.3
Test the timezone configuration.
File
- tests/
src/ Unit/ Feeds/ Target/ DateTimeTest.php, line 107
Class
- DateTimeTest
- @coversDefaultClass \Drupal\feeds\Feeds\Target\DateTime @group feeds
Namespace
Drupal\Tests\feeds\Unit\Feeds\TargetCode
public function testGetTimezoneConfiguration() {
// Timezone setting for default timezone.
$container = new ContainerBuilder();
$config = [
'system.date' => [
'timezone.default' => 'UTC',
],
];
$container
->set('config.factory', $this
->getConfigFactoryStub($config));
\Drupal::setContainer($container);
$method = $this
->getMethod('Drupal\\feeds\\Feeds\\Target\\DateTime', 'prepareTarget')
->getClosure();
$this->targetDefinition = $method($this
->getMockFieldDefinition([
'datetime_type' => 'date',
]));
// Test timezone options with one of the timezones.
$configuration = [
'feed_type' => $this->feedType,
'target_definition' => $this->targetDefinition,
'timezone' => 'Europe/Helsinki',
];
$target = new DateTime($configuration, 'datetime', []);
$method = $this
->getProtectedClosure($target, 'getTimezoneConfiguration');
$this
->assertSame('Europe/Helsinki', $method());
// Test timezone options with site default option.
$configuration = [
'feed_type' => $this->feedType,
'target_definition' => $this->targetDefinition,
'timezone' => '__SITE__',
];
$target = new DateTime($configuration, 'datetime', []);
$method = $this
->getProtectedClosure($target, 'getTimezoneConfiguration');
$this
->assertSame('UTC', $method());
}