class ReflectionTest

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/ReflectionTest.php \Drupal\Tests\Component\Utility\ReflectionTest
  2. 10 core/tests/Drupal/Tests/Component/Utility/ReflectionTest.php \Drupal\Tests\Component\Utility\ReflectionTest

@coversDefaultClass \Drupal\Component\Utility\Reflection @group Utility

Hierarchy

  • class \Drupal\Tests\Component\Utility\ReflectionTest extends \PHPUnit\Framework\TestCase

Expanded class hierarchy of ReflectionTest

File

core/tests/Drupal/Tests/Component/Utility/ReflectionTest.php, line 14

Namespace

Drupal\Tests\Component\Utility
View source
class ReflectionTest extends TestCase {
    
    /**
     * @param string|null $expected
     *   The expected value of the parameter.
     * @param \ReflectionParameter $parameter
     *   The reflection parameter.
     *
     * @covers ::getParameterClassName
     * @dataProvider providerGetParameterClassName
     */
    public function testGetParameterClassName(?string $expected, \ReflectionParameter $parameter) : void {
        $this->assertEquals($expected, Reflection::getParameterClassName($parameter));
    }
    
    /**
     * Data provider for ::testGetParameterClassName().
     *
     * @return array[]
     */
    public static function providerGetParameterClassName() {
        $reflection_method = new \ReflectionMethod(static::class, 'existsForTesting');
        $parameters = $reflection_method->getParameters();
        return [
            'string' => [
                NULL,
                $parameters[0],
            ],
            'array' => [
                NULL,
                $parameters[1],
            ],
            'same class' => [
                'Drupal\\Tests\\Component\\Utility\\ReflectionTest',
                $parameters[2],
            ],
            'class' => [
                'Drupal\\Component\\Utility\\Reflection',
                $parameters[3],
            ],
            'parent' => [
                'PHPUnit\\Framework\\TestCase',
                $parameters[4],
            ],
            'self' => [
                'Drupal\\Tests\\Component\\Utility\\ReflectionTest',
                $parameters[5],
            ],
        ];
    }
    
    /**
     * This method exists for reflection testing only.
     *
     * Note the capital P in Parent is intentional and for testing purposes.
     */
    // phpcs:disable Generic.PHP.LowerCaseKeyword.Found
    protected function existsForTesting(string $string, array $array, ReflectionTest $test, Reflection $reflection, Parent $parent, self $self) {
    }
    // phpcs:enable

}

Members

Title Sort descending Modifiers Object type Summary
ReflectionTest::existsForTesting protected function
ReflectionTest::providerGetParameterClassName public static function Data provider for ::testGetParameterClassName().
ReflectionTest::testGetParameterClassName public function @covers ::getParameterClassName
@dataProvider providerGetParameterClassName

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