class ArgumentStringTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Handler/ArgumentStringTest.php \Drupal\Tests\views\Kernel\Handler\ArgumentStringTest
Tests the core Drupal\views\Plugin\views\argument\StringArgument handler.
@group views
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\views\Kernel\Handler\ArgumentStringTest implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ArgumentStringTest
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ ArgumentStringTest.php, line 15
Namespace
Drupal\Tests\views\Kernel\HandlerView source
class ArgumentStringTest extends ViewsKernelTestBase {
/**
* {@inheritdoc}
*/
public static $testViews = [
'test_glossary',
];
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
];
/**
* Tests the glossary feature.
*/
public function testGlossary() {
$this->installEntitySchema('user');
$this->installEntitySchema('node');
NodeType::create([
'type' => 'page',
])->save();
// Setup some nodes, one with a, two with b and three with c.
$counter = 1;
foreach ([
'a',
'b',
'c',
] as $char) {
for ($i = 0; $i < $counter; $i++) {
Node::create([
'type' => 'page',
'title' => $char . $this->randomMachineName(),
])
->save();
}
}
$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->assertEquals(1, $row->{$count_field});
}
if (strpos($view->field['title']
->getValue($row), 'b') === 0) {
$this->assertEquals(2, $row->{$count_field});
}
if (strpos($view->field['title']
->getValue($row), 'c') === 0) {
$this->assertEquals(3, $row->{$count_field});
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.