Skip to content

Commit 70fd459

Browse files
localheinzsebastianbergmann
authored andcommitted
Fix: Import
1 parent 1cf9a3f commit 70fd459

16 files changed

+341
-163
lines changed

Diff for: tests/unit/Framework/AssertTest.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,20 @@ public function testAssertArrayNotContainsOnlyIntegers(): void
216216

217217
public function testAssertArrayContainsOnlyStdClass(): void
218218
{
219-
$this->assertContainsOnly('StdClass', [new stdClass]);
219+
$this->assertContainsOnly(stdClass::class, [new stdClass]);
220220

221221
$this->expectException(AssertionFailedError::class);
222222

223-
$this->assertContainsOnly('StdClass', ['StdClass']);
223+
$this->assertContainsOnly(stdClass::class, [stdClass::class]);
224224
}
225225

226226
public function testAssertArrayNotContainsOnlyStdClass(): void
227227
{
228-
$this->assertNotContainsOnly('StdClass', ['StdClass']);
228+
$this->assertNotContainsOnly(stdClass::class, [stdClass::class]);
229229

230230
$this->expectException(AssertionFailedError::class);
231231

232-
$this->assertNotContainsOnly('StdClass', [new stdClass]);
232+
$this->assertNotContainsOnly(stdClass::class, [new stdClass]);
233233
}
234234

235235
public function equalProvider(): array
@@ -993,7 +993,7 @@ public function testAssertClassHasAttributeThrowsExceptionIfClassDoesNotExist():
993993
{
994994
$this->expectException(Exception::class);
995995

996-
$this->assertClassHasAttribute('attribute', 'ClassThatDoesNotExist');
996+
$this->assertClassHasAttribute('attribute', ClassThatDoesNotExist::class);
997997
}
998998

999999
public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
@@ -1007,7 +1007,7 @@ public function testAssertClassNotHasAttributeThrowsExceptionIfClassDoesNotExist
10071007
{
10081008
$this->expectException(Exception::class);
10091009

1010-
$this->assertClassNotHasAttribute('attribute', 'ClassThatDoesNotExist');
1010+
$this->assertClassNotHasAttribute('attribute', ClassThatDoesNotExist::class);
10111011
}
10121012

10131013
public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
@@ -1021,7 +1021,7 @@ public function testAssertClassHasStaticAttributeThrowsExceptionIfClassDoesNotEx
10211021
{
10221022
$this->expectException(Exception::class);
10231023

1024-
$this->assertClassHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
1024+
$this->assertClassHasStaticAttribute('attribute', ClassThatDoesNotExist::class);
10251025
}
10261026

10271027
public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
@@ -1035,7 +1035,7 @@ public function testAssertClassNotHasStaticAttributeThrowsExceptionIfClassDoesNo
10351035
{
10361036
$this->expectException(Exception::class);
10371037

1038-
$this->assertClassNotHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
1038+
$this->assertClassNotHasStaticAttribute('attribute', ClassThatDoesNotExist::class);
10391039
}
10401040

10411041
public function testAssertObjectHasAttributeThrowsException2(): void
@@ -1321,7 +1321,7 @@ public function testAssertThatIdenticalTo(): void
13211321

13221322
public function testAssertThatIsInstanceOf(): void
13231323
{
1324-
$this->assertThat(new stdClass, $this->isInstanceOf('StdClass'));
1324+
$this->assertThat(new stdClass, $this->isInstanceOf(stdClass::class));
13251325
}
13261326

13271327
public function testAssertThatIsType(): void
@@ -1828,7 +1828,7 @@ public function testAssertInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
18281828
{
18291829
$this->expectException(Exception::class);
18301830

1831-
$this->assertInstanceOf('ClassThatDoesNotExist', new stdClass);
1831+
$this->assertInstanceOf(ClassThatDoesNotExist::class, new stdClass);
18321832
}
18331833

18341834
public function testAssertInstanceOf(): void
@@ -1844,7 +1844,7 @@ public function testAssertNotInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
18441844
{
18451845
$this->expectException(Exception::class);
18461846

1847-
$this->assertNotInstanceOf('ClassThatDoesNotExist', new stdClass);
1847+
$this->assertNotInstanceOf(ClassThatDoesNotExist::class, new stdClass);
18481848
}
18491849

18501850
public function testAssertNotInstanceOf(): void

Diff for: tests/unit/Framework/Constraint/ClassHasAttributeTest.php

+12-6
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

Diff for: tests/unit/Framework/Constraint/ClassHasStaticAttributeTest.php

+12-6
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

Diff for: tests/unit/Framework/Constraint/IsIdenticalTest.php

+7-1
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 {

Diff for: tests/unit/Framework/Constraint/IsInstanceOfTest.php

+12-5
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
}

Diff for: tests/unit/Framework/Constraint/ObjectHasAttributeTest.php

+12-6
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)