diff --git a/core/modules/datetime/datetime.views.inc b/core/modules/datetime/datetime.views.inc index 8b26bd5..c12a3ac 100644 --- a/core/modules/datetime/datetime.views.inc +++ b/core/modules/datetime/datetime.views.inc @@ -23,22 +23,22 @@ function datetime_field_views_data(FieldStorageConfigInterface $field_storage) { // Create year, month, and day arguments. $group = $data[$table_name][$field_storage->getName() . '_value']['group']; - $arguments = array( + $arguments = [ // Argument type => help text. 'year' => t('Date in the form of YYYY.'), 'month' => t('Date in the form of MM.'), 'day' => t('Date in the form of DD.'), - ); + ]; foreach ($arguments as $argument_type => $help_text) { - $data[$table_name][$field_storage->getName() . '_value_' . $argument_type] = array( + $data[$table_name][$field_storage->getName() . '_value_' . $argument_type] = [ 'title' => $field_storage->getLabel() . ' (' . $argument_type . ')', 'help' => $help_text, - 'argument' => array( + 'argument' => [ 'field' => $field_storage->getName() . '_value', 'id' => 'datetime_' . $argument_type, - ), + ], 'group' => $group, - ); + ]; } // Set the 'datetime' sort handler. diff --git a/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php b/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php index a7d9e92..1890684 100644 --- a/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php +++ b/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php @@ -19,7 +19,7 @@ class ArgumentDateTimeTest extends DateTimeHandlerTestBase { /** * {@inheritdoc} */ - public static $testViews = array('test_argument_datetime'); + public static $testViews = ['test_argument_datetime']; /** * {@inheritdoc} @@ -28,17 +28,17 @@ public function setUp() { parent::setUp(); // Add some basic test nodes. - $dates = array( + $dates = [ '2000-10-10', '2001-10-10', '2002-01-01', - ); + ]; foreach ($dates as $date) { - $this->nodes[] = $this->drupalCreateNode(array( - 'field_date' => array( + $this->nodes[] = $this->drupalCreateNode([ + 'field_date' => [ 'value' => $date, - ) - )); + ] + ]); } } @@ -52,16 +52,16 @@ public function testDatetimeArgumentYear() { // The 'default' display has the 'year' argument. $view->setDisplay('default'); - $this->executeView($view, array('2000')); - $expected = array(); - $expected[] = array('nid' => $this->nodes[0]->id()); + $this->executeView($view, ['2000']); + $expected = []; + $expected[] = ['nid' => $this->nodes[0]->id()]; $this->assertIdenticalResultset($view, $expected, $this->map); $view->destroy(); $view->setDisplay('default'); - $this->executeView($view, array('2002')); - $expected = array(); - $expected[] = array('nid' => $this->nodes[2]->id()); + $this->executeView($view, ['2002']); + $expected = []; + $expected[] = ['nid' => $this->nodes[2]->id()]; $this->assertIdenticalResultset($view, $expected, $this->map); $view->destroy(); } @@ -76,17 +76,17 @@ public function testDatetimeArgumentMonth() { // The 'embed_1' display has the 'month' argument. $view->setDisplay('embed_1'); - $this->executeView($view, array('10')); - $expected = array(); - $expected[] = array('nid' => $this->nodes[0]->id()); - $expected[] = array('nid' => $this->nodes[1]->id()); + $this->executeView($view, ['10']); + $expected = []; + $expected[] = ['nid' => $this->nodes[0]->id()]; + $expected[] = ['nid' => $this->nodes[1]->id()]; $this->assertIdenticalResultset($view, $expected, $this->map); $view->destroy(); $view->setDisplay('embed_1'); - $this->executeView($view, array('01')); - $expected = array(); - $expected[] = array('nid' => $this->nodes[2]->id()); + $this->executeView($view, ['01']); + $expected = []; + $expected[] = ['nid' => $this->nodes[2]->id()]; $this->assertIdenticalResultset($view, $expected, $this->map); $view->destroy(); } @@ -101,17 +101,17 @@ public function testDatetimeArgumentDay() { // The 'embed_2' display has the 'day' argument. $view->setDisplay('embed_2'); - $this->executeView($view, array('10')); - $expected = array(); - $expected[] = array('nid' => $this->nodes[0]->id()); - $expected[] = array('nid' => $this->nodes[1]->id()); + $this->executeView($view, ['10']); + $expected = []; + $expected[] = ['nid' => $this->nodes[0]->id()]; + $expected[] = ['nid' => $this->nodes[1]->id()]; $this->assertIdenticalResultset($view, $expected, $this->map); $view->destroy(); $view->setDisplay('embed_2'); - $this->executeView($view, array('01')); - $expected = array(); - $expected[] = array('nid' => $this->nodes[2]->id()); + $this->executeView($view, ['01']); + $expected = []; + $expected[] = ['nid' => $this->nodes[2]->id()]; $this->assertIdenticalResultset($view, $expected, $this->map); $view->destroy(); } @@ -124,16 +124,16 @@ public function testDatetimeArgumentAll() { // The 'embed_3' display has year, month, and day arguments. $view->setDisplay('embed_3'); - $this->executeView($view, array('2000', '10', '10')); - $expected = array(); - $expected[] = array('nid' => $this->nodes[0]->id()); + $this->executeView($view, ['2000', '10', '10']); + $expected = []; + $expected[] = ['nid' => $this->nodes[0]->id()]; $this->assertIdenticalResultset($view, $expected, $this->map); $view->destroy(); $view->setDisplay('embed_3'); - $this->executeView($view, array('2002', '01', '01')); - $expected = array(); - $expected[] = array('nid' => $this->nodes[2]->id()); + $this->executeView($view, ['2002', '01', '01']); + $expected = []; + $expected[] = ['nid' => $this->nodes[2]->id()]; $this->assertIdenticalResultset($view, $expected, $this->map); $view->destroy(); } diff --git a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php index 4678be9..b9a4699 100644 --- a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php +++ b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php @@ -19,7 +19,7 @@ /** * {@inheritdoc} */ - public static $modules = array('datetime_test', 'node', 'datetime'); + public static $modules = ['datetime_test', 'node', 'datetime']; /** * Name of the field. @@ -35,7 +35,7 @@ * * @var \Drupal\node\NodeInterface[] */ - protected $nodes = array(); + protected $nodes = []; /** * {@inheritdoc} @@ -44,35 +44,35 @@ public function setUp() { parent::setUp(); // Add a date field to page nodes. - $node_type = entity_create('node_type', array( - 'type' => 'page', - 'name' => 'page' - )); + $node_type = entity_create('node_type', [ + 'type' => 'page', + 'name' => 'page' + ]); $node_type->save(); - $fieldStorage = entity_create('field_storage_config', array( + $fieldStorage = entity_create('field_storage_config', [ 'field_name' => static::$field_name, 'entity_type' => 'node', 'type' => 'datetime', - 'settings' => array('datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME), - )); + 'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME], + ]); $fieldStorage->save(); - $field = entity_create('field_config', array( + $field = entity_create('field_config', [ '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 = array( + $this->map = [ 'nid' => 'nid', - ); + ]; // Load test views. - ViewTestData::createTestViews(get_class($this), array('datetime_test')); + ViewTestData::createTestViews(get_class($this), ['datetime_test']); } } diff --git a/core/modules/datetime/src/Tests/Views/FilterDateTest.php b/core/modules/datetime/src/Tests/Views/FilterDateTest.php index d36bc73..5e54f78 100644 --- a/core/modules/datetime/src/Tests/Views/FilterDateTest.php +++ b/core/modules/datetime/src/Tests/Views/FilterDateTest.php @@ -20,7 +20,7 @@ class FilterDateTest extends DateTimeHandlerTestBase { /** * {@inheritdoc} */ - public static $testViews = array('test_filter_datetime'); + public static $testViews = ['test_filter_datetime']; /** * For offset tests, set to the current time. @@ -53,11 +53,11 @@ public function setUp() { ]; foreach ($dates as $date) { - $this->nodes[] = $this->drupalCreateNode(array( - 'field_date' => array( + $this->nodes[] = $this->drupalCreateNode([ + 'field_date' => [ 'value' => $date, - ) - )); + ] + ]); } } @@ -78,10 +78,10 @@ public function testDateOffsets() { $view->filter[$field]->value['value'] = 'now'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[0]->id()), - array('nid' => $this->nodes[1]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[0]->id()], + ['nid' => $this->nodes[1]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); @@ -92,9 +92,9 @@ public function testDateOffsets() { $view->filter[$field]->value['value'] = 'now'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[2]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[2]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); @@ -106,9 +106,9 @@ public function testDateOffsets() { $view->filter[$field]->value['min'] = '+1 day'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[0]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[0]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); } diff --git a/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php b/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php index 283caf6..137f45c 100644 --- a/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php +++ b/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php @@ -20,7 +20,7 @@ class FilterDateTimeTest extends DateTimeHandlerTestBase { /** * {@inheritdoc} */ - public static $testViews = array('test_filter_datetime'); + public static $testViews = ['test_filter_datetime']; /** * For offset tests, set a date 1 day in the future. @@ -44,20 +44,20 @@ public function setUp() { date_default_timezone_set(static::$timezone); // Add some basic test nodes. - $dates = array( + $dates = [ '2000-10-10T00:01:30', '2001-10-10T12:12:12', '2002-10-10T14:14:14', // The date storage timezone is used (this mimics the steps taken in the // widget: \Drupal\datetime\Plugin\Field\FieldWidget::messageFormValues(). \Drupal::service('date.formatter')->format(static::$date, 'custom', DATETIME_DATETIME_STORAGE_FORMAT, DATETIME_STORAGE_TIMEZONE), - ); + ]; foreach ($dates as $date) { - $this->nodes[] = $this->drupalCreateNode(array( - 'field_date' => array( + $this->nodes[] = $this->drupalCreateNode([ + 'field_date' => [ 'value' => $date, - ) - )); + ] + ]); } } @@ -85,9 +85,9 @@ protected function _testOffset() { $view->filter[$field]->value['value'] = '+1 hour'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[3]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[3]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); @@ -99,9 +99,9 @@ protected function _testOffset() { $view->filter[$field]->value['min'] = '+1 hour'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[3]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[3]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); } @@ -119,9 +119,9 @@ protected function _testBetween() { $view->filter[$field]->value['max'] = '2002-01-01'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[1]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[1]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); @@ -131,10 +131,10 @@ protected function _testBetween() { $view->filter[$field]->value['max'] = '2002-01-01'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[0]->id()), - array('nid' => $this->nodes[1]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[0]->id()], + ['nid' => $this->nodes[1]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); @@ -145,11 +145,11 @@ protected function _testBetween() { $view->filter[$field]->value['max'] = '2002-01-01'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[0]->id()), - array('nid' => $this->nodes[2]->id()), - array('nid' => $this->nodes[3]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[0]->id()], + ['nid' => $this->nodes[2]->id()], + ['nid' => $this->nodes[3]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); @@ -159,11 +159,11 @@ protected function _testBetween() { $view->filter[$field]->value['max'] = '2001-01-01'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[1]->id()), - array('nid' => $this->nodes[2]->id()), - array('nid' => $this->nodes[3]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[1]->id()], + ['nid' => $this->nodes[2]->id()], + ['nid' => $this->nodes[3]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); } @@ -184,9 +184,9 @@ protected function _testExact() { $view->filter[$field]->value['value'] = \Drupal::service('date.formatter')->format(static::$date, 'custom', DATETIME_DATETIME_STORAGE_FORMAT, static::$timezone); $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[3]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[3]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); diff --git a/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php b/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php index 9c9ddcb..f3f8936 100644 --- a/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php +++ b/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php @@ -19,7 +19,7 @@ class SortDateTimeTest extends DateTimeHandlerTestBase { /** * {@inheritdoc} */ - public static $testViews = array('test_sort_datetime'); + public static $testViews = ['test_sort_datetime']; /** * {@inheritdoc} @@ -28,18 +28,18 @@ public function setUp() { parent::setUp(); // Add some basic test nodes. - $dates = array( + $dates = [ '2014-10-10T00:03:00', '2000-10-10T00:01:00', '2000-10-10T00:02:00', '2000-10-10T00:03:00', - ); + ]; foreach ($dates as $date) { - $this->nodes[] = $this->drupalCreateNode(array( - 'field_date' => array( + $this->nodes[] = $this->drupalCreateNode([ + 'field_date' => [ 'value' => $date, - ) - )); + ] + ]); } } @@ -55,12 +55,12 @@ public function testDateTimeSort() { $view->sort[$field]->options['granularity'] = 'minute'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[0]->id()), - array('nid' => $this->nodes[3]->id()), - array('nid' => $this->nodes[2]->id()), - array('nid' => $this->nodes[1]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[0]->id()], + ['nid' => $this->nodes[3]->id()], + ['nid' => $this->nodes[2]->id()], + ['nid' => $this->nodes[1]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); @@ -70,12 +70,12 @@ public function testDateTimeSort() { $view->sort[$field]->options['order'] = 'ASC'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[1]->id()), - array('nid' => $this->nodes[2]->id()), - array('nid' => $this->nodes[3]->id()), - array('nid' => $this->nodes[0]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[1]->id()], + ['nid' => $this->nodes[2]->id()], + ['nid' => $this->nodes[3]->id()], + ['nid' => $this->nodes[0]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); @@ -86,12 +86,12 @@ public function testDateTimeSort() { $view->sort[$field]->options['order'] = 'DESC'; $view->setDisplay('default'); $this->executeView($view); - $expected_result = array( - array('nid' => $this->nodes[0]->id()), - array('nid' => $this->nodes[1]->id()), - array('nid' => $this->nodes[2]->id()), - array('nid' => $this->nodes[3]->id()), - ); + $expected_result = [ + ['nid' => $this->nodes[0]->id()], + ['nid' => $this->nodes[1]->id()], + ['nid' => $this->nodes[2]->id()], + ['nid' => $this->nodes[3]->id()], + ]; $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); }