Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

phpunit test private function

/**
 	 * testBar
 	 *
 	 * @author	Joe Sexton <joe@webtipblog.com>
 	 */
	public function testBar()
	{
		$number = 1;

		$object = new Foo();
		$reflector = new ReflectionClass( 'Foo' );
		$method = $reflector->getMethod( 'bar' );
		$method->setAccessible( true );

		$result = $method->invokeArgs( $object, array( $number ) );

		$this->assertEquals( 1, $result ); // whatever your assertion is

	}
Source by www.webtipblog.com #
 
PREVIOUS NEXT
Tagged: #phpunit #test #private #function
ADD COMMENT
Topic
Name
7+2 =