-
Notifications
You must be signed in to change notification settings - Fork 37
/
NoSecurityBundleTest.php
52 lines (44 loc) · 1.86 KB
/
NoSecurityBundleTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace TheCodingMachine\Graphqlite\Bundle\Tests;
use function json_decode;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use function spl_object_hash;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\User\User;
use TheCodingMachine\Graphqlite\Bundle\Controller\GraphqliteController;
use TheCodingMachine\Graphqlite\Bundle\Security\AuthenticationService;
use TheCodingMachine\GraphQLite\GraphQLRuntimeException as GraphQLException;
use TheCodingMachine\GraphQLite\Schema;
use function var_dump;
/**
* This test class is supposed to work even if the security bundle is not installed in the project.
* It is here to check we don't have hidden dependencies on this bundle and that it remains optional.
*/
class NoSecurityBundleTest extends TestCase
{
public function testServiceWiring(): void
{
$kernel = new GraphqliteTestingKernel(true, null, false, null, true, null, null, ['TheCodingMachine\\Graphqlite\\Bundle\\Tests\\NoSecurityBundleFixtures\\Controller\\']);
$kernel->boot();
$container = $kernel->getContainer();
$schema = $container->get(Schema::class);
$this->assertInstanceOf(Schema::class, $schema);
$schema->assertValid();
$request = Request::create('/graphql', 'GET', ['query' => '
{
echoMsg(message: "Hello world")
}']);
$response = $kernel->handle($request);
$result = json_decode($response->getContent(), true);
$this->assertSame([
'data' => [
'echoMsg' => 'Hello world'
]
], $result);
}
}