/**
  * Adds the claroline common assets and translations into the package.
  *
  * @param \ZipArchive $archive
  * @param string      $locale
  */
 private function addCommons(\ZipArchive $archive, $locale)
 {
     $assets = ['bootstrap.css' => 'themes/claroline/bootstrap.css', 'font-awesome.css' => 'packages/font-awesome/css/font-awesome.min.css', 'claroline-reset.css' => 'vendor/clarolinescorm/claroline-reset.css', 'jquery.min.js' => 'packages/jquery/dist/jquery.min.js', 'jquery-ui.min.js' => 'packages/jquery-ui/jquery-ui.min.js', 'bootstrap.min.js' => 'packages/bootstrap/dist/js/bootstrap.min.js', 'translator.js' => 'bundles/bazingajstranslation/js/translator.min.js', 'router.js' => 'bundles/fosjsrouting/js/router.js', 'video.min.js' => 'packages/video.js/dist/video.min.js', 'video-js.min.css' => 'packages/video.js/dist/video-js.min.css', 'video-js.swf' => 'packages/video.js/dist/video-js.swf'];
     $webpackAssets = ['commons.js' => 'dist/commons.js', 'claroline-distribution-plugin-video-player-watcher.js' => 'dist/claroline-distribution-plugin-video-player-watcher.js'];
     $translationDomains = ['resource', 'home', 'platform', 'error', 'validators'];
     foreach ($assets as $filename => $originalFile) {
         $this->copyToPackage($archive, 'commons/' . $filename, $this->getFilePath($this->webPath, $originalFile));
     }
     // Add webpack assets
     foreach ($webpackAssets as $filename => $originalFile) {
         $this->copyToPackage($archive, 'commons/' . $filename, $this->getFilePath($this->webPath, $this->webpack->hotAsset($originalFile, true)));
     }
     // Add FontAwesome font files
     $fontDir = $this->webPath . DIRECTORY_SEPARATOR . 'packages/font-awesome/fonts';
     $files = scandir($fontDir);
     foreach ($files as $file) {
         $filePath = $fontDir . DIRECTORY_SEPARATOR . $file;
         if (is_file($filePath)) {
             $this->copyToPackage($archive, 'fonts/' . $file, $this->getFilePath($fontDir, $file));
         }
     }
     // Generate JS routes with FOSJSRoutingBundle
     $request = new Request(['callback' => 'fos.Router.setData']);
     $jsRoutes = $this->jsRouterCtrl->indexAction($request, 'js');
     $this->saveToPackage($archive, 'commons/routes.js', $jsRoutes->getContent());
     // Add common translations
     foreach ($translationDomains as $domain) {
         $translationFile = 'js/translations/' . $domain . '/' . $locale . '.js';
         $this->copyToPackage($archive, 'translations/' . $domain . '.js', $this->getFilePath($this->webPath, $translationFile));
     }
 }
 public function testIndexActionWithoutRoutes()
 {
     $controller = new Controller($this->getSerializer(), $this->getExtractor(), sys_get_temp_dir());
     $response = $controller->indexAction(Request::create('/'), 'json');
     $this->assertEquals('{"base_url":"","routes":[]}', $response->getContent());
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('application/json', $response->headers->get('Content-Type'));
 }
 public function testCacheControl()
 {
     $cacheControlConfig = array('enabled' => true, 'public' => true, 'expires' => '2013-10-04 23:59:59 UTC', 'maxage' => 123, 'smaxage' => 456, 'vary' => array());
     $controller = new Controller($this->getSerializer(), $this->getExtractor(), $cacheControlConfig, sys_get_temp_dir());
     $response = $controller->indexAction($this->getRequest('/'), 'json');
     $this->assertTrue($response->headers->hasCacheControlDirective('public'));
     $this->assertEquals('2013-10-04 23:59:59', $response->getExpires()->format('Y-m-d H:i:s'));
     $this->assertTrue($response->headers->hasCacheControlDirective('max-age'));
     $this->assertEquals(123, $response->headers->getCacheControlDirective('max-age'));
     $this->assertTrue($response->headers->hasCacheControlDirective('s-maxage'));
     $this->assertEquals(456, $response->headers->getCacheControlDirective('s-maxage'));
 }