You are here

public function ProtectedPrivatesTest::getAccessibleMethod in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/phpunit_example/tests/src/Unit/ProtectedPrivatesTest.php \Drupal\Tests\phpunit_example\Unit\ProtectedPrivatesTest::getAccessibleMethod()

Get an accessible method using reflection.

2 calls to ProtectedPrivatesTest::getAccessibleMethod()
ProtectedPrivatesTest::testPrivateAdd in phpunit_example/tests/src/Unit/ProtectedPrivatesTest.php
Test ProtectedPrivate::privateAdd().
ProtectedPrivatesTest::testPrivateAddBadData in phpunit_example/tests/src/Unit/ProtectedPrivatesTest.php
Test ProtectedPrivate::privateAdd() with bad data.

File

phpunit_example/tests/src/Unit/ProtectedPrivatesTest.php, line 46

Class

ProtectedPrivatesTest
ProtectedPrivates unit testing of restricted methods.

Namespace

Drupal\Tests\phpunit_example\Unit

Code

public function getAccessibleMethod($class_name, $method_name) {
  $class = new \ReflectionClass($class_name);
  $method = $class
    ->getMethod($method_name);
  $method
    ->setAccessible(TRUE);
  return $method;
}