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

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

(cherry picked from commit 5235ea9a)
parent f4ede890
No related branches found
No related tags found
No related merge requests found
<?php <?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; use Drupal\views\Views;
/** /**
...@@ -10,34 +12,36 @@ ...@@ -10,34 +12,36 @@
* *
* @group views * @group views
*/ */
class ArgumentStringTest extends ViewTestBase { class ArgumentStringTest extends ViewsKernelTestBase {
/** /**
* Views used by this test. * {@inheritdoc}
*
* @var array
*/ */
public static $testViews = ['test_glossary']; public static $testViews = ['test_glossary'];
/** /**
* Modules to enable. * {@inheritdoc}
*
* @var array
*/ */
public static $modules = ['node']; public static $modules = [
'node',
];
/** /**
* Tests the glossary feature. * Tests the glossary feature.
*/ */
public function testGlossary() { 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. // Setup some nodes, one with a, two with b and three with c.
$counter = 1; $counter = 1;
foreach (['a', 'b', 'c'] as $char) { foreach (['a', 'b', 'c'] as $char) {
for ($i = 0; $i < $counter; $i++) { for ($i = 0; $i < $counter; $i++) {
$edit = [ Node::create([
'type' => 'page',
'title' => $char . $this->randomMachineName(), 'title' => $char . $this->randomMachineName(),
]; ])->save();
$this->drupalCreateNode($edit);
} }
} }
...@@ -47,13 +51,13 @@ public function testGlossary() { ...@@ -47,13 +51,13 @@ public function testGlossary() {
$count_field = 'nid'; $count_field = 'nid';
foreach ($view->result as &$row) { foreach ($view->result as &$row) {
if (strpos($view->field['title']->getValue($row), 'a') === 0) { 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) { 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) { 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