-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Tests/NoSecurityBundleFixtures/Controller/EchoController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
|
||
namespace TheCodingMachine\Graphqlite\Bundle\Tests\NoSecurityBundleFixtures\Controller; | ||
|
||
|
||
use TheCodingMachine\GraphQLite\Annotations\Query; | ||
|
||
class EchoController | ||
{ | ||
/** | ||
* @Query() | ||
*/ | ||
public function echoMsg(string $message): string { | ||
return $message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} | ||
} |