formatViewOptions example

// Test Views::getViewsAsOptions().     // Test the $views_only parameter.     $this->assertSame(array_keys($all_views)array_keys(Views::getViewsAsOptions(TRUE)), 'Expected option keys for all views were returned.');
    $expected_options = [];
    foreach ($all_views as $id => $view) {
      $expected_options[$id] = $view->label();
    }
    $this->assertSame($expected_options, Views::getViewsAsOptions(TRUE), 'Expected options array was returned.');

    // Test the default.     $this->assertEquals($this->formatViewOptions($all_views), Views::getViewsAsOptions(), 'Expected options array for all views was returned.');
    // Test enabled views.     $this->assertEquals($this->formatViewOptions($expected_enabled), Views::getViewsAsOptions(FALSE, 'enabled'), 'Expected enabled options array was returned.');
    // 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.
Home | Imprint | This part of the site doesn't use cookies.