Skip to content

Commit 6a137ad

Browse files
Add tests
1 parent bac4fa5 commit 6a137ad

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

tests/unit/Framework/AssertTest.php

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,8 @@ public function testAssertIsReadable(): void
858858

859859
public function testAssertNotIsReadable(): void
860860
{
861+
$this->assertNotIsReadable(__DIR__ . \DIRECTORY_SEPARATOR . 'NotExisting');
862+
861863
$this->expectException(AssertionFailedError::class);
862864

863865
$this->assertNotIsReadable(__FILE__);
@@ -874,6 +876,8 @@ public function testAssertIsWritable(): void
874876

875877
public function testAssertNotIsWritable(): void
876878
{
879+
$this->assertNotIsWritable(__DIR__ . \DIRECTORY_SEPARATOR . 'NotExisting');
880+
877881
$this->expectException(AssertionFailedError::class);
878882

879883
$this->assertNotIsWritable(__FILE__);
@@ -1596,27 +1600,55 @@ public function testAssertClassHasAttributeThrowsExceptionIfAttributeNameIsNotVa
15961600
$this->assertClassHasAttribute('1', \ClassWithNonPublicAttributes::class);
15971601
}
15981602

1603+
public function testAssertClassHasAttributeThrowsExceptionIfClassDoesNotExist(): void
1604+
{
1605+
$this->expectException(Exception::class);
1606+
1607+
$this->assertClassHasAttribute('attribute', 'ClassThatDoesNotExist');
1608+
}
1609+
15991610
public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
16001611
{
16011612
$this->expectException(Exception::class);
16021613

16031614
$this->assertClassNotHasAttribute('1', \ClassWithNonPublicAttributes::class);
16041615
}
16051616

1617+
public function testAssertClassNotHasAttributeThrowsExceptionIfClassDoesNotExist(): void
1618+
{
1619+
$this->expectException(Exception::class);
1620+
1621+
$this->assertClassNotHasAttribute('attribute', 'ClassThatDoesNotExist');
1622+
}
1623+
16061624
public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
16071625
{
16081626
$this->expectException(Exception::class);
16091627

16101628
$this->assertClassHasStaticAttribute('1', \ClassWithNonPublicAttributes::class);
16111629
}
16121630

1631+
public function testAssertClassHasStaticAttributeThrowsExceptionIfClassDoesNotExist(): void
1632+
{
1633+
$this->expectException(Exception::class);
1634+
1635+
$this->assertClassHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
1636+
}
1637+
16131638
public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
16141639
{
16151640
$this->expectException(Exception::class);
16161641

16171642
$this->assertClassNotHasStaticAttribute('1', \ClassWithNonPublicAttributes::class);
16181643
}
16191644

1645+
public function testAssertClassNotHasStaticAttributeThrowsExceptionIfClassDoesNotExist(): void
1646+
{
1647+
$this->expectException(Exception::class);
1648+
1649+
$this->assertClassNotHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
1650+
}
1651+
16201652
public function testAssertObjectHasAttributeThrowsException2(): void
16211653
{
16221654
$this->expectException(Exception::class);
@@ -2411,6 +2443,13 @@ public function testAssertJsonFileEqualsJsonFile(): void
24112443
$this->assertJsonFileEqualsJsonFile($file, $file, $message);
24122444
}
24132445

2446+
public function testAssertInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
2447+
{
2448+
$this->expectException(Exception::class);
2449+
2450+
$this->assertInstanceOf('ClassThatDoesNotExist', new \stdClass);
2451+
}
2452+
24142453
public function testAssertInstanceOf(): void
24152454
{
24162455
$this->assertInstanceOf(\stdClass::class, new \stdClass);
@@ -2428,6 +2467,13 @@ public function testAssertAttributeInstanceOf(): void
24282467
$this->assertAttributeInstanceOf(\stdClass::class, 'a', $o);
24292468
}
24302469

2470+
public function testAssertNotInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
2471+
{
2472+
$this->expectException(Exception::class);
2473+
2474+
$this->assertNotInstanceOf('ClassThatDoesNotExist', new \stdClass);
2475+
}
2476+
24312477
public function testAssertNotInstanceOf(): void
24322478
{
24332479
$this->assertNotInstanceOf(\Exception::class, new \stdClass);
@@ -2520,6 +2566,69 @@ public function testAssertStringNotMatchesFormatFile(): void
25202566
$this->assertStringNotMatchesFormatFile(TEST_FILES_PATH . 'expectedFileFormat.txt', "FOO\n");
25212567
}
25222568

2569+
public function testLogicalAnd(): void
2570+
{
2571+
$this->assertThat(
2572+
true,
2573+
$this->logicalAnd(
2574+
$this->isTrue(),
2575+
$this->isTrue()
2576+
)
2577+
);
2578+
2579+
$this->expectException(AssertionFailedError::class);
2580+
2581+
$this->assertThat(
2582+
true,
2583+
$this->logicalAnd(
2584+
$this->isTrue(),
2585+
$this->isFalse()
2586+
)
2587+
);
2588+
}
2589+
2590+
public function testLogicalOr(): void
2591+
{
2592+
$this->assertThat(
2593+
true,
2594+
$this->logicalOr(
2595+
$this->isTrue(),
2596+
$this->isFalse()
2597+
)
2598+
);
2599+
2600+
$this->expectException(AssertionFailedError::class);
2601+
2602+
$this->assertThat(
2603+
true,
2604+
$this->logicalOr(
2605+
$this->isFalse(),
2606+
$this->isFalse()
2607+
)
2608+
);
2609+
}
2610+
2611+
public function testLogicalXor(): void
2612+
{
2613+
$this->assertThat(
2614+
true,
2615+
$this->logicalXor(
2616+
$this->isTrue(),
2617+
$this->isFalse()
2618+
)
2619+
);
2620+
2621+
$this->expectException(AssertionFailedError::class);
2622+
2623+
$this->assertThat(
2624+
true,
2625+
$this->logicalXor(
2626+
$this->isTrue(),
2627+
$this->isTrue()
2628+
)
2629+
);
2630+
}
2631+
25232632
protected function sameValues(): array
25242633
{
25252634
$object = new \SampleClass(4, 8, 15);

0 commit comments

Comments
 (0)