PHPUnit - Private Method Test Eden Fonksiyon
PHPUnit - Private Method Test Eden Fonksiyon

13 Dec, 2022 1 dk

PHPUnit - Private Method Test Eden Fonksiyon

13 Dec, 2022

1 dk

PHPUnit - Private Method Test Eden Fonksiyon

Private bir methodu test etmek için aşağıdaki gibi bir ReflectionClass ve ReflectionMethod kullanan fonksiyon yazabiliriz.

public function testPrivateMethod($class, $method, $args)
{
	$reflectionClass = new ReflectionClass($class);
	$method = $reflectionClass->getMethod($method);
	$method->setAccessible(true);
	return $method->invokeArgs($class, $args);
}
İLGİLİ MAKALELER
İLGİLİ KOD PARÇALARI