Skip to content
Snippets Groups Projects
Unverified Commit 5235ea9a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3041770 by claudiu.cristea: Convert ArgumentStringTest into a Kernel test

parent 97f5efc2
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
<?php
namespace Drupal\Tests\views\Functional\Handler;
namespace Drupal\Tests\views\Kernel\Handler;
use Drupal\Tests\views\Functional\ViewTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
/**
......@@ -10,34 +12,36 @@
*
* @group views
*/
class ArgumentStringTest extends ViewTestBase {
class ArgumentStringTest extends ViewsKernelTestBase {
/**
* Views used by this test.
*
* @var array
* {@inheritdoc}
*/
public static $testViews = ['test_glossary'];
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['node'];
public 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++) {
$edit = [
Node::create([
'type' => 'page',
'title' => $char . $this->randomMachineName(),
];
$this->drupalCreateNode($edit);
])->save();
}
}
......@@ -47,13 +51,13 @@ public function testGlossary() {
$count_field = 'nid';
foreach ($view->result as &$row) {
if (strpos($view->field['title']->getValue($row), 'a') === 0) {
$this->assertEqual(1, $row->{$count_field});
$this->assertEquals(1, $row->{$count_field});
}
if (strpos($view->field['title']->getValue($row), 'b') === 0) {
$this->assertEqual(2, $row->{$count_field});
$this->assertEquals(2, $row->{$count_field});
}
if (strpos($view->field['title']->getValue($row), 'c') === 0) {
$this->assertEqual(3, $row->{$count_field});
$this->assertEquals(3, $row->{$count_field});
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment