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


PHP Environment::getContainer方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $grantTypeFactory = new GrantTypeFactory();
     $grantTypeFactory->add(new TestImplicit());
     Environment::getContainer()->set('oauth2_grant_type_factory', $grantTypeFactory);
 }
开发者ID:seytar,项目名称:psx,代码行数:7,代码来源:AuthorizationAbstractTest.php

示例2: testCommandFileExists

 /**
  * @expectedException \RuntimeException
  */
 public function testCommandFileExists()
 {
     $command = $this->getMockBuilder('PSX\\Console\\Generate\\ControllerCommand')->setConstructorArgs(array(Environment::getContainer()))->setMethods(array('makeDir', 'writeFile', 'isDir', 'isFile'))->getMock();
     $command->expects($this->at(0))->method('isDir')->with($this->equalTo('library' . DIRECTORY_SEPARATOR . 'Acme' . DIRECTORY_SEPARATOR . 'Foo'))->will($this->returnValue(false));
     $command->expects($this->at(1))->method('makeDir')->with($this->equalTo('library' . DIRECTORY_SEPARATOR . 'Acme' . DIRECTORY_SEPARATOR . 'Foo'));
     $command->expects($this->at(2))->method('isFile')->with($this->equalTo('library' . DIRECTORY_SEPARATOR . 'Acme' . DIRECTORY_SEPARATOR . 'Foo' . DIRECTORY_SEPARATOR . 'Bar.php'))->will($this->returnValue(true));
     $command->expects($this->never())->method('writeFile');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('namespace' => 'Acme\\Foo\\Bar', 'services' => 'connection,template'));
 }
开发者ID:seytar,项目名称:psx,代码行数:13,代码来源:ControllerCommandTest.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     $grantTypeFactory = new GrantTypeFactory();
     $grantTypeFactory->add(new TestAuthorizationCode());
     $grantTypeFactory->add(new TestClientCredentials());
     $grantTypeFactory->add(new TestImplicit());
     $grantTypeFactory->add(new TestPassword());
     $grantTypeFactory->add(new TestRefreshToken());
     Environment::getContainer()->set('oauth2_grant_type_factory', $grantTypeFactory);
 }
开发者ID:seytar,项目名称:psx,代码行数:11,代码来源:TokenAbstractTest.php

示例4: testCommand

 public function testCommand()
 {
     $command = Environment::getService('console')->find('container');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array());
     $serviceIds = Environment::getContainer()->getServiceIds();
     $response = $commandTester->getDisplay();
     foreach ($serviceIds as $serviceId) {
         $this->assertTrue(strpos($response, $serviceId) !== false, $serviceId);
     }
 }
开发者ID:seytar,项目名称:psx,代码行数:11,代码来源:ContainerCommandTest.php

示例5: testGet

 public function testGet()
 {
     $container = Environment::getContainer();
     // command
     $this->assertInstanceOf('PSX\\Dispatch\\CommandFactoryInterface', $container->get('command_factory'));
     $this->assertInstanceOf('PSX\\Command\\OutputInterface', $container->get('command_output'));
     $this->assertInstanceOf('PSX\\Command\\Executor', $container->get('executor'));
     // console
     $this->assertInstanceOf('Symfony\\Component\\Console\\Application', $container->get('console'));
     $this->assertInstanceOf('PSX\\Console\\ReaderInterface', $container->get('console_reader'));
     // controller
     $this->assertInstanceOf('PSX\\Dispatch\\ControllerFactoryInterface', $container->get('application_stack_factory'));
     $this->assertInstanceOf('PSX\\Dispatch\\ControllerFactoryInterface', $container->get('controller_factory'));
     $this->assertInstanceOf('PSX\\Dispatch\\SenderInterface', $container->get('dispatch_sender'));
     $this->assertInstanceOf('PSX\\Loader\\LocationFinderInterface', $container->get('loader_location_finder'));
     $this->assertInstanceOf('PSX\\Loader\\CallbackResolverInterface', $container->get('loader_callback_resolver'));
     $this->assertInstanceOf('PSX\\Loader', $container->get('loader'));
     $this->assertInstanceOf('PSX\\Dispatch\\RequestFactoryInterface', $container->get('request_factory'));
     $this->assertInstanceOf('PSX\\Dispatch\\ResponseFactoryInterface', $container->get('response_factory'));
     $this->assertInstanceOf('PSX\\Dispatch', $container->get('dispatch'));
     $this->assertInstanceOf('PSX\\Loader\\RoutingParserInterface', $container->get('routing_parser'));
     $this->assertInstanceOf('PSX\\Loader\\ReverseRouter', $container->get('reverse_router'));
     // data
     $this->assertInstanceOf('PSX\\Data\\ReaderFactory', $container->get('reader_factory'));
     $this->assertInstanceOf('PSX\\Data\\WriterFactory', $container->get('writer_factory'));
     $this->assertInstanceOf('PSX\\Data\\Transformer\\TransformerManager', $container->get('transformer_manager'));
     $this->assertInstanceOf('PSX\\Data\\Record\\ImporterManager', $container->get('importer_manager'));
     $this->assertInstanceOf('PSX\\Data\\Schema\\SchemaManagerInterface', $container->get('schema_manager'));
     $this->assertInstanceOf('PSX\\Data\\Schema\\ValidatorInterface', $container->get('schema_validator'));
     $this->assertInstanceOf('PSX\\Data\\Schema\\Assimilator', $container->get('schema_assimilator'));
     $this->assertInstanceOf('PSX\\Data\\Record\\FactoryFactory', $container->get('record_factory_factory'));
     $this->assertInstanceOf('PSX\\Data\\Importer', $container->get('importer'));
     $this->assertInstanceOf('PSX\\Data\\Extractor', $container->get('extractor'));
     $this->assertInstanceOf('PSX\\Data\\SerializerInterface', $container->get('serializer'));
     // default
     $this->assertInstanceOf('PSX\\Config', $container->get('config'));
     $this->assertInstanceOf('PSX\\Http', $container->get('http'));
     $this->assertInstanceOf('PSX\\Session', $container->get('session'));
     if (Environment::hasConnection()) {
         $this->assertInstanceOf('Doctrine\\DBAL\\Connection', $container->get('connection'));
         $this->assertInstanceOf('PSX\\Sql\\TableManager', $container->get('table_manager'));
     }
     $this->assertInstanceOf('PSX\\TemplateInterface', $container->get('template'));
     $this->assertInstanceOf('PSX\\Validate', $container->get('validate'));
     $this->assertInstanceOf('PSX\\Dependency\\ObjectBuilderInterface', $container->get('object_builder'));
     $this->assertInstanceOf('PSX\\Cache\\CacheItemPoolInterface', $container->get('cache'));
     $this->assertInstanceOf('Psr\\Log\\LoggerInterface', $container->get('logger'));
     // event
     $this->assertInstanceOf('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', $container->get('event_dispatcher'));
 }
