assertNoText example

    \Drupal::currentUser()->setAccount($user1);

    // Test the rendering of a block.     $entity = Block::load('views_block__who_s_online_who_s_online_block');
    $output = \Drupal::entityTypeManager()
      ->getViewBuilder($entity->getEntityTypeId())
      ->view($entity, 'block');
    $this->setRawContent($this->renderer->renderRoot($output));
    $this->assertRaw('2 users', 'Correct number of online users (2 users).');
    $this->assertText($user1->getAccountName(), 'Active user 1 found in online list.');
    $this->assertText($user2->getAccountName(), 'Active user 2 found in online list.');
    $this->assertNoText($user3->getAccountName(), 'Inactive user not found in online list.');
    // Verify that online users are ordered correctly.     $this->assertGreaterThan(strpos($this->getRawContent()$user2->getAccountName())strpos($this->getRawContent()$user1->getAccountName()));
  }

}
'user_id' => $user->id(),
        'name' => 'test entity test',
      ]);
      $entity_test->save();
    }

    $view = Views::getView('test_entity_row');
    $build = $view->preview();
    $this->render($build);

    $this->assertText('test entity test');
    $this->assertNoText('Member for');

    // Change the view to use a relationship to render the row.     $view = Views::getView('test_entity_row');
    $display = &$view->storage->getDisplay('default');
    $display['display_options']['row']['type'] = 'entity:user';
    $display['display_options']['row']['options']['relationship'] = 'user_id';
    $view->setDisplay('default');
    $build = $view->preview();
    $this->render($build);

    $this->assertNoText('test entity test');
    
$build = $executable->preview();
    $this->setRawContent($renderer->renderRoot($build));

    $this->assertText($field_content);
    $this->assertTrue(isset($executable->field[$field_name]));

    $account_switcher->switchTo($this->userWithoutAccess);
    $executable = Views::getView($view_id);
    $build = $executable->preview();
    $this->setRawContent($renderer->renderRoot($build));

    $this->assertNoText($field_content);
    $this->assertFalse(isset($executable->field[$field_name]));

    \Drupal::state()->delete('views_field_access_test-field');
  }

}
    $view->header['test_example']->options['string'] = '<p>' . $empty_header . '</p>';
    // Set example footer text.     $view->footer['test_example']->options['string'] = '<p>' . $empty_footer . '</p>';

    // Verify that the empty header and footer sections have not been rendered.     $view->setDisplay('default');
    $this->executeView($view);
    $output = $view->render();
    $output = \Drupal::service('renderer')->renderRoot($output);
    $this->setRawContent($output);
    $this->assertText($empty_text);
    $this->assertNoText($empty_header);
    $this->assertNoText($empty_footer);

    // Enable displaying the header and footer when the View is empty.     $view->header['test_example']->options['empty'] = TRUE;
    $view->footer['test_example']->options['empty'] = TRUE;

    // Verify that the header and footer sections have been rendered.     $this->executeView($view);
    $output = $view->render();
    $output = \Drupal::service('renderer')->renderRoot($output);
    $this->setRawContent($output);
    
    $display = [
      'label' => 'hidden',
      'type' => 'field_test_multiple',
      'settings' => [
        'test_formatter_setting_multiple' => $this->randomMachineName(),
        'alter' => TRUE,
      ],
    ];
    $build = $items->view($display);
    $this->render($build);
    $setting = $display['settings']['test_formatter_setting_multiple'];
    $this->assertNoText($this->label, 'Label was not displayed.');
    $this->assertText('field_test_entity_display_build_alter', 'Alter fired, display passed.');
    $this->assertText('entity language is en', 'Language is placed onto the context.');
    $array = [];
    foreach ($this->values as $delta => $value) {
      $array[] = $delta . ':' . $value['value'];
    }
    $this->assertText($setting . '|' . implode('|', $array), 'Values were displayed with expected setting.');

    // Display settings: Check visually_hidden field.     $display = [
      'label' => 'visually_hidden',
      
$this->assertText($comment->label());
    $this->assertText($comment_anonymous->label());
    $executable->destroy();

    // Test the Subject filter.     $executable->setExposedInput(['subject' => 'Anonymous']);
    $build = $executable->preview($display_id);
    $this->setRawContent($renderer->renderRoot($build));

    $elements = $this->cssSelect('input[type="checkbox"]');
    $this->assertCount(1, $elements, 'Only anonymous comment is visible.');
    $this->assertNoText($comment->label());
    $this->assertText($comment_anonymous->label());
    $executable->destroy();

    $executable->setExposedInput(['subject' => 'My comment']);
    $build = $executable->preview($display_id);
    $this->setRawContent($renderer->renderRoot($build));

    $elements = $this->cssSelect('input[type="checkbox"]');
    $this->assertCount(1, $elements, 'Only admin comment is visible.');
    $this->assertText($comment->label());
    $this->assertNoText($comment_anonymous->label());
    
$this->assertText('start: 0 | end: 0 | total: 0 | label: test_area_result | per page: 0 | current page: 1 | current record count: 0 | page count: 1');
    $this->assertRaw('<header>');

    // Test that the area is not displayed if we have not checked the empty     // checkbox.     $view->setDisplay('page_1');

    $this->executeView($view);
    $output = $view->render();
    $output = \Drupal::service('renderer')->renderRoot($output);
    $this->setRawContent($output);
    $this->assertNoText('start: 0 | end: 0 | total: 0 | label: test_area_result | per page: 0 | current page: 1 | current record count: 0 | page count: 1');
    // Make sure the empty header region isn't rendered.     $this->assertNoRaw('<header>');
  }

}
Home | Imprint | This part of the site doesn't use cookies.