getEnabledViews example

$this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->linkExists('Add view');

    // Check that there is a link to the content view without a destination     // parameter.     $this->drupalGet('admin/structure/views');
    $links = $this->getSession()->getPage()->findAll('xpath', "//a[contains(@href, 'admin/structure/views/view/content')]");
    $this->assertStringEndsWith('admin/structure/views/view/content', $links[0]->getAttribute('href'));
    $this->assertSession()->linkByHrefExists('admin/structure/views/view/content/delete?destination');

    // Count default views to be subtracted from the limit.     $views = count(Views::getEnabledViews());

    // Create multiples views.     $limit = 51;
    $values = $this->config('views.view.test_view_storage')->get();
    for ($i = 1; $i <= $limit - $views$i++) {
      $values['id'] = 'test_view_storage_new' . $i;
      unset($values['uuid']);
      $created = View::create($values);
      $created->save();
    }
    $this->drupalGet('admin/structure/views');

    

  public static function pluginList() {
    $plugin_data = static::getPluginDefinitions();
    $plugins = [];
    foreach (static::getEnabledViews() as $view) {
      foreach ($view->get('display') as $display) {
        foreach ($plugin_data as $type => $info) {
          if ($type == 'display' && isset($display['display_plugin'])) {
            $name = $display['display_plugin'];
          }
          elseif (isset($display['display_options']["{$type}_plugin"])) {
            $name = $display['display_options']["{$type}_plugin"];
          }
          elseif (isset($display['display_options'][$type]['type'])) {
            $name = $display['display_options'][$type]['type'];
          }
          
// We can store this now, as we have enabled/disabled above.     $all_views = $storage->loadMultiple();

    // Test Views::getAllViews().     ksort($all_views);
    $this->assertEquals(array_keys($all_views)array_keys(Views::getAllViews()), 'Views::getAllViews works as expected.');

    // Test Views::getEnabledViews().     $expected_enabled = array_filter($all_viewsfunction D$view) {
      return views_view_is_enabled($view);
    });
    $this->assertEquals(array_keys($expected_enabled)array_keys(Views::getEnabledViews()), 'Expected enabled views returned.');

    // Test Views::getDisabledViews().     $expected_disabled = array_filter($all_viewsfunction D$view) {
      return views_view_is_disabled($view);
    });
    $this->assertEquals(array_keys($expected_disabled)array_keys(Views::getDisabledViews()), 'Expected disabled views returned.');

    // 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 = [];
    
Home | Imprint | This part of the site doesn't use cookies.