Skip to content

Commit a550db8

Browse files
committed
refactor test to work on < php8
1 parent c9afcd7 commit a550db8

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TheCodingMachine\GraphQLite\Fixtures80;
6+
7+
use TheCodingMachine\GraphQLite\Fixtures\TestObject;
8+
use TheCodingMachine\GraphQLite\Fixtures\TestObject2;
9+
10+
class UnionOutputType
11+
{
12+
public function objectUnion(): TestObject|TestObject2 {
13+
return new TestObject((''));
14+
}
15+
}

tests/Mappers/Parameters/TypeMapperTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
use Symfony\Component\Cache\Simple\ArrayCache;
1313
use TheCodingMachine\GraphQLite\AbstractQueryProviderTest;
1414
use TheCodingMachine\GraphQLite\Annotations\HideParameter;
15-
use TheCodingMachine\GraphQLite\Fixtures\TestObject;
16-
use TheCodingMachine\GraphQLite\Fixtures\TestObject2;
15+
use TheCodingMachine\GraphQLite\Fixtures80\UnionOutputType;
1716
use TheCodingMachine\GraphQLite\Mappers\CannotMapTypeException;
1817
use TheCodingMachine\GraphQLite\Mappers\Root\BaseTypeMapper;
1918
use TheCodingMachine\GraphQLite\Mappers\Root\CompositeRootTypeMapper;
@@ -38,13 +37,16 @@ public function testMapScalarUnionException(): void
3837
$typeMapper->mapReturnType($refMethod, $docBlockObj);
3938
}
4039

40+
/**
41+
* @requires PHP >= 8.0
42+
*/
4143
public function testMapObjectUnionWorks(): void
4244
{
4345
$typeMapper = new TypeHandler($this->getArgumentResolver(), $this->getRootTypeMapper(), $this->getTypeResolver());
4446

4547
$cachedDocBlockFactory = new CachedDocBlockFactory(new Psr16Cache(new ArrayAdapter()));
4648

47-
$refMethod = new ReflectionMethod($this, 'objectUnion');
49+
$refMethod = new ReflectionMethod(UnionOutputType::class, 'objectUnion');
4850
$docBlockObj = $cachedDocBlockFactory->getDocBlock($refMethod);
4951

5052
$gqType = $typeMapper->mapReturnType($refMethod, $docBlockObj);
@@ -101,10 +103,6 @@ private function dummy() {
101103

102104
}
103105

104-
private function objectUnion(): TestObject|TestObject2 {
105-
return new TestObject((''));
106-
}
107-
108106
/**
109107
* @HideParameter(for="$foo")
110108
*/

0 commit comments

Comments
 (0)