Skip to content

Commit

Permalink
Fix: Import
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz authored and sebastianbergmann committed Mar 8, 2022
1 parent 1cf9a3f commit 70fd459
Show file tree
Hide file tree
Showing 16 changed files with 341 additions and 163 deletions.
22 changes: 11 additions & 11 deletions tests/unit/Framework/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,20 @@ public function testAssertArrayNotContainsOnlyIntegers(): void

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

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

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

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

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

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

public function equalProvider(): array
Expand Down Expand Up @@ -993,7 +993,7 @@ public function testAssertClassHasAttributeThrowsExceptionIfClassDoesNotExist():
{
$this->expectException(Exception::class);

$this->assertClassHasAttribute('attribute', 'ClassThatDoesNotExist');
$this->assertClassHasAttribute('attribute', ClassThatDoesNotExist::class);
}

public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
Expand All @@ -1007,7 +1007,7 @@ public function testAssertClassNotHasAttributeThrowsExceptionIfClassDoesNotExist
{
$this->expectException(Exception::class);

$this->assertClassNotHasAttribute('attribute', 'ClassThatDoesNotExist');
$this->assertClassNotHasAttribute('attribute', ClassThatDoesNotExist::class);
}

public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
Expand All @@ -1021,7 +1021,7 @@ public function testAssertClassHasStaticAttributeThrowsExceptionIfClassDoesNotEx
{
$this->expectException(Exception::class);

$this->assertClassHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
$this->assertClassHasStaticAttribute('attribute', ClassThatDoesNotExist::class);
}

public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
Expand All @@ -1035,7 +1035,7 @@ public function testAssertClassNotHasStaticAttributeThrowsExceptionIfClassDoesNo
{
$this->expectException(Exception::class);

$this->assertClassNotHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
$this->assertClassNotHasStaticAttribute('attribute', ClassThatDoesNotExist::class);
}

public function testAssertObjectHasAttributeThrowsException2(): void
Expand Down Expand Up @@ -1321,7 +1321,7 @@ public function testAssertThatIdenticalTo(): void

public function testAssertThatIsInstanceOf(): void
{
$this->assertThat(new stdClass, $this->isInstanceOf('StdClass'));
$this->assertThat(new stdClass, $this->isInstanceOf(stdClass::class));
}

public function testAssertThatIsType(): void
Expand Down Expand Up @@ -1828,7 +1828,7 @@ public function testAssertInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
{
$this->expectException(Exception::class);

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

public function testAssertInstanceOf(): void
Expand All @@ -1844,7 +1844,7 @@ public function testAssertNotInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
{
$this->expectException(Exception::class);

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

public function testAssertNotInstanceOf(): void
Expand Down
18 changes: 12 additions & 6 deletions tests/unit/Framework/Constraint/ClassHasAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ public function testConstraintClassHasAttribute(): void
$constraint->evaluate(stdClass::class);
} catch (ExpectationFailedException $e) {
$this->assertEquals(
<<<'EOF'
Failed asserting that class "stdClass" has attribute "privateAttribute".
sprintf(
<<<'EOF'
Failed asserting that class "%s" has attribute "privateAttribute".

EOF
,
,
stdClass::class
),
TestFailure::exceptionToString($e)
);

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

EOF
,
,
stdClass::class
),
TestFailure::exceptionToString($e)
);

Expand Down
18 changes: 12 additions & 6 deletions tests/unit/Framework/Constraint/ClassHasStaticAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ public function testConstraintClassHasStaticAttribute(): void
$constraint->evaluate(stdClass::class);
} catch (ExpectationFailedException $e) {
$this->assertEquals(
<<<'EOF'
Failed asserting that class "stdClass" has static attribute "privateStaticAttribute".
sprintf(
<<<'EOF'
Failed asserting that class "%s" has static attribute "privateStaticAttribute".

EOF
,
,
stdClass::class
),
TestFailure::exceptionToString($e)
);

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

EOF
,
,
stdClass::class
),
TestFailure::exceptionToString($e)
);

Expand Down
8 changes: 7 additions & 1 deletion tests/unit/Framework/Constraint/IsIdenticalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ public function testConstraintIsIdentical(): void

$this->assertFalse($constraint->evaluate($b, '', true));
$this->assertTrue($constraint->evaluate($a, '', true));
$this->assertEquals('is identical to an object of class "stdClass"', $constraint->toString());
$this->assertEquals(
sprintf(
'is identical to an object of class "%s"',
stdClass::class
),
$constraint->toString()
);
$this->assertCount(1, $constraint);

try {
Expand Down
17 changes: 12 additions & 5 deletions tests/unit/Framework/Constraint/IsInstanceOfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ public function testConstraintFailsOnString(): void
$constraint = new IsInstanceOf(stdClass::class);

try {
$constraint->evaluate('stdClass');
$constraint->evaluate(stdClass::class);
} catch (ExpectationFailedException $e) {
$this->assertSame(
<<<'EOT'
Failed asserting that 'stdClass' is an instance of class "stdClass".
sprintf(
<<<'EOT'
Failed asserting that '%s' is an instance of class "%s".

EOT
,
,
stdClass::class,
stdClass::class
),
TestFailure::exceptionToString($e)
);
}
Expand All @@ -51,7 +55,10 @@ public function testCronstraintsThrowsReflectionException(): void
$constraint = new IsInstanceOf(NotExistingClass::class);

$this->assertSame(
'is instance of class "PHPUnit\Framework\Constraint\NotExistingClass"',
sprintf(
'is instance of class "%s"',
NotExistingClass::class
),
$constraint->toString()
);
}
Expand Down
18 changes: 12 additions & 6 deletions tests/unit/Framework/Constraint/ObjectHasAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ public function testConstraintObjectHasAttribute(): void
$constraint->evaluate(new stdClass);
} catch (ExpectationFailedException $e) {
$this->assertEquals(
<<<'EOF'
Failed asserting that object of class "stdClass" has attribute "privateAttribute".
sprintf(
<<<'EOF'
Failed asserting that object of class "%s" has attribute "privateAttribute".

EOF
,
,
stdClass::class
),
TestFailure::exceptionToString($e)
);

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

EOF
,
,
stdClass::class
),
TestFailure::exceptionToString($e)
);

Expand Down
Loading

0 comments on commit 70fd459

Please sign in to comment.