1 views_handler_argument_string.test ViewsHandlerArgumentStringTest::testGlossary()

Tests the glossary feature.

File

core/modules/views/tests/handlers/views_handler_argument_string.test, line 18
Definition of ViewsHandlerArgumentNullTest.

Class

ViewsHandlerArgumentStringTest
Tests the core views_handler_argument_string handler.

Code

function testGlossary() {
  // Setup some nodes, one with a, two with b and three with c.
  $counter = 1;
  foreach (array('a', 'b', 'c') as $char) {
    for ($i = 0; $i < $counter; $i++) {
      $edit = array(
        'title' => $char . $this->randomName(),
      );
      $this->backdropCreateNode($edit);
    }
  }

  $view = $this->viewGlossary();
  $view->init_display();
  $this->executeView($view);

  $count_field = 'nid';
  foreach ($view->result as &$row) {
    if (strpos($row->node_title, 'a') === 0) {
      $this->assertEqual(1, $row->{$count_field});
    }
    if (strpos($row->node_title, 'b') === 0) {
      $this->assertEqual(2, $row->{$count_field});
    }
    if (strpos($row->node_title, 'c') === 0) {
      $this->assertEqual(3, $row->{$count_field});
    }
  }
}