1 views_glossary.test public ViewsGlossaryTestCase::testGlossaryView()

Tests the default glossary view.

File

core/modules/views/tests/views_glossary.test, line 18
Definition of ViewsGlossaryTestCase.

Class

ViewsGlossaryTestCase
Tests glossary view ( summary of arguments ).

Code

public function testGlossaryView() {
  // Create a content type and add some nodes, with a non random title.
  $type = $this->backdropCreateContentType();
  $nodes_per_char = array(
    'd' => 1,
    'r' => 4,
    'u' => 10,
    'p' => 2,
    'a' => 3,
    'l' => 6,
  );
  foreach ($nodes_per_char as $char => $count) {
    $setting = array(
      'type' => $type->type
    );
    for ($i = 0; $i < $count; $i++) {
      $node = $setting;
      $node['title'] = $char . $this->randomString(3);
      $this->backdropCreateNode($node);
    }
  }

  // Execute glossary view
  $view = views_get_view('test_glossary');
  $view->set_display('attachment');
  $view->execute_display('attachment');

  // Check that the amount of nodes per char.
  $result_nodes_per_char = array();
  foreach ($view->result as $item) {
    $this->assertEqual($nodes_per_char[$item->title_truncated], $item->num_records);
  }
}