public function testSingleItemMode() { $app = $this->getApp(); $qb = new ContentQueryParser($app['storage'], $app['query.select']); $qb->setQuery('pages/5'); $qb->setParameter('printquery', true); $qb->parse(); $this->assertEquals(['pages'], $qb->getContentTypes()); $this->assertEquals('namedselect', $qb->getOperation()); $this->assertEquals('5', $qb->getIdentifier()); $this->expectOutputString('SELECT pages.* FROM bolt_pages pages WHERE pages.id = :id_1'); $res = $qb->fetch(); $this->assertInstanceOf('Bolt\\Storage\\Entity\\Content', $res); }
public function testNativeSearchHandlerFallback() { $app = $this->getApp(); $qb = new ContentQueryParser($app['storage'], $app['query.select']); $qb->addService('search', $app['query.search']); $qb->addService('search_weighter', $app['query.search_weighter']); $qb->setQuery('pages/nativesearch/4'); $qb->setParameters(['filter' => 'lorem ipsum']); $res = $qb->fetch(); $this->assertEquals(4, $res->count()); }
public function testLatestHandler() { $this->resetDb(); $app = $this->getApp(); $this->addSomeContent($app); $qb = new ContentQueryParser($app['storage'], $app['query.select']); $qb->setQuery('pages/latest/4'); $res = $qb->fetch(); $this->assertEquals(4, count($res)); $count = 5; foreach ($res as $item) { $this->assertEquals($count, $item['id']); $count--; } }