Same name in this branch
- 10 core/modules/rest/tests/src/Functional/Views/FieldCounterTest.php \Drupal\Tests\rest\Functional\Views\FieldCounterTest
- 10 core/modules/views/tests/src/Kernel/Handler/FieldCounterTest.php \Drupal\Tests\views\Kernel\Handler\FieldCounterTest
Same name and namespace in other branches
- 8.9.x core/modules/rest/tests/src/Functional/Views/FieldCounterTest.php \Drupal\Tests\rest\Functional\Views\FieldCounterTest
- 9 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\views\Functional\ViewTestBase extends \Drupal\Tests\BrowserTestBase uses ViewResultAssertionTrait
- class \Drupal\Tests\rest\Functional\Views\FieldCounterTest
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 18
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldCounterTest:: |
protected | property | ||
FieldCounterTest:: |
protected static | property |
The modules that need to be installed for this test. Overrides ViewTestBase:: |
|
FieldCounterTest:: |
public static | property | The views that are used by this test. | |
FieldCounterTest:: |
protected | property | ||
FieldCounterTest:: |
protected | function |
Sets up the test. Overrides ViewTestBase:: |
|
FieldCounterTest:: |
public | function | Tests the display of an excluded title field when used as a token. | |
ViewResultAssertionTrait:: |
protected | function | Verifies that a result set returned by a View matches expected values. | |
ViewResultAssertionTrait:: |
protected | function | Performs View result assertions. | |
ViewResultAssertionTrait:: |
protected | function | Verifies that a result set returned by a View differs from certain values. | |
ViewTestBase:: |
protected | function | Returns a very simple test dataset. | 1 |
ViewTestBase:: |
protected | function | Sets up the views_test_data.module. | |
ViewTestBase:: |
protected | function | Executes a view. | |
ViewTestBase:: |
protected | function | Asserts the existence of a button with a certain ID and label. | |
ViewTestBase:: |
protected | function | Orders a nested array containing a result set based on a given column. | |
ViewTestBase:: |
protected | function | Returns the schema definition. | 1 |
ViewTestBase:: |
protected | function | Returns the views data definition. | 8 |