Пример #1
0
 function testOnMapRequest()
 {
     $p = \PMVC\plug($this->_plug);
     $url = \PMVC\plug('url', ['REQUEST_URI' => '/fake/hello', 'SCRIPT_NAME' => '/fake/']);
     $p->onMapRequest();
     $r = \PMVC\plug('controller')->getRequest();
     $this->assertEquals(['hello'], \PMVC\get($r));
 }
Пример #2
0
 function testUrlObject()
 {
     $p = PMVC\plug($this->_plug);
     $url = 'http://*****:*****@hostname:9090/path?zzz=yyy&arg=value#anchor';
     $o = $p->getUrl($url);
     $this->assertEquals(['scheme' => 'http', 'host' => 'hostname', 'port' => 9090, 'user' => 'username', 'pass' => 'password', 'path' => ['', 'path'], 'query' => new \PMVC\HashMap(['arg' => 'value', 'zzz' => 'yyy']), 'fragment' => 'anchor'], \PMVC\get($o));
     $expected = 'http://*****:*****@hostname:9090/path?arg=value&zzz=yyy#anchor';
     $this->assertEquals($expected, (string) $o);
 }
Пример #3
0
 public function getArr()
 {
     foreach ($this as $k => $v) {
         if (\PMVC\isArrayAccess($v)) {
             $ref = $this->{$k};
             $v = $ref($v->getArr());
         }
         if (0 !== $v && false !== $v && empty($v)) {
             unset($this[$k]);
         }
     }
     return \PMVC\get($this);
 }
Пример #4
0
 function stringify()
 {
     $scheme = !empty($this[SCHEME]) ? $this[SCHEME] . '://' : '';
     $host = $this[HOST];
     $port = !empty($this[PORT]) ? ':' . $this[PORT] : '';
     $user = $this[USER];
     $pass = !empty($this[PASS]) ? ':' . $this[PASS] : '';
     $pass = $user || $pass ? $pass . '@' : '';
     $query = \PMVC\get($this[QUERY]);
     ksort($query);
     $query = http_build_query($query);
     $query = ($query ? '?' : '') . $query;
     $path = implode('/', $this[PATH]);
     $path = ($host && 0 !== strpos($path, '/') && ($path || $query) ? '/' : '') . $path;
     $fragment = !empty($this[FRAGMENT]) ? '#' . $this[FRAGMENT] : '';
     return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
 }
Пример #5
0
 public function toArray(Page $page)
 {
     $arrPage = \PMVC\get($page);
     foreach ($arrPage as $k => $v) {
         if (is_null($v)) {
             unset($arrPage[$k]);
         }
     }
     if (isset($arrPage[URL])) {
         $arrPage[URL] = (string) $arrPage[URL];
     }
     return $arrPage;
 }
Пример #6
0
 public function testGetAll()
 {
     $arr = ['a' => '111', 'b' => '222'];
     $hash = new HashMap($arr);
     $this->assertEquals($arr, \PMVC\get($hash));
 }