Skip to content

Commit 508e777

Browse files
authored
Fix travis build for Symfony 5 (overblog#622)
* Fix validation message condition * Remove deprecation messages * Require phpstan ^0.11.19 * Use phpstan/phpstan-shim * Use default allowEmptyString value * Remove allowEmptyString * add legacy group * Allow travis build 7.4snapshot * Remove useless phpstan ignoreErrors * Fix $kernel var is not nullable error
1 parent e5019f6 commit 508e777

File tree

7 files changed

+46
-35
lines changed

7 files changed

+46
-35
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ cache:
2020
before_install:
2121
- if [ "${STABILITY}" != "" ]; then perl -pi -e 's/^}$/,"minimum-stability":"'"${STABILITY}"'"}/' composer.json; fi;
2222
- if [ "${SYMFONY_VERSION}" != "" ]; then perl -pi -e 's#"(symfony/.*)":\s*".*"#"$1":"'"${SYMFONY_VERSION}"'"#' composer.json; fi;
23-
- if [ "${SYMFONY_VERSION}" = "5.0.*" ]; then composer req "symfony/translation" --no-update; fi;
2423
- if [ "${PHPUNIT_VERSION}" != "" ]; then composer req "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update; fi;
2524
- if [ "${VALIDATOR}" = "0" ]; then composer remove "symfony/validator" --dev --no-update; fi;
2625
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
@@ -77,3 +76,5 @@ jobs:
7776

7877
allow_failures:
7978
- php: nightly
79+
- php: 7.4snapshot
80+
env: SYMFONY_VERSION=4.3.*

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"require-dev": {
5252
"doctrine/orm": "^2.5",
5353
"phpstan/extension-installer": "^1.0",
54-
"phpstan/phpstan": "^0.11",
54+
"phpstan/phpstan-shim": "^0.11.19",
5555
"phpstan/phpstan-phpunit": "^0.11",
5656
"phpstan/phpstan-symfony": "^0.11",
5757
"phpunit/phpunit": "<8.3",

phpstan-baseline.neon

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,11 @@ parameters:
9090
count: 1
9191
path: lib/generator/tests/StarWarsIntrospectionTest.php
9292

93-
-
94-
message: "#^Return type \\(void\\) of method Overblog\\\\GraphQLBundle\\\\Command\\\\CompileCommand\\:\\:execute\\(\\) should be compatible with return type \\(int\\|null\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#"
95-
count: 1
96-
path: src/Command/CompileCommand.php
97-
98-
-
99-
message: "#^Return type \\(void\\) of method Overblog\\\\GraphQLBundle\\\\Command\\\\DebugCommand\\:\\:execute\\(\\) should be compatible with return type \\(int\\|null\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#"
100-
count: 1
101-
path: src/Command/DebugCommand.php
102-
10393
-
10494
message: "#^Parameter \\#1 \\$id of method Overblog\\\\GraphQLBundle\\\\Resolver\\\\FluentResolverInterface\\:\\:getSolutionAliases\\(\\) expects string, int\\|string given\\.$#"
10595
count: 1
10696
path: src/Command/DebugCommand.php
10797

108-
-
109-
message: "#^Return type \\(void\\) of method Overblog\\\\GraphQLBundle\\\\Command\\\\GraphQLDumpSchemaCommand\\:\\:execute\\(\\) should be compatible with return type \\(int\\|null\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#"
110-
count: 1
111-
path: src/Command/GraphQLDumpSchemaCommand.php
112-
11398
-
11499
message: "#^Parameter \\#1 \\$str of function strtolower expects string, array\\<string\\>\\|bool\\|string\\|null given\\.$#"
115100
count: 1
@@ -140,11 +125,6 @@ parameters:
140125
count: 1
141126
path: src/Command/GraphQLDumpSchemaCommand.php
142127

143-
-
144-
message: "#^Return type \\(void\\) of method Overblog\\\\GraphQLBundle\\\\Command\\\\ValidateCommand\\:\\:execute\\(\\) should be compatible with return type \\(int\\|null\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#"
145-
count: 1
146-
path: src/Command/ValidateCommand.php
147-
148128
-
149129
message: "#^Parameter \\#1 \\$name of method Overblog\\\\GraphQLBundle\\\\Request\\\\Executor\\:\\:getSchema\\(\\) expects string\\|null, array\\<string\\>\\|bool\\|string\\|null given\\.$#"
150130
count: 1
@@ -1055,11 +1035,6 @@ parameters:
10551035
count: 1
10561036
path: tests/Functional/Inheritance/InheritanceTest.php
10571037

1058-
-
1059-
message: "#^Static property Symfony\\\\Bundle\\\\FrameworkBundle\\\\Test\\\\KernelTestCase\\:\\:\\$kernel \\(Symfony\\\\Component\\\\HttpKernel\\\\KernelInterface\\) does not accept null\\.$#"
1060-
count: 1
1061-
path: tests/Functional/TestCase.php
1062-
10631038
-
10641039
message: "#^Parameter \\#3 \\$message of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) expects string, string\\|false given\\.$#"
10651040
count: 1

src/Validator/Constraints/ExpressionValidator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Overblog\GraphQLBundle\Validator\ValidationNode;
88
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
9+
use Symfony\Component\HttpKernel\Kernel;
910
use Symfony\Component\Validator\Constraint;
1011
use Symfony\Component\Validator\Constraints\Expression;
1112
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
@@ -17,7 +18,11 @@ class ExpressionValidator extends \Symfony\Component\Validator\Constraints\Expre
1718
public function __construct(ExpressionLanguage $expressionLanguage)
1819
{
1920
$this->expressionLanguage = $expressionLanguage;
20-
parent::__construct(null, $expressionLanguage);
21+
if (Kernel::VERSION_ID >= 40400) {
22+
parent::__construct($expressionLanguage);
23+
} else {
24+
parent::__construct(null, $expressionLanguage);
25+
}
2126
}
2227

2328
/**

tests/Functional/TestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public static function setUpBeforeClass(): void
5959
protected function tearDown(): void
6060
{
6161
static::ensureKernelShutdown();
62-
static::$kernel = null;
6362
}
6463

6564
protected static function executeGraphQLRequest(string $query, $rootValue = [], string $schemaName = null)
@@ -106,7 +105,6 @@ protected static function query($query, $username, $testCase, $password = self::
106105
protected static function createClientAuthenticated($username, $testCase, $password = self::DEFAULT_PASSWORD)
107106
{
108107
static::ensureKernelShutdown();
109-
static::$kernel = null;
110108
$client = static::createClient(['test_case' => $testCase]);
111109

112110
if ($username) {

tests/Functional/Validator/ExpectedErrors.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,17 @@ public static function cascadeWithGroups($fieldName)
137137
],
138138
'birthdate.day' => [
139139
[
140-
'message' => 'This value should be between 1 and 31.',
141-
'code' => '04b91c99-a946-4221-afc5-e65ebac401eb',
140+
'message' => 'This value should be 31 or less.',
141+
'code' => '2d28afcb-e32e-45fb-a815-01c431a86a69',
142142
],
143143
],
144144
];
145145

146-
if (Kernel::VERSION_ID >= 50000) {
146+
if (Kernel::VERSION_ID >= 40400) {
147147
$validation['birthdate.day'] = [
148148
[
149-
'message' => 'This value should be 31 or less.',
150-
'code' => '2d28afcb-e32e-45fb-a815-01c431a86a69',
149+
'message' => 'This value should be between 1 and 31.',
150+
'code' => '04b91c99-a946-4221-afc5-e65ebac401eb',
151151
],
152152
];
153153
}

tests/Functional/Validator/InputValidatorTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public function testNoValidation(): void
2727
$this->assertTrue($result['data']['noValidation']);
2828
}
2929

30+
/**
31+
* @group legacy
32+
*/
3033
public function testSimpleValidationPasses(): void
3134
{
3235
$query = '
@@ -41,6 +44,9 @@ public function testSimpleValidationPasses(): void
4144
$this->assertTrue($result['data']['simpleValidation']);
4245
}
4346

47+
/**
48+
* @group legacy
49+
*/
4450
public function testSimpleValidationFails(): void
4551
{
4652
$query = '
@@ -91,6 +97,9 @@ public function testLinkedConstraintsValidationFails(): void
9197
$this->assertNull($result['data']['linkedConstraintsValidation']);
9298
}
9399

100+
/**
101+
* @group legacy
102+
*/
94103
public function testCollectionValidationPasses(): void
95104
{
96105
$query = '
@@ -116,6 +125,9 @@ public function testCollectionValidationPasses(): void
116125
$this->assertTrue($result['data']['collectionValidation']);
117126
}
118127

128+
/**
129+
* @group legacy
130+
*/
119131
public function testCollectionValidationFails(): void
120132
{
121133
$query = '
@@ -141,6 +153,9 @@ public function testCollectionValidationFails(): void
141153
$this->assertNull($result['data']['collectionValidation']);
142154
}
143155

156+
/**
157+
* @group legacy
158+
*/
144159
public function testCascadeValidationWithGroupsPasses(): void
145160
{
146161
$query = '
@@ -171,6 +186,9 @@ public function testCascadeValidationWithGroupsPasses(): void
171186
$this->assertTrue($result['data']['cascadeValidationWithGroups']);
172187
}
173188

189+
/**
190+
* @group legacy
191+
*/
174192
public function testCascadeValidationWithGroupsFails(): void
175193
{
176194
$query = '
@@ -227,6 +245,9 @@ public function testExpressionVariablesAccessible(): void
227245
$this->assertTrue($result['data']['expressionVariablesValidation']);
228246
}
229247

248+
/**
249+
* @group legacy
250+
*/
230251
public function testAutoValidationAutoThrowPasses(): void
231252
{
232253
$query = '
@@ -241,6 +262,9 @@ public function testAutoValidationAutoThrowPasses(): void
241262
$this->assertTrue($result['data']['autoValidationAutoThrow']);
242263
}
243264

265+
/**
266+
* @group legacy
267+
*/
244268
public function testAutoValidationAutoThrowFails(): void
245269
{
246270
$query = '
@@ -256,6 +280,7 @@ public function testAutoValidationAutoThrowFails(): void
256280
}
257281

258282
/**
283+
* @group legacy
259284
* Checks if the injected variable `errors` contains 0 violations.
260285
*/
261286
public function testAutoValidationNoThrowNoErrors(): void
@@ -268,6 +293,7 @@ public function testAutoValidationNoThrowNoErrors(): void
268293
}
269294

270295
/**
296+
* @group legacy
271297
* Checks if the injected variable `errors` contains exactly 1 violation.
272298
*/
273299
public function testAutoValidationNoThrowHasErrors(): void
@@ -279,6 +305,9 @@ public function testAutoValidationNoThrowHasErrors(): void
279305
$this->assertTrue(true === $result['data']['autoValidationNoThrow']);
280306
}
281307

308+
/**
309+
* @group legacy
310+
*/
282311
public function testAutoValidationAutoThrowWithGroupsPasses(): void
283312
{
284313
$query = '
@@ -308,6 +337,9 @@ public function testAutoValidationAutoThrowWithGroupsPasses(): void
308337
$this->assertTrue($result['data']['autoValidationAutoThrowWithGroups']);
309338
}
310339

340+
/**
341+
* @group legacy
342+
*/
311343
public function testAutoValidationAutoThrowWithGroupsFails(): void
312344
{
313345
$query = '

0 commit comments

Comments
 (0)