Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 22, 2018
1 parent bac4fa5 commit 6a137ad
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions tests/unit/Framework/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,8 @@ public function testAssertIsReadable(): void

public function testAssertNotIsReadable(): void
{
$this->assertNotIsReadable(__DIR__ . \DIRECTORY_SEPARATOR . 'NotExisting');

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

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

public function testAssertNotIsWritable(): void
{
$this->assertNotIsWritable(__DIR__ . \DIRECTORY_SEPARATOR . 'NotExisting');

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

$this->assertNotIsWritable(__FILE__);
Expand Down Expand Up @@ -1596,27 +1600,55 @@ public function testAssertClassHasAttributeThrowsExceptionIfAttributeNameIsNotVa
$this->assertClassHasAttribute('1', \ClassWithNonPublicAttributes::class);
}

public function testAssertClassHasAttributeThrowsExceptionIfClassDoesNotExist(): void
{
$this->expectException(Exception::class);

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

public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
{
$this->expectException(Exception::class);

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

public function testAssertClassNotHasAttributeThrowsExceptionIfClassDoesNotExist(): void
{
$this->expectException(Exception::class);

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

public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
{
$this->expectException(Exception::class);

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

public function testAssertClassHasStaticAttributeThrowsExceptionIfClassDoesNotExist(): void
{
$this->expectException(Exception::class);

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

public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
{
$this->expectException(Exception::class);

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

public function testAssertClassNotHasStaticAttributeThrowsExceptionIfClassDoesNotExist(): void
{
$this->expectException(Exception::class);

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

public function testAssertObjectHasAttributeThrowsException2(): void
{
$this->expectException(Exception::class);
Expand Down Expand Up @@ -2411,6 +2443,13 @@ public function testAssertJsonFileEqualsJsonFile(): void
$this->assertJsonFileEqualsJsonFile($file, $file, $message);
}

public function testAssertInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
{
$this->expectException(Exception::class);

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

public function testAssertInstanceOf(): void
{
$this->assertInstanceOf(\stdClass::class, new \stdClass);
Expand All @@ -2428,6 +2467,13 @@ public function testAssertAttributeInstanceOf(): void
$this->assertAttributeInstanceOf(\stdClass::class, 'a', $o);
}

public function testAssertNotInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
{
$this->expectException(Exception::class);

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

public function testAssertNotInstanceOf(): void
{
$this->assertNotInstanceOf(\Exception::class, new \stdClass);
Expand Down Expand Up @@ -2520,6 +2566,69 @@ public function testAssertStringNotMatchesFormatFile(): void
$this->assertStringNotMatchesFormatFile(TEST_FILES_PATH . 'expectedFileFormat.txt', "FOO\n");
}

public function testLogicalAnd(): void
{
$this->assertThat(
true,
$this->logicalAnd(
$this->isTrue(),
$this->isTrue()
)
);

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

$this->assertThat(
true,
$this->logicalAnd(
$this->isTrue(),
$this->isFalse()
)
);
}

public function testLogicalOr(): void
{
$this->assertThat(
true,
$this->logicalOr(
$this->isTrue(),
$this->isFalse()
)
);

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

$this->assertThat(
true,
$this->logicalOr(
$this->isFalse(),
$this->isFalse()
)
);
}

public function testLogicalXor(): void
{
$this->assertThat(
true,
$this->logicalXor(
$this->isTrue(),
$this->isFalse()
)
);

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

$this->assertThat(
true,
$this->logicalXor(
$this->isTrue(),
$this->isTrue()
)
);
}

protected function sameValues(): array
{
$object = new \SampleClass(4, 8, 15);
Expand Down

0 comments on commit 6a137ad

Please sign in to comment.