Skip to content

Commit 83d3728

Browse files
authored
Use addToAssertionCount(1) instead of assertTrue(true)
1 parent 7e3ef03 commit 83d3728

File tree

7 files changed

+24
-25
lines changed

7 files changed

+24
-25
lines changed

tests/Executor/Promise/SyncPromiseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,6 @@ public function testPendingPromiseThen(): void
415415
public function testRunEmptyQueue(): void
416416
{
417417
SyncPromise::runQueue();
418-
self::assertDidNotCrash();
418+
$this->assertDidNotCrash();
419419
}
420420
}

tests/Language/ParserTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testParseProvidesUsefulErrorWhenUsingSource(): void
113113
public function testParsesVariableInlineValues(): void
114114
{
115115
Parser::parse('{ field(complex: { a: { b: [ $var ] } }) }');
116-
self::assertDidNotCrash();
116+
$this->assertDidNotCrash();
117117
}
118118

119119
/** @see it('parses constant default values') */
@@ -130,7 +130,7 @@ public function testParsesConstantDefaultValues(): void
130130
public function testParsesVariableDefinitionDirectives(): void
131131
{
132132
Parser::parse('query Foo($x: Boolean = false @bar) { field }');
133-
self::assertDidNotCrash();
133+
$this->assertDidNotCrash();
134134
}
135135

136136
/**
@@ -264,7 +264,7 @@ public function testParsessAnonymousMutationOperations(): void
264264
mutationField
265265
}
266266
');
267-
self::assertDidNotCrash();
267+
$this->assertDidNotCrash();
268268
}
269269

270270
/** @see it('parses anonymous subscription operations') */
@@ -275,7 +275,7 @@ public function testParsesAnonymousSubscriptionOperations(): void
275275
subscriptionField
276276
}
277277
');
278-
self::assertDidNotCrash();
278+
$this->assertDidNotCrash();
279279
}
280280

281281
/** @see it('parses named mutation operations') */
@@ -286,7 +286,7 @@ public function testParsesNamedMutationOperations(): void
286286
mutationField
287287
}
288288
');
289-
self::assertDidNotCrash();
289+
$this->assertDidNotCrash();
290290
}
291291

292292
/** @see it('parses named subscription operations') */
@@ -297,7 +297,7 @@ public function testParsesNamedSubscriptionOperations(): void
297297
subscriptionField
298298
}
299299
');
300-
self::assertDidNotCrash();
300+
$this->assertDidNotCrash();
301301
}
302302

303303
/** @see it('creates ast') */

tests/TestCaseBase.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ abstract class TestCaseBase extends TestCase
1515
*
1616
* @see TestCase::expectNotToPerformAssertions()
1717
*/
18-
public static function assertDidNotCrash(): void
18+
public function assertDidNotCrash(): void
1919
{
20-
// @phpstan-ignore-next-line this truism is required to prevent a PHPUnit warning
21-
self::assertTrue(true);
20+
$this->addToAssertionCount(1);
2221
}
2322

2423
protected static function assertASTMatches(string $expected, ?Node $node): void

tests/Type/DefinitionTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ public function testRejectsAnObjectTypeWithInterfacesAsAFunctionReturningAnIncor
994994
public function testAcceptsALambdaAsAnObjectFieldResolver(): void
995995
{
996996
$this->schemaWithObjectWithFieldResolver(static fn () => null);
997-
self::assertDidNotCrash();
997+
$this->assertDidNotCrash();
998998
}
999999

10001000
/**
@@ -1065,7 +1065,7 @@ public function testAcceptsAnInterfaceTypeDefiningResolveType(): void
10651065
'fields' => ['f' => ['type' => Type::string()]],
10661066
])
10671067
);
1068-
self::assertDidNotCrash();
1068+
$this->assertDidNotCrash();
10691069
}
10701070

10711071
/** @see it('accepts an Interface type with an array of interfaces') */
@@ -1159,7 +1159,7 @@ public function testAcceptsAnInterfaceWithImplementingTypeDefiningIsTypeOf(): vo
11591159
'fields' => ['f' => ['type' => Type::string()]],
11601160
])
11611161
);
1162-
self::assertDidNotCrash();
1162+
$this->assertDidNotCrash();
11631163
}
11641164

11651165
/** @see it('accepts an Interface type defining resolveType with implementing type defining isTypeOf') */
@@ -1177,7 +1177,7 @@ public function testAcceptsAnInterfaceTypeDefiningResolveTypeWithImplementingTyp
11771177
'fields' => ['f' => ['type' => Type::string()]],
11781178
])
11791179
);
1180-
self::assertDidNotCrash();
1180+
$this->assertDidNotCrash();
11811181
}
11821182

