ArgumentStringTest.php in Zircon Profile 8.0
File
core/modules/views/src/Tests/Handler/ArgumentStringTest.php
View source
<?php
namespace Drupal\views\Tests\Handler;
use Drupal\views\Views;
class ArgumentStringTest extends HandlerTestBase {
public static $testViews = array(
'test_glossary',
);
public static $modules = array(
'node',
);
function testGlossary() {
$counter = 1;
foreach (array(
'a',
'b',
'c',
) as $char) {
for ($i = 0; $i < $counter; $i++) {
$edit = array(
'title' => $char . $this
->randomMachineName(),
);
$this
->drupalCreateNode($edit);
}
}
$view = Views::getView('test_glossary');
$this
->executeView($view);
$count_field = 'nid';
foreach ($view->result as &$row) {
if (strpos($view->field['title']
->getValue($row), 'a') === 0) {
$this
->assertEqual(1, $row->{$count_field});
}
if (strpos($view->field['title']
->getValue($row), 'b') === 0) {
$this
->assertEqual(2, $row->{$count_field});
}
if (strpos($view->field['title']
->getValue($row), 'c') === 0) {
$this
->assertEqual(3, $row->{$count_field});
}
}
}
}