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


PHP Test\Environment类代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     if (!class_exists('MongoDB')) {
         $this->markTestSkipped('MongoDB extension not available');
     }
     if (!self::$hasConnection) {
         $this->markTestSkipped('MongoDB connection not available');
     }
     parent::setUp();
     try {
         $this->mongodb = Environment::getService('connector')->getConnection(3);
     } catch (MongoConnectionException $e) {
         self::$hasConnection = false;
         $this->markTestSkipped('MongoDB connection not available');
     }
     $this->collection = $this->mongodb->createCollection('app_news');
     $table = $this->getDataSet()->getTable('app_news');
     $columns = $table->getTableMetaData()->getColumns();
     for ($i = 0; $i < $table->getRowCount(); $i++) {
         $row = array();
         foreach ($columns as $name) {
             $row[$name] = $table->getValue($i, $name);
         }
         $this->collection->insert($row);
     }
 }
开发者ID:uqiauto,项目名称:fusio,代码行数:26,代码来源:MongoTestCase.php

示例2: testRequest

    public function testRequest()
    {
        $testCase = $this;
        $http = new Http(new Callback(function (RequestInterface $request) use($testCase) {
            // api request
            if ($request->getUri()->getPath() == '/api') {
                $testCase->assertEquals('Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW', (string) $request->getHeader('Authorization'));
                $testCase->assertEquals('application/x-www-form-urlencoded', (string) $request->getHeader('Content-Type'));
                $testCase->assertEquals('grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA', (string) $request->getBody());
                $response = <<<TEXT
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache

{
  "access_token":"2YotnFZFEjr1zCsicMWpAA",
  "token_type":"example",
  "expires_in":3600,
  "example_parameter":"example_value"
}
TEXT;
            } else {
                throw new \RuntimeException('Invalid path');
            }
            return ResponseParser::convert($response, ResponseParser::MODE_LOOSE)->toString();
        }));
        $oauth = new AuthorizationCode($http, new Url('http://127.0.0.1/api'), Environment::getService('importer'));
        $oauth->setClientPassword(self::CLIENT_ID, self::CLIENT_SECRET);
        $accessToken = $oauth->getAccessToken('SplxlOBeZQQYbYS6WxSbIA');
        $this->assertEquals('2YotnFZFEjr1zCsicMWpAA', $accessToken->getAccessToken());
        $this->assertEquals('example', $accessToken->getTokenType());
        $this->assertEquals(3600, $accessToken->getExpiresIn());
    }
开发者ID:seytar,项目名称:psx,代码行数:34,代码来源:AuthorizationCodeTest.php

示例3: getAuthorizationCode

    protected function getAuthorizationCode($code, $state)
    {
        $testCase = $this->testCase;
        $http = new Http(new Callback(function (RequestInterface $request) use($testCase) {
            // api request
            if ($request->getUri()->getPath() == '/api') {
                $testCase->assertEquals('Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW', (string) $request->getHeader('Authorization'));
                $testCase->assertEquals('application/x-www-form-urlencoded', (string) $request->getHeader('Content-Type'));
                $response = <<<TEXT
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache

{
  "access_token":"2YotnFZFEjr1zCsicMWpAA",
  "token_type":"example",
  "expires_in":3600,
  "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
  "example_parameter":"example_value"
}
TEXT;
            } else {
                throw new \RuntimeException('Invalid path');
            }
            return ResponseParser::convert($response, ResponseParser::MODE_LOOSE)->toString();
        }));
        $oauth = new AuthorizationCode($http, new Url('http://127.0.0.1/api'), Environment::getService('importer'));
        $oauth->setClientPassword(ClientCredentialsTest::CLIENT_ID, ClientCredentialsTest::CLIENT_SECRET);
        return $oauth;
    }
开发者ID:seytar,项目名称:psx,代码行数:31,代码来源:TestCallbackAbstract.php

示例4: getEntityManager

 protected function getEntityManager()
 {
     if (self::$em === null) {
         self::$em = Environment::getService('entity_manager');
     }
     return self::$em;
 }
开发者ID:seytar,项目名称:psx,代码行数:7,代码来源:DoctrineTestCase.php

示例5: 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

