// Test disabled views.
$this->
assertEquals($this->
formatViewOptions($expected_disabled), Views::
getViewsAsOptions(FALSE, 'disabled'
), 'Expected disabled options array was returned.'
);
// Test the sort parameter.
$all_views_sorted =
$all_views;
ksort($all_views_sorted);
$this->
assertSame(array_keys($all_views_sorted),
array_keys(Views::
getViewsAsOptions(TRUE, 'all', NULL, FALSE, TRUE
)), 'All view id keys returned in expected sort order'
);
// Test $exclude_view parameter.
$this->
assertArrayNotHasKey('archive', Views::
getViewsAsOptions(TRUE, 'all', 'archive'
));
$this->
assertArrayNotHasKey('archive:default', Views::
getViewsAsOptions(FALSE, 'all', 'archive:default'
));
$this->
assertArrayNotHasKey('archive', Views::
getViewsAsOptions(TRUE, 'all',
$archive->
getExecutable()));
// Test the $opt_group parameter.
$expected_opt_groups =
[];
foreach ($all_views as $view) { foreach ($view->
get('display'
) as $display) { $expected_opt_groups[$view->
id()][$view->
id() . ':' .
$display['id'
]] =
$view->
id() . ' : ' .
$display['id'
];
} } $this->
assertEquals($expected_opt_groups, Views::
getViewsAsOptions(FALSE, 'all', NULL, TRUE
), 'Expected option array for an option group returned.'
);
}