public function setUp()
 {
     parent::setUp();
     if (null !== self::$DI) {
         unset(self::$DI['app']['dbal.provider']);
     }
     self::$DI = new \Pimple();
     ini_set('memory_limit', '4096M');
     \PHPUnit_Framework_Error_Warning::$enabled = true;
     \PHPUnit_Framework_Error_Notice::$enabled = true;
     self::$DI['app'] = self::$DI->share(function ($DI) {
         return $this->loadApp('/lib/Alchemy/Phrasea/Application/Root.php');
     });
     self::$DI['cli'] = self::$DI->share(function ($DI) {
         return $this->loadCLI();
     });
     self::$DI['local-guzzle'] = self::$DI->share(function ($DI) {
         return new Guzzle(self::$DI['app']['conf']->get('servername'));
     });
     self::$DI['client'] = self::$DI->share(function ($DI) {
         return new Client($DI['app'], []);
     });
     self::$DI['user'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit']);
     });
     self::$DI['user_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_1']);
     });
     self::$DI['user_2'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_2']);
     });
     self::$DI['user_3'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_3']);
     });
     self::$DI['user_guest'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_guest']);
     });
     self::$DI['user_notAdmin'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_not_admin']);
     });
     self::$DI['user_alt1'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_alt1']);
     });
     self::$DI['user_alt2'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_alt2']);
     });
     self::$DI['user_template'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_template']);
     });
     self::$DI['registration_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_1']);
     });
     self::$DI['registration_2'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_2']);
     });
     self::$DI['registration_3'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_3']);
     });
     self::$DI['oauth2-app-user'] = self::$DI->share(function ($DI) {
         return new \API_OAuth2_Application($DI['app'], self::$fixtureIds['oauth']['user']);
     });
     self::$DI['oauth2-app-user_notAdmin'] = self::$DI->share(function ($DI) {
         return new \API_OAuth2_Application($DI['app'], self::$fixtureIds['oauth']['user_notAdmin']);
     });
     self::$DI['logger'] = self::$DI->share(function () {
         $logger = new Logger('tests');
         $logger->pushHandler(new NullHandler());
         return $logger;
     });
     self::$DI['collection'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll']);
     });
     self::$DI['collection_no_access'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_access']);
     });
     self::$DI['collection_no_access_by_status'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_status']);
     });
     if (!self::$booted) {
         if (!self::$DI['app']['phraseanet.configuration-tester']->isInstalled()) {
             echo "Phraseanet is not set up\n";
             exit(1);
         }
         self::$fixtureIds = array_merge(self::$fixtureIds, json_decode(file_get_contents(__DIR__ . '/../fixtures.json'), true));
         self::resetUsersRights(self::$DI['app'], self::$DI['user']);
         self::resetUsersRights(self::$DI['app'], self::$DI['user_notAdmin']);
         self::$booted = true;
     }
     self::$DI['lazaret_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['EM']->find('Phraseanet:LazaretFile', self::$fixtureIds['lazaret']['lazaret_1']);
     });
     foreach (range(1, 7) as $i) {
         self::$DI['record_' . $i] = self::$DI->share(function ($DI) use($i) {
             return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_' . $i]);
         });
     }
     foreach (range(1, 3) as $i) {
         self::$DI['record_story_' . $i] = self::$DI->share(function ($DI) use($i) {
             return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_story_' . $i]);
         });
     }
     self::$DI['record_no_access_resolver'] = self::$DI->protect(function () {
         $id = 'no_access';
         if (isset(self::$fixtureIds['records'][$id])) {
             return self::$fixtureIds['records'][$id];
         }
         self::$recordsInitialized[] = $id;
         $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access']);
         $record = record_adapter::createFromFile($file, self::$DI['app']);
         self::$DI['app']['subdef.generator']->generateSubdefs($record);
         self::$fixtureIds['records'][$id] = $record->get_record_id();
         return self::$fixtureIds['records'][$id];
     });
     self::$DI['record_no_access_by_status_resolver'] = self::$DI->protect(function () {
         $id = 'no_access_by_status';
         if (isset(self::$fixtureIds['records'][$id])) {
             return self::$fixtureIds['records'][$id];
         }
         self::$recordsInitialized[] = $id;
         $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access_by_status']);
         $record = record_adapter::createFromFile($file, self::$DI['app']);
         self::$DI['app']['subdef.generator']->generateSubdefs($record);
         self::$fixtureIds['records'][$id] = $record->get_record_id();
         return self::$fixtureIds['records'][$id];
     });
     self::$DI['record_no_access'] = self::$DI->share(function ($DI) {
         return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_resolver']());
     });
     self::$DI['record_no_access_by_status'] = self::$DI->share(function ($DI) {
         return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_by_status_resolver']());
     });
     if (!self::$testCaseBooted) {
         $this->bootTestCase();
     }
     self::$testCaseBooted = true;
 }
 /**
  * Deletes previously created Resources.
  */
 private static function deleteResources()
 {
     if (!empty(self::$recordsInitialized)) {
         foreach (self::$recordsInitialized as $i) {
             self::$DI['record_' . $i]->delete();
         }
         self::$recordsInitialized = [];
     }
     // Clear fixtures
     self::$fixtureIds = [];
 }