Skip to content

Commit

Permalink
Removed all conditional logic for tests supporting PHP versions less …
Browse files Browse the repository at this point in the history
…than 8.1 (thecodingmachine#630)
  • Loading branch information
oojacoboo authored Oct 20, 2023
1 parent 3c4045a commit c906c66
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 133 deletions.
11 changes: 3 additions & 8 deletions src/SchemaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,9 @@ public function createSchema(): Schema

$errorRootTypeMapper = new FinalRootTypeMapper($recursiveTypeMapper);
$rootTypeMapper = new BaseTypeMapper($errorRootTypeMapper, $recursiveTypeMapper, $topRootTypeMapper);

if (interface_exists(UnitEnum::class)) {
$rootTypeMapper = new EnumTypeMapper($rootTypeMapper, $annotationReader, $symfonyCache, $nsList);
}

if (class_exists(Enum::class)) {
$rootTypeMapper = new MyCLabsEnumTypeMapper($rootTypeMapper, $annotationReader, $symfonyCache, $nsList);
}
$rootTypeMapper = new EnumTypeMapper($rootTypeMapper, $annotationReader, $symfonyCache, $nsList);
// Annotation support - deprecated
$rootTypeMapper = new MyCLabsEnumTypeMapper($rootTypeMapper, $annotationReader, $symfonyCache, $nsList);

if (! empty($this->rootTypeMapperFactories)) {
$rootSchemaFactoryContext = new RootTypeMapperFactoryContext(
Expand Down
15 changes: 7 additions & 8 deletions tests/AbstractQueryProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,21 +356,20 @@ protected function buildRootTypeMapper(): RootTypeMapperInterface
$topRootTypeMapper
);

// Annotation support - deprecated
$rootTypeMapper = new MyCLabsEnumTypeMapper(
$rootTypeMapper,
$this->getAnnotationReader(),
$arrayAdapter,
[]
);

if (interface_exists(UnitEnum::class)) {
$rootTypeMapper = new EnumTypeMapper(
$rootTypeMapper,
$this->getAnnotationReader(),
$arrayAdapter,
[]
);
}
$rootTypeMapper = new EnumTypeMapper(
$rootTypeMapper,
$this->getAnnotationReader(),
$arrayAdapter,
[]
);

$rootTypeMapper = new CompoundTypeMapper(
$rootTypeMapper,
Expand Down
15 changes: 0 additions & 15 deletions tests/AnnotationReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ public function testEmptyGetParameterAnnotations(): void
$this->assertEmpty($annotationReader->getParameterAnnotationsPerParameter([]));
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8AttributeClassAnnotation(): void
{
$annotationReader = new AnnotationReader(new DoctrineAnnotationReader());
Expand All @@ -169,9 +166,6 @@ public function testPhp8AttributeClassAnnotation(): void
//$this->assertSame($type, $type2, 'Assert some cache is available');
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8AttributeClassAnnotations(): void
{
$annotationReader = new AnnotationReader(new DoctrineAnnotationReader());
Expand All @@ -181,9 +175,6 @@ public function testPhp8AttributeClassAnnotations(): void
$this->assertCount(3, $types);
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8AttributeMethodAnnotation(): void
{
$annotationReader = new AnnotationReader(new DoctrineAnnotationReader());
Expand All @@ -192,9 +183,6 @@ public function testPhp8AttributeMethodAnnotation(): void
$this->assertInstanceOf(Field::class, $type);
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8AttributeMethodAnnotations(): void
{
$annotationReader = new AnnotationReader(new DoctrineAnnotationReader());
Expand All @@ -209,9 +197,6 @@ public function testPhp8AttributeMethodAnnotations(): void
$this->assertTrue($securitys[1]->isFailWithSet());
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8AttributeParameterAnnotations(): void
{
$annotationReader = new AnnotationReader(new DoctrineAnnotationReader());
Expand Down
3 changes: 0 additions & 3 deletions tests/Annotations/DecorateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public function testException(): void
new Decorate([]);
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8Annotation(): void
{
$method = new ReflectionMethod(__CLASS__, 'method1');
Expand Down
3 changes: 0 additions & 3 deletions tests/Annotations/FailWithTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public function testException(): void
new FailWith([]);
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8Annotation(): void
{
$method = new ReflectionMethod(__CLASS__, 'method1');
Expand Down
3 changes: 0 additions & 3 deletions tests/Annotations/RightTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public function testException(): void
new Right([]);
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8Annotation(): void
{
$method = new ReflectionMethod(__CLASS__, 'method1');
Expand Down
3 changes: 0 additions & 3 deletions tests/Annotations/UseInputTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public function testException2(): void
(new UseInputType(['inputType' => 'foo']))->getTarget();
}

/**
* @requires PHP >= 8.0
*/
public function testPhp8Annotation(): void
{
$attribute = new UseInputType('foo');
Expand Down
8 changes: 2 additions & 6 deletions tests/FieldsBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
use TheCodingMachine\GraphQLite\Security\VoidAuthenticationService;
use TheCodingMachine\GraphQLite\Security\VoidAuthorizationService;
use TheCodingMachine\GraphQLite\Annotations\Query;
use TheCodingMachine\GraphQLite\Fixtures80\PropertyPromotionInputType;
use TheCodingMachine\GraphQLite\Fixtures80\PropertyPromotionInputTypeWithoutGenericDoc;
use TheCodingMachine\GraphQLite\Fixtures\PropertyPromotionInputType;
use TheCodingMachine\GraphQLite\Fixtures\PropertyPromotionInputTypeWithoutGenericDoc;
use TheCodingMachine\GraphQLite\Types\DateTimeType;
use TheCodingMachine\GraphQLite\Types\VoidType;

Expand Down Expand Up @@ -203,8 +203,6 @@ public function test($typeHintInDocBlock)
/**
* Tests that the fields builder will fail when a parameter is missing it's generic docblock
* definition, when required - an array, for instance, or could be a collection (List types)
*
* @requires PHP >= 8.0
*/
public function testTypeMissingForPropertyPromotionWithoutGenericDoc(): void
{
Expand All @@ -221,8 +219,6 @@ public function testTypeMissingForPropertyPromotionWithoutGenericDoc(): void
/**
* Tests that the fields builder will properly build an input type using property promotion
* with the generic docblock defined on the constructor and not the property directly.
*
* @requires PHP >= 8.0
*/
public function testTypeInDocBlockWithPropertyPromotion(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures81\Integration\Controllers;
namespace TheCodingMachine\GraphQLite\Fixtures\Integration\Controllers;

use TheCodingMachine\GraphQLite\Annotations\Mutation;
use TheCodingMachine\GraphQLite\Annotations\Query;
use TheCodingMachine\GraphQLite\Fixtures81\Integration\Models\Button;
use TheCodingMachine\GraphQLite\Fixtures81\Integration\Models\Color;
use TheCodingMachine\GraphQLite\Fixtures81\Integration\Models\Position;
use TheCodingMachine\GraphQLite\Fixtures81\Integration\Models\Size;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\Button;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\Color;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\Position;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\Size;
use TheCodingMachine\GraphQLite\Types\ID;

final class ButtonController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures81\Integration\Models;
namespace TheCodingMachine\GraphQLite\Fixtures\Integration\Models;

use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures81\Integration\Models;
namespace TheCodingMachine\GraphQLite\Fixtures\Integration\Models;

use TheCodingMachine\GraphQLite\Annotations\Type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures81\Integration\Models;
namespace TheCodingMachine\GraphQLite\Fixtures\Integration\Models;

use TheCodingMachine\GraphQLite\Annotations\Type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures81\Integration\Models;
namespace TheCodingMachine\GraphQLite\Fixtures\Integration\Models;

use TheCodingMachine\GraphQLite\Annotations\Type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures80;
namespace TheCodingMachine\GraphQLite\Fixtures;

use TheCodingMachine\GraphQLite\Annotations as GraphQLite;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures80;
namespace TheCodingMachine\GraphQLite\Fixtures;

use TheCodingMachine\GraphQLite\Annotations as GraphQLite;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite\Fixtures80;
namespace TheCodingMachine\GraphQLite\Fixtures;

use TheCodingMachine\GraphQLite\Fixtures\TestObject;
use TheCodingMachine\GraphQLite\Fixtures\TestObject2;
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/EndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
use TheCodingMachine\GraphQLite\FieldsBuilder;
use TheCodingMachine\GraphQLite\Fixtures\Inputs\ValidationException;
use TheCodingMachine\GraphQLite\Fixtures\Inputs\Validator;
use TheCodingMachine\GraphQLite\Fixtures81\Integration\Models\Color;
use TheCodingMachine\GraphQLite\Fixtures81\Integration\Models\Position;
use TheCodingMachine\GraphQLite\Fixtures81\Integration\Models\Size;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\Color;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\Position;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\Size;
use TheCodingMachine\GraphQLite\GlobControllerQueryProvider;
use TheCodingMachine\GraphQLite\GraphQLRuntimeException;
use TheCodingMachine\GraphQLite\InputTypeGenerator;
Expand Down
Loading

0 comments on commit c906c66

Please sign in to comment.