/**
  * @dataProvider upperBoundProvider
  */
 public function testSetUpperBound($bound, $testValue, $validity)
 {
     $definition = $this->getEmptyInstance();
     $definition->setArrayValues(array('upperbound' => $bound));
     $this->validate($definition, (string) $testValue, $validity);
     $options = new Options();
     $options->setRawStringInputs(false);
     $this->validate($definition, $testValue, $validity, $options);
 }
Esempio n. 2
0
 /**
  * Values and definitions in-system parameter handling.
  * Options set to expect non-raw values.
  *
  * @return array
  */
 private function getTypedParams()
 {
     $params = array('awesome' => true, 'howmuch' => '42', 'float' => 4.2, 'page' => 'Ohi there!', 'Text' => 'foo bar baz o_O', 'text1 ' => 'foo bar baz o_O', ' text2' => 'foo bar baz o_O');
     $definitions = array('awesome' => array('type' => 'boolean'), 'howmuch' => array('type' => 'integer', 'default' => 9001), 'float' => array('type' => 'float', 'lowerbound' => 9001, 'default' => 9000.1), 'page' => array('type' => 'string', 'hastoexist' => false), 'text' => array('default' => 'some text'), 'text1' => array('default' => 'some text'), 'text2' => array('default' => 'some text'));
     $options = new Options();
     $options->setRawStringInputs(false);
     $options->setLowercaseNames(false);
     $options->setTrimNames(false);
     $expected = array('awesome' => true, 'howmuch' => 9001, 'float' => 9000.1, 'page' => 'Ohi there!', 'text' => 'some text', 'text1' => 'some text', 'text2' => 'some text');
     return array($params, $definitions, $options, $expected);
 }
 /**
  * @dataProvider instanceProvider
  */
 public function testValidate(IParamDefinition $definition)
 {
     foreach (array(true, false) as $stringlyTyped) {
         $values = $this->valueProvider($stringlyTyped);
         $options = new Options();
         $options->setRawStringInputs($stringlyTyped);
         foreach ($values[$definition->getName()] as $data) {
             list($input, $valid, ) = $data;
             $param = new Param($definition);
             $param->setUserValue($definition->getName(), $input, $options);
             $definitions = array();
             $param->process($definitions, array(), $options);
             $this->assertEquals($valid, $param->getErrors() === array(), 'The validation process should ' . ($valid ? '' : 'not ') . 'pass');
         }
     }
     $this->assertTrue(true);
 }