Skip to content

Commit 66840de

Browse files
committed
Adding test to showcase poor error message
1 parent 4ce7e9d commit 66840de

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
4+
namespace TheCodingMachine\GraphQLite\Fixtures\InputOutputNameConflict\Controllers;
5+
6+
7+
use TheCodingMachine\GraphQLite\Annotations\Query;
8+
use TheCodingMachine\GraphQLite\Annotations\UseInputType;
9+
use TheCodingMachine\GraphQLite\Fixtures\InputOutputNameConflict\Types\InAndOut;
10+
11+
class InAndOutController
12+
{
13+
/**
14+
* @Query()
15+
* @UseInputType(for="$inAndOut", inputType="InAndOut")
16+
*/
17+
public function testInAndOut(InAndOut $inAndOut): InAndOut
18+
{
19+
return $inAndOut;
20+
}
21+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
4+
namespace TheCodingMachine\GraphQLite\Fixtures\InputOutputNameConflict\Types;
5+
6+
use TheCodingMachine\GraphQLite\Annotations\Factory;
7+
use TheCodingMachine\GraphQLite\Annotations\Field;
8+
use TheCodingMachine\GraphQLite\Annotations\Type;
9+
10+
/**
11+
* @Type(name="InAndOut")
12+
*/
13+
class InAndOut
14+
{
15+
/**
16+
* @var string
17+
*/
18+
private $value;
19+
20+
public function __construct(string $value)
21+
{
22+
$this->value = $value;
23+
}
24+
25+
/**
26+
* @Field()
27+
*/
28+
public function getValue(): string
29+
{
30+
return $this->value;
31+
}
32+
33+
/**
34+
* @Factory(name="InAndOut")
35+
*/
36+
public static function create(string $value): self
37+
{
38+
return new self($value);
39+
}
40+
}

tests/Integration/EndToEndTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
use TheCodingMachine\GraphQLite\Containers\EmptyContainer;
5353
use TheCodingMachine\GraphQLite\Reflection\CachedDocBlockFactory;
5454
use TheCodingMachine\GraphQLite\Schema;
55+
use TheCodingMachine\GraphQLite\SchemaFactory;
5556
use TheCodingMachine\GraphQLite\Security\AuthenticationServiceInterface;
5657
use TheCodingMachine\GraphQLite\Security\AuthorizationServiceInterface;
5758
use TheCodingMachine\GraphQLite\Security\SecurityExpressionLanguageProvider;
@@ -451,7 +452,7 @@ public function testEndToEndInputType()
451452
{
452453
name: "bar"
453454
}
454-
]
455+
]
455456
}
456457
) {
457458
name,
@@ -1364,4 +1365,14 @@ public function getUser(): ?object
13641365

13651366
$this->assertSame(42, $result->toArray(Debug::RETHROW_UNSAFE_EXCEPTIONS)['data']['injectedUser']);
13661367
}
1368+
1369+
public function testInputOutputNameConflict(): void
1370+
{
1371+
$schemaFactory = new SchemaFactory(new Psr16Cache(new ArrayAdapter()), new BasicAutoWiringContainer(new EmptyContainer()));
1372+
$schemaFactory->addControllerNamespace('TheCodingMachine\\GraphQLite\\Fixtures\\InputOutputNameConflict\\Controllers');
1373+
$schemaFactory->addTypeNamespace('TheCodingMachine\\GraphQLite\\Fixtures\\InputOutputNameConflict\\Types');
1374+
1375+
$schema = $schemaFactory->createSchema();
1376+
$schema->validate();
1377+
}
13671378
}

0 commit comments

Comments
 (0)