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'); }
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'); }
public function getUrl() { if ($this->url) { return $this->url; } if ($this->navigator) { return $this->navigator->getUrlClean(); } return new URLImmutable(); }
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(), 'Свой фильтр'); }