function ProxyBuilderTest::testBuildWithNullableSelfTypehint

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php \Drupal\Tests\Component\ProxyBuilder\ProxyBuilderTest::testBuildWithNullableSelfTypeHint()
  2. 11.x core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php \Drupal\Tests\Component\ProxyBuilder\ProxyBuilderTest::testBuildWithNullableSelfTypeHint()

@covers ::buildMethod @covers ::buildParameter @covers ::buildMethodBody

File

core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php, line 291

Class

ProxyBuilderTest
@coversDefaultClass \Drupal\Component\ProxyBuilder\ProxyBuilder @group proxy_builder

Namespace

Drupal\Tests\Component\ProxyBuilder

Code

public function testBuildWithNullableSelfTypehint() {
    $class = 'Drupal\\Tests\\Component\\ProxyBuilder\\TestServiceNullableTypehintSelf';
    $result = $this->proxyBuilder
        ->build($class);
    // Ensure that the static method is not wrapped.
    $method_body = <<<'EOS'

/**
 * {@inheritdoc}
 */
public function typehintSelf(?\Drupal\Tests\Component\ProxyBuilder\TestServiceNullableTypehintSelf $parameter): ?\Drupal\Tests\Component\ProxyBuilder\TestServiceNullableTypehintSelf
{
    return $this->lazyLoadItself()->typehintSelf($parameter);
}

EOS;
    $this->assertEquals($this->buildExpectedClass($class, $method_body), $result);
}

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