You are here

public function UpcastingTest::testSameTypes in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php \Drupal\Tests\system\Functional\ParamConverter\UpcastingTest::testSameTypes()

Confirms we can upcast to controller arguments of the same type.

File

core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php, line 58

Class

UpcastingTest
Tests upcasting of url arguments to entities.

Namespace

Drupal\Tests\system\Functional\ParamConverter

Code

public function testSameTypes() {
  $node = $this
    ->drupalCreateNode([
    'title' => $this
      ->randomMachineName(8),
  ]);
  $parent = $this
    ->drupalCreateNode([
    'title' => $this
      ->randomMachineName(8),
  ]);

  // paramconverter_test/node/{node}/set/parent/{parent}
  // options.parameters.parent.type = entity:node
  $this
    ->drupalGet("paramconverter_test/node/" . $node
    ->id() . "/set/parent/" . $parent
    ->id());
  $this
    ->assertSession()
    ->pageTextContains("Setting '" . $parent
    ->getTitle() . "' as parent of '" . $node
    ->getTitle() . "'.");
}