PrivateMethodUnitTestTrait.php

Same filename and directory in other branches
  1. 9 core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php
  2. 10 core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php

Namespace

Drupal\Tests\ckeditor5\Traits

File

core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\ckeditor5\Traits;


/**
 * Provides methods to test protected/private methods in unit tests.
 *
 * @internal
 */
trait PrivateMethodUnitTestTrait {
    
    /**
     * Gets a protected/private method to test.
     *
     * @param string $fqcn
     *   A fully qualified classname.
     * @param string $name
     *   The method name.
     *
     * @return \ReflectionMethod
     *   The accessible method.
     */
    protected static function getMethod(string $fqcn, string $name) : \ReflectionMethod {
        $class = new \ReflectionClass($fqcn);
        $method = $class->getMethod($name);
        return $method;
    }

}

Traits

Title Deprecated Summary
PrivateMethodUnitTestTrait Provides methods to test protected/private methods in unit tests.

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