/** * @dataProvider dataProviderTestFactory */ public function testFactory($config, $expected, $exceptionName = '') { if ($exceptionName) { $this->setExpectedException($exceptionName); } $actual = Miao_Router_Rule_Validator::factory($config); $this->assertInstanceOf($expected, $actual); }
protected function _init($validators) { $rule = $this->getRule(); $parts = explode('/', $rule); foreach ($parts as $value) { if (':' == $value[0]) { $id = substr($value, 1); $config = $this->_searchValidatorConfigById($id, $validators); if (is_null($config)) { $config = array('id' => $id, 'type' => 'NotEmpty'); } $this->_params[] = $id; } else { $config = array('id' => null, 'type' => 'Compare', 'str' => $value); } $validator = Miao_Router_Rule_Validator::factory($config); $this->_validators[] = $validator; } $this->_parts = $parts; if (count($validators)) { $message = sprintf("Some validators did not find his part of uri (%s). Validators: %s", implode('/', $this->_parts), print_r($validators, true)); throw new Miao_Router_Rule_Exception($message); } }