Example #1
0
 function testPlugin()
 {
     $view = \PMVC\plug('view', [_CLASS => '\\PMVC\\FakeView']);
     $c = \PMVC\plug('controller');
     $c->setApp('error');
     $c->plugApp(['./']);
     $r = $c->getRequest();
     $r['errors'][] = 1001;
     $result = $c->process();
     $actual = \PMVC\value($result, [0, 'v', 'errors', '0']);
     $expected = new Error('1001', ['message' => 'Username can\'t empty, and must be at least 6 characters long', 'field' => 'username']);
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 function testDebug()
 {
     $c = \PMVC\plug('controller');
     $c->setApp('dimension');
     $c->plugApp(['./']);
     \PMVC\plug('dev');
     \PMVC\plug('debug', ['level' => 'dimension', 'output' => 'debug_store']);
     $r = $c->getRequest();
     $r['test'] = 'fakeDimension';
     $result = $c->process();
     $actual = \PMVC\value($result, [0, 'v', 'debugs', '0']);
     $expected = ['dimension', ['fakeDimension' => 'test']];
     $this->assertEquals($expected, $actual);
 }
Example #3
0
 /**
  * Get tpl files from path
  */
 function getFile($tpl_name, $useDefault = true)
 {
     $file = null;
     $paths = p\value($this->_configs, ['paths']);
     if (!empty($paths[$tpl_name])) {
         $file = $paths[$tpl_name];
     } elseif ($useDefault) {
         $file = p\value($paths, ['index']);
     }
     if (!empty($file)) {
         return p\realpath($file);
     } else {
         return null;
     }
 }
Example #4
0
 function processInputForOneDimension($f, $dimension)
 {
     $keys = explode('_', $dimension);
     $inputs = [];
     foreach ($keys as $key) {
         $inputs[] = \PMVC\value($f, [$key]);
     }
     $all_input = $this->flatten($inputs);
     if (empty($all_input)) {
         return [];
     }
     if (\PMVC\isdev(DEBUG_KEY)) {
         foreach ($all_input as $i) {
             $this->_inputs[$i] = $dimension;
         }
     }
     if (count($all_input) > 1) {
         return $this->getMultiInputConfigs($all_input, $dimension);
     } else {
         $all_input = reset($all_input);
         return $this->getOneInputConfigs($all_input, $dimension);
     }
 }
Example #5
0
 public function onSetConfig__run_form_($subject)
 {
     $subject->detach($this);
     $trace = p\value(p\getOption(_RUN_FORM), [INPUT_FIELD]);
     $this->setLevelType($trace, false);
 }