コード例 #1
0
ファイル: OrderbyTest.php プロジェクト: sqrt-pro/navigator
 function testOrderByFromURL()
 {
     $n = new Navigator(Request::create('http://localhost/hello/orderby:_name/'), new Manager());
     $n->addOrderBy('id', 'ID');
     $n->addOrderBy('name');
     $o = $n->getOrderBy(true);
     $this->assertInstanceOf('SQRT\\Navigator\\OrderBy', $o);
     $this->assertEquals('`name` DESC', $o->asSQL(), 'Сортировка получена из URL');
 }
コード例 #2
0
ファイル: NavigatorTest.php プロジェクト: sqrt-pro/navigator
 function testUrl()
 {
     $url = '/wow/id:12/';
     $r = Request::create('http://localhost' . $url);
     $n = new Navigator($r, $this->getManager());
     $this->assertInstanceOf('SQRT\\URLImmutable', $n->getUrl(), 'Объект URLImmutable');
     $this->assertEquals($url, $n->getUrl()->asString(), 'Адрес 1');
     $n = new Navigator(Request::create('/'), $this->getManager());
     $n->setUrl($url);
     $this->assertInstanceOf('SQRT\\URLImmutable', $n->getUrl(), 'Объект URLImmutable');
     $this->assertEquals($url, $n->getUrl()->asString(), 'Адрес 2');
     $u = new \SQRT\URL($url);
     $n = new Navigator(Request::create('/'), $this->getManager());
     $n->setUrl($u);
     $this->assertInstanceOf('SQRT\\URLImmutable', $n->getUrl(), 'Объект URLImmutable');
     $this->assertEquals($url, $n->getUrl()->asString(), 'Адрес 3');
 }
コード例 #3
0
ファイル: OrderBy.php プロジェクト: sqrt-pro/navigator
 public function getUrl()
 {
     if ($this->url) {
         return $this->url;
     }
     if ($this->navigator) {
         return $this->navigator->getUrlClean();
     }
     return new URLImmutable();
 }
コード例 #4
0
ファイル: FiltersTest.php プロジェクト: sqrt-pro/navigator
 function testLikeCallable()
 {
     $n = new Navigator(Request::create('http://localhost/hello/name:ололо/'), new Manager());
     $f = $n->addFilterLike('name');
     $this->assertEquals('`name` LIKE "ололо%"', $n->processFilters()->asSQL(), 'Фильтры по-умолчанию');
     $f->setCallable(function (Navigator $navi, Filter\Like $f) {
         $navi->conditions()->like('name', 'пыщпыщ%');
     });
     $exp = '`name` LIKE "пыщпыщ%"';
     $this->assertEquals($exp, $n->processFilters()->asSQL(), 'Свой фильтр');
 }