public function testItWorks()
 {
     $collection = array('a' => 1);
     $paramRules = array('a' => f\required(array('v' => 'is_int', 'n' => 'strval')), 'b' => f\optional(array('d' => 2.0, 'n' => 'intval')));
     $expected = array('a' => '1', 'b' => 2);
     $this->assertSame($expected, f\fill_validating_normalizing_or_throw($collection, $paramRules));
 }
 public function __construct(TokenGeneratorInterface $tokenGenerator, $params)
 {
     $this->tokenGenerator = $tokenGenerator;
     f\validate_coll_or_throw($params, ['type' => f\required(['v' => 'is_string']), 'lifetime' => f\required(['v' => 'is_int'])]);
     $this->type = $params['type'];
     $this->lifetime = $params['lifetime'];
 }
Example #3
0
 public function testItReturnsTheResultInTheParamRulesOrder()
 {
     $coll = array('b' => 2.0);
     $rules = array('a' => f\optional(array('d' => 1)), 'b' => f\required());
     $expected = array('a' => 1, 'b' => 2.0);
     $this->assertSame($expected, f\fill($coll, $rules));
 }
Example #4
0
 public function testRequiredPassesTheParams()
 {
     $paramRule = f\required(array('v' => 'foo', 'n' => 'bar'));
     $this->assertInstanceOf('felpado\\required', $paramRule);
     $this->assertSame('foo', $paramRule->getValidator());
     $this->assertSame('bar', $paramRule->getNormalizer());
 }
Example #5
0
 public function testParamRulesWithoutNormalizerAreIgnored()
 {
     $collection = array('a' => 1, 'b' => 2.0);
     $normalizers = array('a' => f\required(array('n' => 'strval')), 'b' => f\optional());
     $expected = array('a' => '1', 'b' => 2.0);
     $this->assertSame($expected, f\normalize_coll($collection, $normalizers));
 }
 public function __construct(Storage $storage, $params)
 {
     $this->storage = $storage;
     f\validate_coll_or_throw($params, ['lifetime' => f\required(['v' => 'is_scalar']), 'resource_processor' => f\required(['v' => 'is_callable'])]);
     $this->lifetime = $params['lifetime'];
     $this->resourceProcessor = $params['resource_processor'];
     $this->scopesObtainer = new ScopesObtainer();
     $this->tokenGenerator = new BearerTokenGenerator(new ArrayRandRandomGenerator());
     $this->clientObtainer = $this->createClientObtainer();
     $this->tokenCreator = $this->createTokenCreator();
 }
 /**
  * @expectedException \Exception
  */
 public function testItThrowsIfValidationFails()
 {
     f\fill_validating_or_throw(array('a' => 1), array('a' => f\required(array('v' => 'is_float'))));
 }
Example #8
0
 private function getParamsRules()
 {
     return ['id' => f\required(['v' => 'is_scalar']), 'secret' => f\optional(['v' => 'is_scalar']), 'allowedGrantTypes' => f\optional(['v' => 'is_array', 'd' => []]), 'allowedScopes' => f\optional(['v' => 'is_array', 'd' => []]), 'defaultScope' => f\optional(['v' => 'is_string'])];
 }
Example #9
0
 private function getParamsRules()
 {
     return ['name' => f\required(['v' => 'is_string']), 'children' => f\optional(['v' => 'is_string'])];
 }
Example #10
0
 private function getParamsRules()
 {
     return ['token' => f\required(['v' => 'is_string']), 'accessTokenToken' => f\required(['v' => 'is_string']), 'createdAt' => f\required(['v' => 'is_int']), 'lifetime' => f\required(['v' => 'is_int'])];
 }
Example #11
0
 private function getParamsRules()
 {
     return ['token' => f\required(['v' => 'is_string']), 'type' => f\required(['v' => 'is_string']), 'clientId' => f\required(['v' => 'is_scalar']), 'userId' => f\required(['v' => 'is_scalar']), 'createdAt' => f\optional(['v' => 'is_int', 'd' => time()]), 'lifetime' => f\required(['v' => 'is_int']), 'scope' => f\optional(['v' => 'is_string'])];
 }
 /**
  * @expectedException \Exception
  */
 public function testItThrowsWithErrors()
 {
     f\validate_coll_or_throw(array('a' => 1), array('a' => f\required(array('v' => 'is_float'))));
 }
Example #13
0
 public function testValidatesWhenRequired()
 {
     $this->assertSame(array(), f\validate_coll(array('a' => 1), array('a' => f\required(array('v' => 'is_int')))));
     $this->assertSame(array('a' => 'invalid'), f\validate_coll(array('a' => 1), array('a' => f\required(array('v' => 'is_string')))));
 }
 public static function paramRules()
 {
     return array('env' => f\required(), 'debug' => f\required(), 'root_dir' => f\required(), 'bundles' => f\optional(array('validator' => 'is_array', 'default_value' => array())), 'container_configurator' => f\optional(array('validator' => 'is_callable')));
 }
 public function __construct(array $params)
 {
     $this->params = f\fill_validating_or_throw($params, array('separator' => f\required(array('v' => 'is_string'))));
 }