public function testDirectiveParsing() { $app = $this->getApp(); $qb = new ContentQueryParser($app['storage'], $app['query.select']); $qb->setQuery('entries'); $qb->setParameters(['order' => '-datepublish', 'id' => '!1']); $qb->parse(); $this->assertEquals(['entries'], $qb->getContentTypes()); $this->assertEquals('select', $qb->getOperation()); $this->assertEquals('-datepublish', $qb->getDirective('order')); $this->assertEquals('!1', $qb->getParameter('id')); $this->assertEquals(1, count($qb->getParameters())); }
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); }