开发者ID:seytar,项目名称:psx,代码行数:50,代码来源:DefaultContainerTest.php

示例6: testExecute

 public function testExecute()
 {
     $memory = new Output\Memory();
     $output = new Output\Composite(array($memory, new Output\Logger(Environment::getService('logger'))));
     Environment::getContainer()->set('command_output', $output);
     $response = $this->sendRequest('http://127.0.0.1/command?command=' . urlencode('PSX\\Command\\Foo\\Command\\FooCommand'), 'POST', ['Content-Type' => 'application/json', 'Accept' => 'application/json'], '{"foo": "bar"}');
     $data = Json::decode((string) $response->getBody());
     $messages = $memory->getMessages();
     $this->assertArrayHasKey('output', $data);
     $this->assertEquals(2, count($messages));
     $lines = explode("\n", trim($data['output']));
     foreach ($lines as $key => $line) {
         $this->assertArrayHasKey($key, $messages);
         $this->assertContains(trim($messages[$key]), $line);
     }
 }
开发者ID:seytar,项目名称:psx,代码行数:16,代码来源:CommandControllerTest.php

示例7: testCommandStdin

 public function testCommandStdin()
 {
     $memory = new Output\Memory();
     Environment::getContainer()->set('command_output', $memory);
     $stream = fopen('php://memory', 'r+');
     fwrite($stream, '{"foo": "test"}');
     rewind($stream);
     $command = Environment::getService('console')->find('command');
     $command->setReader(new Reader\Stdin($stream));
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('cmd' => 'PSX\\Command\\Foo\\Command\\FooCommand', '--stdin' => true));
     $messages = $memory->getMessages();
     $this->assertEquals(2, count($messages));
     $this->assertEquals('Some foo informations', rtrim($messages[0]));
     $this->assertEquals('Hello test', rtrim($messages[1]));
 }
开发者ID:seytar,项目名称:psx,代码行数:16,代码来源:CommandCommandTest.php

示例8: tearDown

 protected function tearDown()
 {
     parent::tearDown();
     Environment::getContainer()->set('transformer_manager', null);
 }
开发者ID:seytar,项目名称:psx,代码行数:5,代码来源:RssTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     // use memory sender
     Environment::getContainer()->set('dispatch_sender', new Memory());
 }
开发者ID:seytar,项目名称:psx,代码行数:6,代码来源:ServeCommandTest.php

示例10: clearServices

 /**
  * Removes all used services so that a new instance of a service gets
  * created. This ensures that our test has no side effects. This behaviour
  * is for some services unwanted like i.e. the db connection since we dont
  * want to re-establish a db connection for every test. Such services can be
  * listed in the _protectedServices property
  */
 protected function clearServices()
 {
     // set original config
     Environment::getContainer()->set('config', Environment::getConfig());
     // remove services
     $serviceIds = Environment::getContainer()->getServiceIds();
     foreach ($serviceIds as $serviceId) {
         if (!in_array($serviceId, $this->_protectedServices)) {
             Environment::getContainer()->set($serviceId, null);
         }
     }
 }
开发者ID:seytar,项目名称:psx,代码行数:19,代码来源:ContainerTestCaseTrait.php

示例11: testCommandEmptyService

 public function testCommandEmptyService()
 {
     $command = $this->getMockBuilder('PSX\\Console\\Generate\\ApiCommand')->setConstructorArgs(array(Environment::getContainer()))->setMethods(array('makeDir', 'writeFile'))->getMock();
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('namespace' => 'Acme\\Foo\\Bar'));
 }
开发者ID:seytar,项目名称:psx,代码行数:6,代码来源:ApiCommandTest.php


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