for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GFG\DTOContext\DataWrapper;
class Mock
{
/**
* Creates a mock for a given transfer (because of dynamic getters and setters)
*/
public static function create($name, \PHPUnit_Framework_TestCase $phpunit)
$methods = array();
$ref = new \ReflectionClass($name);
foreach ($ref->getProperties() as $property) {
$methods[] = 'get' . ucfirst($property->name);
$methods[] = 'set' . ucfirst($property->name);
}
foreach ($ref->getMethods() as $method) {
// do not mock array object methods to we can iterate these mocks
if ($method->class === 'ArrayObject') {
continue;
$methods[] = $method->name;
return $phpunit->getMockBuilder($name)
->disableOriginalConstructor()
->setMethods($methods)
->getMock();