Skip to content

Instantly share code, notes, and snippets.

@pablofmorales-olx
Created January 24, 2013 17:55
Show Gist options
  • Save pablofmorales-olx/4625759 to your computer and use it in GitHub Desktop.
Save pablofmorales-olx/4625759 to your computer and use it in GitHub Desktop.
How to test private properties.
public function test_setResource()
{
$connection = new \Connection();
$originalName = 'ThisIsMyResource';
$connection->setResource($originalName);
$reflection = new \ReflectionClass('Connection');
$propertyRef = $reflection->getProperty('_resource');
$propertyRef->setAccessible(TRUE);
$resourceName = $propertyRef->getValue($connection);
$this->assertEquals($originalName, $resourceName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment