当前位置: 首页>>代码示例>>PHP>>正文


PHP PhraseanetTestCase::DI方法代码示例

本文整理汇总了PHP中PhraseanetTestCase::DI方法的典型用法代码示例。如果您正苦于以下问题:PHP PhraseanetTestCase::DI方法的具体用法?PHP PhraseanetTestCase::DI怎么用?PHP PhraseanetTestCase::DI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhraseanetTestCase的用法示例。


在下文中一共展示了PhraseanetTestCase::DI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 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 "[0;31mPhraseanet is not set up[0;37m\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]);
         });
//.........这里部分代码省略.........
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:101,代码来源:PhraseanetTestCase.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     self::$DI = new \Pimple();
     ini_set('memory_limit', '4096M');
     error_reporting(-1);
     \PHPUnit_Framework_Error_Warning::$enabled = true;
     \PHPUnit_Framework_Error_Notice::$enabled = true;
     self::$DI['app'] = self::$DI->share(function ($DI) {
         return $this->loadApp($this->getApplicationPath());
     });
     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['feed_public'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.feeds']->find(self::$fixtureIds['feed']['public']['feed']);
     });
     self::$DI['feed_public_entry'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.feed-entries']->find(self::$fixtureIds['feed']['public']['entry']);
     });
     self::$DI['feed_public_token'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.feed-tokens']->find(self::$fixtureIds['feed']['public']['token']);
     });
     self::$DI['feed_private'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.feeds']->find(self::$fixtureIds['feed']['private']['feed']);
     });
     self::$DI['feed_private_entry'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.feed-entries']->find(self::$fixtureIds['feed']['private']['entry']);
     });
     self::$DI['feed_private_token'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.feed-tokens']->find(self::$fixtureIds['feed']['private']['token']);
     });
     self::$DI['basket_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.baskets']->find(self::$fixtureIds['basket']['basket_1']);
     });
     self::$DI['basket_2'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.baskets']->find(self::$fixtureIds['basket']['basket_2']);
     });
     self::$DI['basket_3'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.baskets']->find(self::$fixtureIds['basket']['basket_3']);
     });
     self::$DI['basket_4'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.baskets']->find(self::$fixtureIds['basket']['basket_4']);
     });
     self::$DI['token_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.tokens']->find(self::$fixtureIds['token']['token_1']);
     });
     self::$DI['token_2'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.tokens']->find(self::$fixtureIds['token']['token_2']);
     });
     self::$DI['token_invalid'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.tokens']->find(self::$fixtureIds['token']['token_invalid']);
     });
     self::$DI['token_validation'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.tokens']->find(self::$fixtureIds['token']['token_validation']);
     });
     $users = ['user' => 'test_phpunit', 'user_1' => 'user_1', 'user_2' => 'user_2', 'user_3' => 'user_3', 'user_guest' => 'user_guest', 'user_notAdmin' => 'test_phpunit_not_admin', 'user_alt1' => 'test_phpunit_alt1', 'user_alt2' => 'test_phpunit_alt2', 'user_template' => 'user_template'];
     $userFactory = function ($fixtureName) {
         if ('user_guest' === $fixtureName) {
             return function ($DI) use($fixtureName) {
                 return $DI['app']['repo.users']->find(self::$fixtureIds['user'][$fixtureName]);
             };
         }
         return function ($DI) use($fixtureName) {
             $user = $DI['app']['repo.users']->find(self::$fixtureIds['user'][$fixtureName]);
             self::resetUsersRights($DI['app'], $user);
             return $user;
         };
     };
     foreach ($users as $name => $fixtureName) {
         self::$DI[$name] = self::$DI->share($userFactory($fixtureName));
     }
     self::$DI['registration_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_1']);
     });
     self::$DI['registration_2'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_2']);
     });
     self::$DI['registration_3'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_3']);
     });
     self::$DI['oauth2-app-user'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user']);
     });
     self::$DI['webhook-event'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.webhook-event']->find(self::$fixtureIds['webhook']['event']);
     });
     self::$DI['oauth2-app-user-not-admin'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user-not-admin']);
     });
     self::$DI['oauth2-app-acc-user'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.api-accounts']->find(self::$fixtureIds['oauth']['acc-user']);
     });
     self::$DI['oauth2-app-acc-user-not-admin'] = self::$DI->share(function ($DI) {
//.........这里部分代码省略.........
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:101,代码来源:PhraseanetTestCase.php


注:本文中的PhraseanetTestCase::DI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。