trait PrivateMethodUnitTestTrait

Same name in other branches
  1. 10 core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php \Drupal\Tests\ckeditor5\Traits\PrivateMethodUnitTestTrait
  2. 11.x core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php \Drupal\Tests\ckeditor5\Traits\PrivateMethodUnitTestTrait

Provides methods to test protected/private methods in unit tests.

@internal

Hierarchy

2 files declare their use of PrivateMethodUnitTestTrait
CKEditor5Test.php in core/modules/ckeditor5/tests/src/Unit/CKEditor5Test.php
SmartDefaultSettingsTest.php in core/modules/ckeditor5/tests/src/Unit/SmartDefaultSettingsTest.php

File

core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php, line 10

Namespace

Drupal\Tests\ckeditor5\Traits
View source
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);
        $method->setAccessible(TRUE);
        return $method;
    }

}

Members

Title Sort descending Modifiers Object type Summary
PrivateMethodUnitTestTrait::getMethod protected static function Gets a protected/private method to test.

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