class DateTimeHandlerTestBase
Same name in this branch
- 8.9.x core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php \Drupal\Tests\datetime\Kernel\Views\DateTimeHandlerTestBase
Same name in other branches
- 9 core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php \Drupal\Tests\datetime\Kernel\Views\DateTimeHandlerTestBase
- 10 core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php \Drupal\Tests\datetime\Kernel\Views\DateTimeHandlerTestBase
- 11.x core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php \Drupal\Tests\datetime\Kernel\Views\DateTimeHandlerTestBase
Base class for testing datetime handlers.
Hierarchy
- class \Drupal\simpletest\TestBase uses \Drupal\Tests\AssertHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\Traits\Core\GeneratePermutationsTrait, \Drupal\Tests\ConfigTestTrait
- class \Drupal\simpletest\WebTestBase extends \Drupal\simpletest\TestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\TestFileCreationTrait, \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\Traits\Core\CronRunTrait, \Drupal\Core\Test\AssertMailTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\EntityViewTrait
- class \Drupal\views\Tests\ViewTestBase extends \Drupal\simpletest\WebTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait
- class \Drupal\views\Tests\Handler\HandlerTestBase extends \Drupal\views\Tests\ViewTestBase
- class \Drupal\datetime\Tests\Views\DateTimeHandlerTestBase extends \Drupal\views\Tests\Handler\HandlerTestBase
- class \Drupal\views\Tests\Handler\HandlerTestBase extends \Drupal\views\Tests\ViewTestBase
- class \Drupal\views\Tests\ViewTestBase extends \Drupal\simpletest\WebTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait
- class \Drupal\simpletest\WebTestBase extends \Drupal\simpletest\TestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\TestFileCreationTrait, \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\Traits\Core\CronRunTrait, \Drupal\Core\Test\AssertMailTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\EntityViewTrait
Expanded class hierarchy of DateTimeHandlerTestBase
Deprecated
in drupal:8.4.0 and is removed from drupal:9.0.0. Use \Drupal\Tests\BrowserTestBase.
File
-
core/
modules/ datetime/ src/ Tests/ Views/ DateTimeHandlerTestBase.php, line 20
Namespace
Drupal\datetime\Tests\ViewsView source
abstract class DateTimeHandlerTestBase extends HandlerTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'datetime_test',
'node',
'datetime',
];
/**
* Name of the field.
*
* Note, this is used in the default test view.
*
* @var string
*/
protected static $field_name = 'field_date';
/**
* Nodes to test.
*
* @var \Drupal\node\NodeInterface[]
*/
protected $nodes = [];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
// Add a date field to page nodes.
$node_type = NodeType::create([
'type' => 'page',
'name' => 'page',
]);
$node_type->save();
$fieldStorage = FieldStorageConfig::create([
'field_name' => static::$field_name,
'entity_type' => 'node',
'type' => 'datetime',
'settings' => [
'datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME,
],
]);
$fieldStorage->save();
$field = FieldConfig::create([
'field_storage' => $fieldStorage,
'bundle' => 'page',
'required' => TRUE,
]);
$field->save();
// Views needs to be aware of the new field.
$this->container
->get('views.views_data')
->clear();
// Set column map.
$this->map = [
'nid' => 'nid',
];
// Load test views.
ViewTestData::createTestViews(get_class($this), [
'datetime_test',
]);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
DateTimeHandlerTestBase::$field_name | protected static | property | Name of the field. |
DateTimeHandlerTestBase::$modules | public static | property | |
DateTimeHandlerTestBase::$nodes | protected | property | Nodes to test. |
DateTimeHandlerTestBase::setUp | protected | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.