示例6: doGet

 protected function doGet(Version $version)
 {
     $this->testCase->assertEquals(12, $this->queryParameters->getProperty('startIndex'));
     $this->testCase->assertEmpty($this->queryParameters->getProperty('bar'));
     $this->testCase->assertEquals(8, $this->pathParameters->getProperty('fooId'));
     $this->testCase->assertEmpty($this->pathParameters->getProperty('bar'));
     return array('entry' => Environment::getService('table_manager')->getTable('PSX\\Sql\\TestTable')->getAll());
 }
开发者ID:seytar,项目名称:psx,代码行数:8,代码来源:EntityController.php

示例7: setUp

 protected function setUp()
 {
     parent::setUp();
     if (!Environment::hasConnection()) {
         $this->markTestSkipped('Database connection not available');
     }
     $this->connection = Environment::getService('connection');
 }
开发者ID:seytar,项目名称:psx,代码行数:8,代码来源:SqlTest.php

示例8: testGetForm

 public function testGetForm()
 {
     $action = new Pipe();
     $builder = new Builder();
     $factory = Environment::getService('form_element_factory');
     $action->configure($builder, $factory);
     $this->assertInstanceOf('Fusio\\Impl\\Form\\Container', $builder->getForm());
 }
开发者ID:uqiauto,项目名称:fusio,代码行数:8,代码来源:PipeTest.php

示例9: testFilter

 public function testFilter()
 {
     $table = Environment::getService('table_manager')->getTable('PSX\\Sql\\TestTable');
     $filter = new PrimaryKey($table);
     $this->assertEquals(true, $filter->apply(1));
     $this->assertEquals(false, $filter->apply(32));
     // test error message
     $this->assertEquals('%s does not exist in table', $filter->getErrorMessage());
 }
开发者ID:seytar,项目名称:psx,代码行数:9,代码来源:PrimaryKeyTest.php

示例10: getResource

 protected function getResource()
 {
     $request = $this->getMock('PSX\\Http\\RequestInterface');
     $response = $this->getMock('PSX\\Http\\ResponseInterface');
     $context = new Context();
     $context->set(Context::KEY_PATH, '/foo/bar');
     $documentation = Environment::getService('controller_factory')->getController('PSX\\Controller\\Foo\\Application\\SchemaApi\\VersionViewController', $request, $response, $context)->getDocumentation();
     return $documentation->getResource($documentation->getLatestVersion());
 }
开发者ID:seytar,项目名称:psx,代码行数:9,代码来源:GeneratorTestCase.php

示例11: testClassNotExist

 /**
  * @expectedException \ReflectionException
  */
 public function testClassNotExist()
 {
     $context = new Context();
     $context->set(Context::KEY_SOURCE, 'Foo::bar');
     $request = new Request(new Url('http://127.0.0.1'), 'GET');
     $response = new Response();
     $simple = new DependencyInjector(Environment::getService('controller_factory'));
     $simple->resolve($request, $response, $context);
 }
开发者ID:seytar,项目名称:psx,代码行数:12,代码来源:DependencyInjectorTest.php

示例12: 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

示例13: 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

示例14: testTransform

 public function testTransform()
 {
     $template = new Twig(Environment::getService('config'));
     $template->setDir('tests/PSX/Template/twig');
     $template->set('foo.twig.html');
     $this->assertTrue($template->hasFile());
     $this->assertTrue($template->isFileAvailable());
     $this->assertFalse($template->isAbsoluteFile());
     $this->assertEquals('foo.twig.html', $template->get());
     $template->assign('foo', 'bar');
     $content = $template->transform();
     $this->assertEquals('Hello bar', $content);
 }
开发者ID:seytar,项目名称:psx,代码行数:13,代码来源:TwigTest.php

示例15: getConnection

 public function getConnection()
 {
     if (!Environment::hasConnection()) {
         $this->markTestSkipped('No database connection available');
     }
     if (self::$con === null) {
         self::$con = Environment::getService('connection');
     }
     if ($this->connection === null) {
         $this->connection = self::$con;
     }
     return $this->createDefaultDBConnection($this->connection->getWrappedConnection(), Environment::getService('config')->get('psx_sql_db'));
 }
开发者ID:uqiauto,项目名称:fusio,代码行数:13,代码来源:DbTestCase.php


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