Example #1
0
 private static function callConstructor($reflClass, $instance, $params, $counter)
 {
     if ($reflClass->hasMethod('__construct')) {
         if ($reflClass->getMethod("__construct")->isPublic()) {
             MethodInvoker::invoke($instance, '__construct', $params);
         } else {
             $className = $reflClass->getName();
             throw new RuntimeException("The constructor is not public in {$className} class");
         }
     }
 }
Example #2
0
 private function handleUnAuthorizedException($instance, $ex)
 {
     $reflClass = new ReflectionClass($instance);
     $throwFurther = true;
     foreach ($reflClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
         if ($method->hasAnnotation(ExceptionHandler::class)) {
             $throwFurther &= MethodInvoker::invoke($instance, $method->getName(), array());
         }
     }
     if ($throwFurther) {
         throw $ex;
     }
 }
Example #3
0
 /**
  * @test
  */
 public function testValidationErrorNotBlankAddressStreet()
 {
     $this->markTestIncomplete('This test has not been implemented yet.');
     $request = InvokerConfig::getRequestHelper();
     $request->setParam('firstName', 'Lobi');
     $request->setParam('lastName', 'Lobi');
     $request->setParam('phones', array('+31644449576', '+36209820644'));
     $request->setParam('address', array('street' => null));
     $ref = new ReflectionClass(ClassInvokerFixture::class);
     $instance = $ref->newInstanceWithoutConstructor();
     MethodInvoker::invoke($instance, 'indexAction');
     $bindingResultProperty = $ref->getProperty('bindingResult');
     $bindingResultProperty->setAccessible(true);
     /* @var $bindingResult BindingResult */
     $bindingResult = $bindingResultProperty->getValue($instance);
     $this->assertEquals(1, count($bindingResult), (string) $bindingResult);
     /* @var $current ConstraintViolation */
     $current = $bindingResult->getIterator()->current();
     $this->assertEquals('address.street', $current->getPropertyPath());
     $this->assertEquals((new NotBlank())->message, $current->getMessage());
 }