Skip to content

Commit

Permalink
Use addToAssertionCount(1) instead of assertTrue(true)
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod authored Jun 17, 2024
1 parent 7e3ef03 commit 83d3728
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tests/Executor/Promise/SyncPromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,6 @@ public function testPendingPromiseThen(): void
public function testRunEmptyQueue(): void
{
SyncPromise::runQueue();
self::assertDidNotCrash();
$this->assertDidNotCrash();
}
}
12 changes: 6 additions & 6 deletions tests/Language/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testParseProvidesUsefulErrorWhenUsingSource(): void
public function testParsesVariableInlineValues(): void
{
Parser::parse('{ field(complex: { a: { b: [ $var ] } }) }');
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

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

/**
Expand Down Expand Up @@ -264,7 +264,7 @@ public function testParsessAnonymousMutationOperations(): void
mutationField
}
');
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

/** @see it('parses anonymous subscription operations') */
Expand All @@ -275,7 +275,7 @@ public function testParsesAnonymousSubscriptionOperations(): void
subscriptionField
}
');
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

/** @see it('parses named mutation operations') */
Expand All @@ -286,7 +286,7 @@ public function testParsesNamedMutationOperations(): void
mutationField
}
');
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

/** @see it('parses named subscription operations') */
Expand All @@ -297,7 +297,7 @@ public function testParsesNamedSubscriptionOperations(): void
subscriptionField
}
');
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

/** @see it('creates ast') */
Expand Down
5 changes: 2 additions & 3 deletions tests/TestCaseBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ abstract class TestCaseBase extends TestCase
*
* @see TestCase::expectNotToPerformAssertions()
*/
public static function assertDidNotCrash(): void
public function assertDidNotCrash(): void
{
// @phpstan-ignore-next-line this truism is required to prevent a PHPUnit warning
self::assertTrue(true);
$this->addToAssertionCount(1);
}

protected static function assertASTMatches(string $expected, ?Node $node): void
Expand Down
24 changes: 12 additions & 12 deletions tests/Type/DefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ public function testRejectsAnObjectTypeWithInterfacesAsAFunctionReturningAnIncor
public function testAcceptsALambdaAsAnObjectFieldResolver(): void
{
$this->schemaWithObjectWithFieldResolver(static fn () => null);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

/**
Expand Down Expand Up @@ -1065,7 +1065,7 @@ public function testAcceptsAnInterfaceTypeDefiningResolveType(): void
'fields' => ['f' => ['type' => Type::string()]],
])
);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

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

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

/** @see it('rejects an Interface type with an incorrect type for resolveType') */
Expand Down Expand Up @@ -1206,7 +1206,7 @@ public function testAcceptsAUnionTypeDefiningResolveType(): void
'types' => [$this->objectType],
])
);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

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

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

/** @see it('rejects an Union type with an incorrect type for resolveType') */
Expand Down Expand Up @@ -1258,7 +1258,7 @@ public function testAcceptsAScalarTypeDefiningSerialize(): void
'serialize' => static fn () => null,
])
);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

// Type System: Scalar types must be serializable
Expand Down Expand Up @@ -1288,7 +1288,7 @@ public function testAcceptsAScalarTypeDefiningParseValueAndParseLiteral(): void
'parseLiteral' => static function (): void {},
])
);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

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

// Type System: Object types must be assertable
Expand Down Expand Up @@ -1374,7 +1374,7 @@ public function testAcceptsAUnionTypeWithArrayTypes(): void
'types' => [$this->objectType],
])
);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

// Type System: Union types must be array
Expand All @@ -1388,7 +1388,7 @@ public function testAcceptsAUnionTypeWithFunctionReturningAnArrayOfTypes(): void
'types' => fn (): array => [$this->objectType],
])
);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

/** @see it('rejects a Union type without types') */
Expand Down
2 changes: 1 addition & 1 deletion tests/Type/TypeLoaderTestCaseBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testSchemaAcceptsTypeLoader(): void
]),
'typeLoader' => static fn () => null,
]);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

public function testSchemaRejectsNonCallableTypeLoader(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Type/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public function testAcceptsShorthandNotationForFields(): void
])
);
$schema->assertValid();
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

/** @see it('accepts field args with valid names') */
Expand Down
2 changes: 1 addition & 1 deletion tests/Utils/BuildSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function testIgnoresNonTypeSystemDefinitions(): void
';
// Should not throw
BuildSchema::build($sdl);
self::assertDidNotCrash();
$this->assertDidNotCrash();
}

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

0 comments on commit 83d3728

Please sign in to comment.