diff --git a/core/modules/views/src/Tests/ModuleTest.php b/core/modules/views/src/Tests/ModuleTest.php index e237a19..7809160 100644 --- a/core/modules/views/src/Tests/ModuleTest.php +++ b/core/modules/views/src/Tests/ModuleTest.php @@ -23,7 +23,7 @@ class ModuleTest extends ViewUnitTestBase { * * @var array */ - public static $testViews = array('test_view_status', 'test_view'); + public static $testViews = array('test_view_status', 'test_view', 'test_argument'); /** * Modules to enable. @@ -269,6 +269,18 @@ public function testViewsPluginList() { } /** + * Tests views.module: views_embed_view(). + */ + public function testViewsEmbedView() { + $this->enableModules(array('user')); + $result = views_embed_view('test_argument'); + $this->assertEqual(count($result['#view']->result), 5); + + $result = views_embed_view('test_argument', 'default', 1); + $this->assertEqual(count($result['#view']->result), 1); + } + + /** * Helper to return an expected views option array. * * @param array $views diff --git a/core/modules/views/src/Tests/ViewUnitTestBase.php b/core/modules/views/src/Tests/ViewUnitTestBase.php index 5efbc14..3aba1f5 100644 --- a/core/modules/views/src/Tests/ViewUnitTestBase.php +++ b/core/modules/views/src/Tests/ViewUnitTestBase.php @@ -118,7 +118,7 @@ protected function orderResultSet($result_set, $column, $reverse = FALSE) { * @param array $args * (optional) An array of the view arguments to use for the view. */ - protected function executeView($view, $args = array()) { + protected function executeView($view, array $args = array()) { $view->setDisplay(); $view->preExecute($args); $view->execute(); diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index fe65fe3..12b3d19 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -482,8 +482,8 @@ public function save() { * Set the arguments that come to this view. Usually from the URL * but possibly from elsewhere. */ - public function setArguments($args) { - $this->args = $args; + public function setArguments(array $args) { + $this->args = array_values($args); } /** diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument.yml new file mode 100644 index 0000000..e2edd29 --- /dev/null +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument.yml @@ -0,0 +1,88 @@ +langcode: en +status: true +dependencies: { } +label: '' +module: views +description: '' +tag: '' +base_table: views_test_data +base_field: nid +core: '8' +id: test_argument +display: + default: + display_options: + defaults: + fields: false + pager: false + sorts: false + arguments: false + fields: + age: + field: age + id: age + relationship: none + table: views_test_data + id: + field: id + id: id + relationship: none + table: views_test_data + name: + field: name + id: name + relationship: none + table: views_test_data + pager: + options: + offset: '0' + type: none + sorts: + id: + field: id + id: id + order: ASC + relationship: none + table: views_test_data + arguments: + id: + id: id + table: views_test_data + field: id + relationship: none + group_type: group + admin_label: '' + default_action: ignore + exception: + value: all + title_enable: false + title: All + title_enable: false + title: '' + default_argument_type: fixed + default_argument_options: + argument: '' + default_argument_skip_url: false + summary_options: + base_path: '' + count: true + items_per_page: 25 + override: false + summary: + sort_order: asc + number_of_records: 0 + format: default_summary + specify_validation: false + validate: + type: none + fail: 'not found' + validate_options: { } + break_phrase: false + not: false + entity_type: node + entity_field: nid + plugin_id: numeric + display_plugin: default + display_title: Master + id: default + position: 0