3 namespace Drupal\Tests\views\Functional\Handler;
5 use Drupal\Tests\views\Functional\ViewTestBase;
6 use Drupal\views\Views;
9 * Tests the core Drupal\views\Plugin\views\argument\StringArgument handler.
13 class ArgumentStringTest extends ViewTestBase {
16 * Views used by this test.
20 public static $testViews = ['test_glossary'];
27 public static $modules = ['node'];
30 * Tests the glossary feature.
32 public function testGlossary() {
33 // Setup some nodes, one with a, two with b and three with c.
35 foreach (['a', 'b', 'c'] as $char) {
36 for ($i = 0; $i < $counter; $i++) {
38 'title' => $char . $this->randomMachineName(),
40 $this->drupalCreateNode($edit);
44 $view = Views::getView('test_glossary');
45 $this->executeView($view);
48 foreach ($view->result as &$row) {
49 if (strpos($view->field['title']->getValue($row), 'a') === 0) {
50 $this->assertEqual(1, $row->{$count_field});
52 if (strpos($view->field['title']->getValue($row), 'b') === 0) {
53 $this->assertEqual(2, $row->{$count_field});
55 if (strpos($view->field['title']->getValue($row), 'c') === 0) {
56 $this->assertEqual(3, $row->{$count_field});