Skip to content

Commit 1da0ad9

Browse files
localheinzsebastianbergmann
authored andcommitted
Fix: Use class keyword
1 parent 1b58560 commit 1da0ad9

16 files changed

+269
-117
lines changed

tests/unit/Framework/AssertTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,20 @@ public function testAssertArrayNotContainsOnlyIntegers(): void
221221

222222
public function testAssertArrayContainsOnlyStdClass(): void
223223
{
224-
$this->assertContainsOnly('StdClass', [new stdClass]);
224+
$this->assertContainsOnly(stdClass::class, [new stdClass]);
225225

226226
$this->expectException(AssertionFailedError::class);
227227

228-
$this->assertContainsOnly('StdClass', ['StdClass']);
228+
$this->assertContainsOnly(stdClass::class, [stdClass::class]);
229229
}
230230

231231
public function testAssertArrayNotContainsOnlyStdClass(): void
232232
{
233-
$this->assertNotContainsOnly('StdClass', ['StdClass']);
233+
$this->assertNotContainsOnly(stdClass::class, [stdClass::class]);
234234

235235
$this->expectException(AssertionFailedError::class);
236236

237-
$this->assertNotContainsOnly('StdClass', [new stdClass]);
237+
$this->assertNotContainsOnly(stdClass::class, [new stdClass]);
238238
}
239239

240240
public function equalProvider(): array
@@ -964,7 +964,7 @@ public function testAssertClassHasAttributeThrowsExceptionIfClassDoesNotExist():
964964
{
965965
$this->expectException(Exception::class);
966966

967-
$this->assertClassHasAttribute('attribute', 'ClassThatDoesNotExist');
967+
$this->assertClassHasAttribute('attribute', ClassThatDoesNotExist::class);
968968
}
969969

970970
public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
@@ -978,7 +978,7 @@ public function testAssertClassNotHasAttributeThrowsExceptionIfClassDoesNotExist
978978
{
979979
$this->expectException(Exception::class);
980980

981-
$this->assertClassNotHasAttribute('attribute', 'ClassThatDoesNotExist');
981+
$this->assertClassNotHasAttribute('attribute', ClassThatDoesNotExist::class);
982982
}
983983

984984
public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
@@ -992,7 +992,7 @@ public function testAssertClassHasStaticAttributeThrowsExceptionIfClassDoesNotEx
992992
{
993993
$this->expectException(Exception::class);
994994

995-
$this->assertClassHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
995+
$this->assertClassHasStaticAttribute('attribute', ClassThatDoesNotExist::class);
996996
}
997997

998998
public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
@@ -1006,7 +1006,7 @@ public function testAssertClassNotHasStaticAttributeThrowsExceptionIfClassDoesNo
10061006
{
10071007
$this->expectException(Exception::class);
10081008

1009-
$this->assertClassNotHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
1009+
$this->assertClassNotHasStaticAttribute('attribute', ClassThatDoesNotExist::class);
10101010
}
10111011

10121012
public function testAssertObjectHasAttributeThrowsException2(): void
@@ -1292,7 +1292,7 @@ public function testAssertThatIdenticalTo(): void
12921292

12931293
public function testAssertThatIsInstanceOf(): void
12941294
{
1295-
$this->assertThat(new stdClass, $this->isInstanceOf('StdClass'));
1295+
$this->assertThat(new stdClass, $this->isInstanceOf(stdClass::class));
12961296
}
12971297

12981298
public function testAssertThatIsType(): void
@@ -1799,7 +1799,7 @@ public function testAssertInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
17991799
{
18001800
$this->expectException(Exception::class);
18011801

1802-
$this->assertInstanceOf('ClassThatDoesNotExist', new stdClass);
1802+
$this->assertInstanceOf(ClassThatDoesNotExist::class, new stdClass);
18031803
}
18041804

18051805
public function testAssertInstanceOf(): void
@@ -1815,7 +1815,7 @@ public function testAssertNotInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
18151815
{
18161816
$this->expectException(Exception::class);
18171817

1818-
$this->assertNotInstanceOf('ClassThatDoesNotExist', new stdClass);
1818+
$this->assertNotInstanceOf(ClassThatDoesNotExist::class, new stdClass);
18191819
}
18201820

18211821
public function testAssertNotInstanceOf(): void