11831183
/** @see it('rejects an Interface type with an incorrect type for resolveType') */
@@ -1206,7 +1206,7 @@ public function testAcceptsAUnionTypeDefiningResolveType(): void
12061206
'types' => [$this->objectType],
12071207
])
12081208
);
1209-
self::assertDidNotCrash();
1209+
$this->assertDidNotCrash();
12101210
}
12111211

12121212
/** @see it('accepts a Union of Object types defining isTypeOf') */
@@ -1218,7 +1218,7 @@ public function testAcceptsAUnionOfObjectTypesDefiningIsTypeOf(): void
12181218
'types' => [$this->objectWithIsTypeOf],
12191219
])
12201220
);
1221-
self::assertDidNotCrash();
1221+
$this->assertDidNotCrash();
12221222
}
12231223

12241224
/** @see it('accepts a Union type defining resolveType of Object types defining isTypeOf') */
@@ -1230,7 +1230,7 @@ public function testAcceptsAUnionTypeDefiningResolveTypeOfObjectTypesDefiningIsT
12301230
'types' => [$this->objectWithIsTypeOf],
12311231
])
12321232
);
1233-
self::assertDidNotCrash();
1233+
$this->assertDidNotCrash();
12341234
}
12351235

12361236
/** @see it('rejects an Union type with an incorrect type for resolveType') */
@@ -1258,7 +1258,7 @@ public function testAcceptsAScalarTypeDefiningSerialize(): void
12581258
'serialize' => static fn () => null,
12591259
])
12601260
);
1261-
self::assertDidNotCrash();
1261+
$this->assertDidNotCrash();
12621262
}
12631263

12641264
// Type System: Scalar types must be serializable
@@ -1288,7 +1288,7 @@ public function testAcceptsAScalarTypeDefiningParseValueAndParseLiteral(): void
12881288
'parseLiteral' => static function (): void {},
12891289
])
12901290
);
1291-
self::assertDidNotCrash();
1291+
$this->assertDidNotCrash();
12921292
}
12931293

12941294
/** @see it('rejects a Scalar type defining parseValue but not parseLiteral') */
@@ -1344,7 +1344,7 @@ public function testAcceptsAnObjectTypeWithAnIsTypeOfFunction(): void
13441344
'fields' => ['f' => ['type' => Type::string()]],
13451345
])
13461346
);
1347-
self::assertDidNotCrash();
1347+
$this->assertDidNotCrash();
13481348
}
13491349

13501350
// Type System: Object types must be assertable
@@ -1374,7 +1374,7 @@ public function testAcceptsAUnionTypeWithArrayTypes(): void
13741374
'types' => [$this->objectType],
13751375
])
13761376
);
1377-
self::assertDidNotCrash();
1377+
$this->assertDidNotCrash();
13781378
}
13791379

13801380
// Type System: Union types must be array
@@ -1388,7 +1388,7 @@ public function testAcceptsAUnionTypeWithFunctionReturningAnArrayOfTypes(): void
13881388
'types' => fn (): array => [$this->objectType],
13891389
])
13901390
);
1391-
self::assertDidNotCrash();
1391+
$this->assertDidNotCrash();
13921392
}
13931393

13941394
/** @see it('rejects a Union type without types') */

tests/Type/TypeLoaderTestCaseBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testSchemaAcceptsTypeLoader(): void
3838
]),
3939
'typeLoader' => static fn () => null,
4040
]);
41-
self::assertDidNotCrash();
41+
$this->assertDidNotCrash();
4242
}
4343

4444
public function testSchemaRejectsNonCallableTypeLoader(): void

tests/Type/ValidationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public function testAcceptsShorthandNotationForFields(): void
567567
])
568568
);
569569
$schema->assertValid();
570-
self::assertDidNotCrash();
570+
$this->assertDidNotCrash();
571571
}
572572

573573
/** @see it('accepts field args with valid names') */

tests/Utils/BuildSchemaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function testIgnoresNonTypeSystemDefinitions(): void
133133
';
134134
// Should not throw
135135
BuildSchema::build($sdl);
136-
self::assertDidNotCrash();
136+
$this->assertDidNotCrash();
137137
}
138138

139139
/** @see it('Match order of default types and directives') */

0 commit comments

Comments
 (0)