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 71b37c8..b3dffc0 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -483,8 +483,10 @@ 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 fix #2208811 because views_embed_views() pass + // arguments to preview() with wrong array keys. + $this->args = array_values($args); } /**