コード例 #1
0
 /**
  * 
  * @param ReflectionParameter $parameter
  * @void
  */
 private function handleRequestParam(ReflectionParameter $parameter)
 {
     $parameterName = $parameter->getName();
     if ($this->hasAnnotation(RequestParam::class, array('value' => $parameterName))) {
         $annotation = $this->getAnnotation(RequestParam::class, array('value' => $parameterName));
         if ($annotation instanceof RequestBody) {
             $value = trim(trim(file_get_contents('php://input'), '"'));
         } else {
             $value = InvokerConfig::getRequestHelper()->getParam($parameterName);
         }
         $this->handleRequiredRequestParam($parameter, $annotation, $value);
         if ($annotation->defaultValue !== '****UNDEFINED****' && $value === null) {
             $value = $annotation->defaultValue;
         }
         $this->invokeParams[$parameter->getPosition()] = $value;
     }
 }
コード例 #2
0
ファイル: Request.php プロジェクト: phspring/common
 public function __construct()
 {
     $this->helper = InvokerConfig::getRequestHelper();
 }
コード例 #3
0
ファイル: MethodInvokerTest.php プロジェクト: phspring/common
 /**
  * @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());
 }