vendor/bshaffer/oauth2-server-bundle/OAuth2/ServerBundle/Tests/Command/CreateClientCommandTest.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace OAuth2\ServerBundle\Tests\Command;
use OAuth2\ServerBundle\Tests\ContainerLoader;
use OAuth2\ServerBundle\Command\CreateClientCommand;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\BufferedOutput;
class CreateClientCommandTest extends \PHPUnit_Framework_TestCase
{
public function testCreateClientWithInvalidScope()
{
$container = ContainerLoader::buildTestContainer();
$command = new CreateClientCommand();
$command->setContainer($container);
$client_id = 'Client-ID-'.rand();
$redirectUris = 'http://brentertainment.com';
$grantTypes = 'authorization_code,client_credentials';
$scopes = 'fakescope';
$input = new ArgvInput(array('command', $client_id, $redirectUris, $grantTypes, $scopes));
$output = new BufferedOutput();
$statusCode = $command->run($input, $output);
$this->assertEquals(1, $statusCode);
$this->assertTrue(false !== strpos($output->fetch(), 'Scope not found, please create it first'));
}
public function testCreateClient()
{
$container = ContainerLoader::buildTestContainer();
$command = new CreateClientCommand();
$command->setContainer($container);
$client_id = 'Client-ID-'.rand();
$redirectUris = 'http://brentertainment.com';
$grantTypes = 'authorization_code,client_credentials';
$scope = 'scope1';
// ensure the scope exists
$scopeStorage = $container->get('oauth2.storage.scope');
if (!$scopeStorage->scopeExists($scope)) {
$scopeManager = $container->get('oauth2.scope_manager');
$scopeManager->createScope($scope, 'test scope');
}
$input = new ArgvInput(array('command', $client_id, $redirectUris, $grantTypes, $scope));
$output = new BufferedOutput();
$statusCode = $command->run($input, $output);
$this->assertEquals(0, $statusCode, $output->fetch());
// verify client details have been stored
$storage = $container->get('oauth2.storage.client_credentials');
$client = $storage->getClientDetails($client_id);
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。