diff --git a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php index 42f309d6d772..0f068ab9ee0d 100644 --- a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php +++ b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php @@ -2,6 +2,8 @@ namespace Drupal\datetime\Tests\Views; +@trigger_error('\Drupal\datetime\Tests\Views\DateTimeHandlerTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\BrowserTestBase', E_USER_DEPRECATED); + use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem; use Drupal\field\Entity\FieldConfig; use Drupal\node\Entity\NodeType; @@ -11,6 +13,9 @@ use Drupal\field\Entity\FieldStorageConfig; /** * Base class for testing datetime handlers. + * + * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. + * Use \Drupal\Tests\BrowserTestBase. */ abstract class DateTimeHandlerTestBase extends HandlerTestBase { diff --git a/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php b/core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php similarity index 94% rename from core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php rename to core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php index e3a17bb9c450..614548395876 100644 --- a/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php +++ b/core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php @@ -1,7 +1,8 @@ nodes[] = $this->drupalCreateNode([ + $node = Node::create([ + 'title' => $this->randomMachineName(8), + 'type' => 'page', 'field_date' => [ 'value' => $date, ] ]); + $node->save(); + $this->nodes[] = $node; } } diff --git a/core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php b/core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php new file mode 100644 index 000000000000..f0c9c786144a --- /dev/null +++ b/core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php @@ -0,0 +1,79 @@ +installEntitySchema('node'); + $this->installEntitySchema('user'); + + // 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']); + } + +} diff --git a/core/modules/datetime/src/Tests/Views/FilterDateTest.php b/core/modules/datetime/tests/src/Kernel/Views/FilterDateTest.php similarity index 90% rename from core/modules/datetime/src/Tests/Views/FilterDateTest.php rename to core/modules/datetime/tests/src/Kernel/Views/FilterDateTest.php index 2a8d7cdb2997..566285e256f9 100644 --- a/core/modules/datetime/src/Tests/Views/FilterDateTest.php +++ b/core/modules/datetime/tests/src/Kernel/Views/FilterDateTest.php @@ -1,8 +1,10 @@ nodes[] = $this->drupalCreateNode([ + $node = Node::create([ + 'title' => $this->randomMachineName(8), + 'type' => 'page', 'field_date' => [ 'value' => $date, ] ]); + $node->save(); + $this->nodes[] = $node; } } diff --git a/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php b/core/modules/datetime/tests/src/Kernel/Views/FilterDateTimeTest.php similarity index 94% rename from core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php rename to core/modules/datetime/tests/src/Kernel/Views/FilterDateTimeTest.php index a15263d57d27..1e8e929f3342 100644 --- a/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php +++ b/core/modules/datetime/tests/src/Kernel/Views/FilterDateTimeTest.php @@ -1,7 +1,8 @@ format(static::$date, 'custom', DATETIME_DATETIME_STORAGE_FORMAT, DATETIME_STORAGE_TIMEZONE), ]; foreach ($dates as $date) { - $this->nodes[] = $this->drupalCreateNode([ + $node = Node::create([ + 'title' => $this->randomMachineName(8), + 'type' => 'page', 'field_date' => [ 'value' => $date, ] ]); + $node->save(); + $this->nodes[] = $node; } } diff --git a/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php b/core/modules/datetime/tests/src/Kernel/Views/SortDateTimeTest.php similarity index 91% rename from core/modules/datetime/src/Tests/Views/SortDateTimeTest.php rename to core/modules/datetime/tests/src/Kernel/Views/SortDateTimeTest.php index c1f23a04c210..7375c4db29e2 100644 --- a/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php +++ b/core/modules/datetime/tests/src/Kernel/Views/SortDateTimeTest.php @@ -1,7 +1,8 @@ nodes[] = $this->drupalCreateNode([ + $node = Node::create([ + 'title' => $this->randomMachineName(8), + 'type' => 'page', 'field_date' => [ 'value' => $date, ] ]); + $node->save(); + $this->nodes[] = $node; } }