tests/unit/Framework/Constraint/ClassHasAttributeTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ public function testConstraintClassHasAttribute(): void
3434
$constraint->evaluate(stdClass::class);
3535
} catch (ExpectationFailedException $e) {
3636
$this->assertEquals(
37-
<<<'EOF'
38-
Failed asserting that class "stdClass" has attribute "privateAttribute".
37+
sprintf(
38+
<<<'EOF'
39+
Failed asserting that class "%s" has attribute "privateAttribute".
3940

4041
EOF
41-
,
42+
,
43+
stdClass::class
44+
),
4245
TestFailure::exceptionToString($e)
4346
);
4447

@@ -58,12 +61,15 @@ public function testConstraintClassHasAttribute2(): void
5861
$constraint->evaluate(stdClass::class, 'custom message');
5962
} catch (ExpectationFailedException $e) {
6063
$this->assertEquals(
61-
<<<'EOF'
64+
sprintf(
65+
<<<'EOF'
6266
custom message
63-
Failed asserting that class "stdClass" has attribute "privateAttribute".
67+
Failed asserting that class "%s" has attribute "privateAttribute".
6468

6569
EOF
66-
,
70+
,
71+
stdClass::class
72+
),
6773
TestFailure::exceptionToString($e)
6874
);
6975

tests/unit/Framework/Constraint/ClassHasStaticAttributeTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ public function testConstraintClassHasStaticAttribute(): void
3232
$constraint->evaluate(stdClass::class);
3333
} catch (ExpectationFailedException $e) {
3434
$this->assertEquals(
35-
<<<'EOF'
36-
Failed asserting that class "stdClass" has static attribute "privateStaticAttribute".
35+
sprintf(
36+
<<<'EOF'
37+
Failed asserting that class "%s" has static attribute "privateStaticAttribute".
3738

3839
EOF
39-
,
40+
,
41+
stdClass::class
42+
),
4043
TestFailure::exceptionToString($e)
4144
);
4245

@@ -54,12 +57,15 @@ public function testConstraintClassHasStaticAttribute2(): void
5457
$constraint->evaluate(stdClass::class, 'custom message');
5558
} catch (ExpectationFailedException $e) {
5659
$this->assertEquals(
57-
<<<'EOF'
60+
sprintf(
61+
<<<'EOF'
5862
custom message
59-
Failed asserting that class "stdClass" has static attribute "foo".
63+
Failed asserting that class "%s" has static attribute "foo".
6064

6165
EOF
62-
,
66+
,
67+
stdClass::class
68+
),
6369
TestFailure::exceptionToString($e)
6470
);
6571

tests/unit/Framework/Constraint/IsIdenticalTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ public function testConstraintIsIdentical(): void
2727

2828
$this->assertFalse($constraint->evaluate($b, '', true));
2929
$this->assertTrue($constraint->evaluate($a, '', true));
30-
$this->assertEquals('is identical to an object of class "stdClass"', $constraint->toString());
30+
$this->assertEquals(
31+
sprintf(
32+
'is identical to an object of class "%s"',
33+
stdClass::class
34+
),
35+
$constraint->toString()
36+
);
3137
$this->assertCount(1, $constraint);
3238

3339
try {

tests/unit/Framework/Constraint/IsInstanceOfTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@ public function testConstraintFailsOnString(): void
3131
$constraint = new IsInstanceOf(stdClass::class);
3232

3333
try {
34-
$constraint->evaluate('stdClass');
34+
$constraint->evaluate(stdClass::class);
3535
} catch (ExpectationFailedException $e) {
3636
$this->assertSame(
37-
<<<'EOT'
38-
Failed asserting that 'stdClass' is an instance of class "stdClass".
37+
sprintf(
38+
<<<'EOT'
39+
Failed asserting that '%s' is an instance of class "%s".
3940

4041
EOT
41-
,
42+
,
43+
stdClass::class,
44+
stdClass::class
45+
),
4246
TestFailure::exceptionToString($e)
4347
);
4448
}
@@ -51,7 +55,10 @@ public function testCronstraintsThrowsReflectionException(): void
5155
$constraint = new IsInstanceOf(NotExistingClass::class);
5256

5357
$this->assertSame(
54-
'is instance of class "PHPUnit\Framework\Constraint\NotExistingClass"',
58+
sprintf(
59+
'is instance of class "%s"',
60+
NotExistingClass::class
61+
),
5562
$constraint->toString()
5663
);
5764
}

tests/unit/Framework/Constraint/IsTypeTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ public function testConstraintIsType(): void
3636
$constraint->evaluate(new stdClass);
3737
} catch (ExpectationFailedException $e) {
3838
$this->assertStringMatchesFormat(
39-
<<<'EOF'
40-
Failed asserting that stdClass Object &%x () is of type "string".
39+
sprintf(
40+
<<<'EOF'
41+
Failed asserting that %s Object &%%x () is of type "string".
4142

4243
EOF
43-
,
44+
,
45+
stdClass::class
46+
),
4447
$this->trimnl(TestFailure::exceptionToString($e))
4548
);
4649

@@ -58,12 +61,15 @@ public function testConstraintIsType2(): void
5861
$constraint->evaluate(new stdClass, 'custom message');
5962
} catch (ExpectationFailedException $e) {
6063
$this->assertStringMatchesFormat(
61-
<<<'EOF'
64+
sprintf(
65+
<<<'EOF'
6266
custom message
63-
Failed asserting that stdClass Object &%x () is of type "string".
67+
Failed asserting that %s Object &%%x () is of type "string".
6468

6569
EOF
6670
,
71+
stdClass::class
72+
),
6773
$this->trimnl(TestFailure::exceptionToString($e))
6874
);
6975

tests/unit/Framework/Constraint/ObjectHasAttributeTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ public function testConstraintObjectHasAttribute(): void
3232
$constraint->evaluate(new stdClass);
3333
} catch (ExpectationFailedException $e) {
3434
$this->assertEquals(
35-
<<<'EOF'
36-
Failed asserting that object of class "stdClass" has attribute "privateAttribute".
35+
sprintf(
36+
<<<'EOF'
37+
Failed asserting that object of class "%s" has attribute "privateAttribute".
3738

3839
EOF
39-
,
40+
,
41+
stdClass::class
42+
),
4043
TestFailure::exceptionToString($e)
4144
);
4245

@@ -54,12 +57,15 @@ public function testConstraintObjectHasAttribute2(): void
5457
$constraint->evaluate(new stdClass, 'custom message');
5558
} catch (ExpectationFailedException $e) {
5659
$this->assertEquals(
57-
<<<'EOF'
60+
sprintf(
61+
<<<'EOF'
5862
custom message
59-
Failed asserting that object of class "stdClass" has attribute "privateAttribute".
63+
Failed asserting that object of class "%s" has attribute "privateAttribute".
6064

6165
EOF
62-
,
66+
,
67+
stdClass::class
68+
),
6369
TestFailure::exceptionToString($e)
6470
);
6571

0 commit comments

Comments
 (0)