Skip to content

Instantly share code, notes, and snippets.

@ismaail
Created August 20, 2019 00:22
Show Gist options
  • Save ismaail/ee88984d9caed3baf25d14e7c387a16f to your computer and use it in GitHub Desktop.
Save ismaail/ee88984d9caed3baf25d14e7c387a16f to your computer and use it in GitHub Desktop.
<?php
class TestCase extends \PHPUnit\Framework\TestCase
{
public function testExample()
{
$refClass = new \ReflectionClass(\App\MyClass::class);
$refMethod = $refClass->getMethod('somePrivateMethod');
$refMethod->setAccessible(true); // make private method accessible
$this->assertEqual(
'expected value',
$refMethod->invoke(new \App\MyClass, 'parameter for somePrivateMethod()')
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment