예제 #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
파일: test.php 프로젝트: pmvc-plugin/url
 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
파일: HashMapTest.php 프로젝트: pmvc/pmvc
 public function testGetAll()
 {
     $arr = ['a' => '111', 'b' => '222'];
     $hash = new HashMap($arr);
     $this->assertEquals($arr, \PMVC\get($hash));
 }