public function testCreatesParamFromArray()
 {
     $p = new ApiParam($this->data);
     $this->assertEquals('foo', $p->getName());
     $this->assertEquals('bar', $p->getType());
     $this->assertEquals(true, $p->getRequired());
     $this->assertEquals('123', $p->getDefault());
     $this->assertEquals('456', $p->getDoc());
     $this->assertEquals(2, $p->getMinLength());
     $this->assertEquals(5, $p->getMaxLength());
     $this->assertEquals('body', $p->getLocation());
     $this->assertEquals('static!', $p->getStatic());
     $this->assertEquals('before.', $p->getPrepend());
     $this->assertEquals('.after', $p->getAppend());
     $this->assertEquals(array('trim', 'json_encode'), $p->getFilters());
 }
Esempio n. 2
0
 public function testCanBuildUpParams()
 {
     $p = new ApiParam(array());
     $p->setName('foo')->setAppend('a')->setDefault('b')->setDoc('c')->setFilters(array('d'))->setLocation('e')->setLocationKey('f')->setMaxLength(2)->setMinLength(1)->setPrepend('g')->setRequired(true)->setStatic('h')->setType('i')->setTypeArgs(array('j'));
     $p->addFilter('foo');
     $this->assertEquals('foo', $p->getName());
     $this->assertEquals('a', $p->getAppend());
     $this->assertEquals('b', $p->getDefault());
     $this->assertEquals('c', $p->getDoc());
     $this->assertEquals(array('d', 'foo'), $p->getFilters());
     $this->assertEquals('e', $p->getLocation());
     $this->assertEquals('f', $p->getLocationKey());
     $this->assertEquals(2, $p->getMaxLength());
     $this->assertEquals(1, $p->getMinLength());
     $this->assertEquals('g', $p->getPrepend());
     $this->assertEquals(true, $p->getRequired());
     $this->assertEquals('h', $p->getStatic());
     $this->assertEquals('i', $p->getType());
     $this->assertEquals(array('j'), $p->getTypeArgs());
 }
Esempio n. 3
0
 public function testAllowsExplicitTypeArgs()
 {
     $p = new ApiParam(array('type' => 'foo', 'type_args' => array('baz', 'bar', 'boo')));
     $this->assertEquals('foo', $p->getType());
     $this->assertEquals(array('baz', 'bar', 'boo'), $p->getTypeArgs());
     $p = new ApiParam(array('type' => 'foo', 'type_args' => 'baz'));
     $this->assertEquals('foo', $p->getType());
     $this->assertEquals(array('baz'), $p->getTypeArgs());
 }