current() public method

See also: Bolt\Twig\Handler\RecordHandler::current()
public current ( $content )
Example #1
0
 public function testCurrent()
 {
     $app = $this->getApp();
     $handlers = $this->getTwigHandlers($app);
     $handlers['record'] = $this->getMockHandler('RecordHandler', 'current');
     $twig = new TwigExtension($app, $handlers, true);
     $twig->current(null);
 }
Example #2
0
 public function testCurrent()
 {
     // Setup the db so we have a predictable content url to test
     $app = $this->getApp();
     $this->addDefaultUser($app);
     $storage = new Storage($app);
     $content = $storage->getEmptyContent('showcases');
     $content->setValues(['title' => 'New Showcase', 'slug' => 'new-showcase', 'status' => 'published']);
     $storage->saveContent($content);
     $phpunit = $this;
     $handlers = $this->getTwigHandlers($app);
     $twig = new TwigExtension($app, $handlers, false);
     $storage = new Storage($app);
     // Get the content object and create a routed request
     $request = Request::create('/showcase/new-showcase');
     $app->before(function ($request, $app) use($phpunit, $twig, $storage) {
         $fetched = $storage->getContent('showcases/1');
         $phpunit->assertTrue($twig->current($fetched));
     });
     $app->handle($request);
     // Test works on custom homepage
     $app['config']->set('general/homepage', 'showcase/new-showcase');
     $request = Request::create('/');
     $app->before(function ($request, $app) use($phpunit, $twig, $storage) {
         $fetched = $storage->getContent('showcases/1');
         $phpunit->assertTrue($twig->current($fetched));
     });
     $app->handle($request);
     // Delete the content so we're back to a clean database
     $storage->deleteContent('showcases', 1);
 }