function UpcastingTest::testSameTypes

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php \Drupal\Tests\system\Functional\ParamConverter\UpcastingTest::testSameTypes()
  2. 8.9.x core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php \Drupal\Tests\system\Functional\ParamConverter\UpcastingTest::testSameTypes()
  3. 10 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 65

Class

UpcastingTest
Tests upcasting of URL arguments to entities.

Namespace

Drupal\Tests\system\Functional\ParamConverter

Code

public function testSameTypes() : void {
  $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() . "'.");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.