Same name and namespace in other branches
- 8.9.x core/modules/taxonomy/tests/src/Kernel/Views/ArgumentTransformTermTest.php \Drupal\Tests\taxonomy\Kernel\Views\ArgumentTransformTermTest
- 9 core/modules/taxonomy/tests/src/Kernel/Views/ArgumentTransformTermTest.php \Drupal\Tests\taxonomy\Kernel\Views\ArgumentTransformTermTest
Tests taxonomy term argument transformation.
@group taxonomy
Hierarchy
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses ViewResultAssertionTrait
- class \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase uses EntityReferenceFieldCreationTrait, ContentTypeCreationTrait, NodeCreationTrait, UserCreationTrait
- class \Drupal\Tests\taxonomy\Kernel\Views\ArgumentTransformTermTest
- class \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase uses EntityReferenceFieldCreationTrait, ContentTypeCreationTrait, NodeCreationTrait, UserCreationTrait
Expanded class hierarchy of ArgumentTransformTermTest
See also
\Drupal\taxonomy\Plugin\views\argument_validator\TermName
File
- core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ ArgumentTransformTermTest.php, line 17
Namespace
Drupal\Tests\taxonomy\Kernel\ViewsView source
class ArgumentTransformTermTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
public static $testViews = [
'test_argument_transform_term',
];
/**
* Tests term argument transformation of hyphens and spaces.
*
* @dataProvider termArgumentTransformationProvider
*
* @param string $name
* The name of the taxonomy term to use for the test.
*/
public function testTermArgumentTransformation($name) {
/** @var \Drupal\taxonomy\TermInterface $term */
$term = $this
->createTerm([
'name' => $name,
]);
/** @var \Drupal\views\ViewExecutable $view */
$view = Views::getView('test_argument_transform_term');
$view
->initHandlers();
/** @var string $hyphenated_term */
$hyphenated_term = str_replace(' ', '-', $term
->label());
$this
->assertTrue($view->argument['tid']
->setArgument($hyphenated_term));
// Assert hyphens are converted back to spaces.
$this
->assertEquals($term
->label(), $view->argument['tid']->argument);
}
/**
* Provides data for testTermArgumentTransformation().
*
* @return array[]
* Test data.
*/
public static function termArgumentTransformationProvider() {
return [
'space in the middle' => [
'name' => Random::machineName() . ' ' . Random::machineName(),
],
'space at the start' => [
'name' => ' ' . Random::machineName(),
],
'space at the end' => [
'name' => Random::machineName() . ' ',
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ArgumentTransformTermTest:: |
public static | property |
Views to be enabled. Overrides ViewsKernelTestBase:: |
|
ArgumentTransformTermTest:: |
public static | function | Provides data for testTermArgumentTransformation(). | |
ArgumentTransformTermTest:: |
public | function | Tests term argument transformation of hyphens and spaces. | |
ContentTypeCreationTrait:: |
protected | function | Creates a custom content type based on default settings. Aliased as: drupalCreateContentType | |
EntityReferenceFieldCreationTrait:: |
protected | function | Creates a field of an entity reference field storage on the specified bundle. | |
NodeCreationTrait:: |
protected | function | Creates a node based on default settings. Aliased as: drupalCreateNode | |
NodeCreationTrait:: |
public | function | Get a node from the database based on its title. | |
TaxonomyTestBase:: |
protected static | property |
Modules to enable. Overrides ViewsKernelTestBase:: |
|
TaxonomyTestBase:: |
protected | property | Stores the nodes used for the different tests. | |
TaxonomyTestBase:: |
protected | property | Stores the first term used in the different tests. | |
TaxonomyTestBase:: |
protected | property | Stores the second term used in the different tests. | |
TaxonomyTestBase:: |
protected | property | The vocabulary used for creating terms. | |
TaxonomyTestBase:: |
protected | function | Creates and returns a taxonomy term. | |
TaxonomyTestBase:: |
protected | function | Provides a workaround for the inability to use the standard profile. | |
TaxonomyTestBase:: |
protected | function |
Overrides ViewsKernelTestBase:: |
|
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. | |
UserCreationTrait:: |
protected | function | Creates an administrative role. | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. | |
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. | |
ViewsKernelTestBase:: |
protected | function | Returns a very simple test dataset. | 8 |
ViewsKernelTestBase:: |
protected | function | Executes a view. | |
ViewsKernelTestBase:: |
protected | function | Orders a nested array containing a result set based on a given column. | |
ViewsKernelTestBase:: |
protected | function | Returns the schema definition. | 6 |
ViewsKernelTestBase:: |
protected | function | Sets up the configuration and schema of views and views_test_data modules. | 7 |
ViewsKernelTestBase:: |
protected | function | Returns the views data definition. | 22 |