class FieldCounterTest
Same name in this branch
- 9 core/modules/views/tests/src/Kernel/Handler/FieldCounterTest.php \Drupal\Tests\views\Kernel\Handler\FieldCounterTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Handler/FieldCounterTest.php \Drupal\Tests\views\Kernel\Handler\FieldCounterTest
- 11.x core/modules/rest/tests/src/Functional/Views/FieldCounterTest.php \Drupal\Tests\rest\Functional\Views\FieldCounterTest
Tests the display of counter field.
@group rest
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\rest\Functional\Views\FieldCounterTest implements \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of FieldCounterTest
See also
\Drupal\rest\Plugin\views\display\RestExport
\Drupal\rest\Plugin\views\row\DataFieldRow
File
-
core/
modules/ rest/ tests/ src/ Functional/ Views/ FieldCounterTest.php, line 16
Namespace
Drupal\Tests\rest\Functional\ViewsView source
class FieldCounterTest extends ViewTestBase {
/**
* @var \Drupal\views\ViewExecutable
*/
protected $view;
/**
* The views that are used by this test.
*
* @var array
*/
public static $testViews = [
'test_field_counter_display',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* The modules that need to be installed for this test.
*
* @var array
*/
protected static $modules = [
'entity_test',
'rest_test_views',
'node',
'field',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = [
'rest_test_views',
]) : void {
parent::setUp($import_test_views, $modules);
// Create some test content.
for ($i = 1; $i <= 10; $i++) {
Node::create([
'type' => 'article',
'title' => 'Article test ' . $i,
])->save();
}
$this->enableViewsTestModule();
$this->view = Views::getView('test_field_counter_display');
$this->view
->setDisplay('rest_export_1');
}
/**
* Tests the display of an excluded title field when used as a token.
*/
public function testExcludedTitleTokenDisplay() {
$actual_json = $this->drupalGet($this->view
->getPath(), [
'query' => [
'_format' => 'json',
],
]);
$this->assertSession()
->statusCodeEquals(200);
$expected = [
[
'counter' => '1',
],
[
'counter' => '2',
],
[
'counter' => '3',
],
[
'counter' => '4',
],
[
'counter' => '5',
],
[
'counter' => '6',
],
[
'counter' => '7',
],
[
'counter' => '8',
],
[
'counter' => '9',
],
[
'counter' => '10',
],
];
$this->assertSame(json_encode($expected), $actual_json);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.