Same filename and directory in other branches
- 8.9.x core/modules/taxonomy/tests/src/Kernel/Views/ArgumentTransformTermTest.php
- 9 core/modules/taxonomy/tests/src/Kernel/Views/ArgumentTransformTermTest.php
Namespace
Drupal\Tests\taxonomy\Kernel\Views
File
core/modules/taxonomy/tests/src/Kernel/Views/ArgumentTransformTermTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\taxonomy\Kernel\Views;
use Drupal\TestTools\Random;
use Drupal\views\Views;
class ArgumentTransformTermTest extends TaxonomyTestBase {
public static $testViews = [
'test_argument_transform_term',
];
public function testTermArgumentTransformation($name) {
$term = $this
->createTerm([
'name' => $name,
]);
$view = Views::getView('test_argument_transform_term');
$view
->initHandlers();
$hyphenated_term = str_replace(' ', '-', $term
->label());
$this
->assertTrue($view->argument['tid']
->setArgument($hyphenated_term));
$this
->assertEquals($term
->label(), $view->argument['tid']->argument);
}
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() . ' ',
],
];
}
}
Classes