/**
  * @param ContainerInterface $container
  * @param $requestedName
  * @param array $options
  * @return ViewHelperGenerator
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     /** @var ModuleOptions $options */
     $options = $container->get(ModuleOptions::class);
     $filterPluginManager = $container->get('FilterManager');
     $viewHelperManager = $container->get('ViewHelperManager');
     $helperConfig = $options->getViewHelpers();
     $viewHelperGenerator = new ViewHelperGenerator($filterPluginManager, $viewHelperManager, $helperConfig);
     $viewHelperGenerator->setDebug($options->isDebug());
     return $viewHelperGenerator;
 }
 public function testGenerateViewHelpers()
 {
     $config = (new Module())->getConfig();
     $helperPluginManager = new HelperPluginManager();
     $helperPluginManager->setServiceLocator(new ServiceManager());
     $filterManager = new FilterPluginManager();
     $basePath = $helperPluginManager->get('basePath');
     $basePath->setBasePath('/assets');
     $basePathFilter = new BasePathFilter($basePath);
     $filterManager->setService('basePath', $basePathFilter);
     $cacheBusterFilter = new CacheBusterFilter(__DIR__ . '/_files');
     $filterManager->setService('cacheBuster', $cacheBusterFilter);
     $generator = new ViewHelperGenerator($filterManager, $helperPluginManager, $config['con-layout']['view_helpers']);
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($helperPluginManager);
     /* @var $headLink HeadLink */
     $headLink = $helperPluginManager->get('headLink');
     $headLinkProxy = new HeadLinkProxy($headLink);
     $helperPluginManager->setService(get_class($headLinkProxy), $headLinkProxy);
     /* @var $headScript HeadScript */
     $headScript = $helperPluginManager->get('headScript');
     $headScriptProxy = new HeadScriptProxy($headScript);
     $helperPluginManager->setService(get_class($headScriptProxy), $headScriptProxy);
     /* @var $doctype Doctype */
     $doctype = $helperPluginManager->get('doctype');
     $doctype('HTML5');
     /* @var $headTitle HeadTitle */
     $headTitle = $helperPluginManager->get('headTitle');
     $headTitleProxy = new HeadTitleProxy($headTitle);
     $helperPluginManager->setService(get_class($headTitleProxy), $headTitleProxy);
     /* @var $headMeta HeadMeta */
     $headMeta = $helperPluginManager->get('headMeta');
     $headMetaProxy = new HeadMetaProxy($headMeta);
     $helperPluginManager->setService(get_class($headMetaProxy), $headMetaProxy);
     $headMeta->setView($renderer);
     $generator->generate($this->getLayoutStructure());
     foreach (['/assets/css/test.css', '/assets/css/main.css'] as $expected) {
         $this->assertContains($expected, $headLink->toString());
     }
     foreach (['jquery.min.js', 'jquery-ui.min.js'] as $expected) {
         $this->assertContains($expected, $headScript->toString());
     }
     $this->assertEquals('<!DOCTYPE html>', (string) $doctype);
     $headTitle->setSeparator(' | ');
     $expected = 'First | My Title | Another Title';
     $this->assertContains($expected, $headTitle->toString());
     $contains = ['charset="utf8"', 'name="description" content="My description"', 'name="keywords" content="keyword1, keyword2, keyword3"'];
     foreach ($contains as $expected) {
         $this->assertContains($expected, $headMeta->toString());
     }
 }