class ArgumentTransformTermTest
Same name and namespace in other branches
- 11.x core/modules/taxonomy/tests/src/Kernel/Views/ArgumentTransformTermTest.php \Drupal\Tests\taxonomy\Kernel\Views\ArgumentTransformTermTest
- 10 core/modules/taxonomy/tests/src/Kernel/Views/ArgumentTransformTermTest.php \Drupal\Tests\taxonomy\Kernel\Views\ArgumentTransformTermTest
- 8.9.x 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\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase uses \Drupal\Tests\field\Traits\EntityReferenceTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\taxonomy\Kernel\Views\ArgumentTransformTermTest implements \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase
- class \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase uses \Drupal\Tests\field\Traits\EntityReferenceTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
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 14
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 function termArgumentTransformationProvider() {
return [
'space in the middle' => [
'name' => $this->randomMachineName() . ' ' . $this->randomMachineName(),
],
'space at the start' => [
'name' => ' ' . $this->randomMachineName(),
],
'space at the end' => [
'name' => $this->randomMachineName() . ' ',
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.