Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 1, 2024
1 parent d81284d commit 204079a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/_files/mock-object/ExtendableClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

class ExtendableClass
{
public function __destruct()
{
}

public function doSomething(): bool
{
return $this->doSomethingElse();
Expand All @@ -20,4 +24,12 @@ public function doSomethingElse(): bool
{
return false;
}

final public function finalMethod(): void
{
}

private function privateMethod(): void
{
}
}
8 changes: 8 additions & 0 deletions tests/unit/Framework/MockObject/Creation/CreateMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PHPUnit\Framework\MockObject\Generator\ClassIsEnumerationException;
use PHPUnit\Framework\MockObject\Generator\ClassIsFinalException;
use PHPUnit\Framework\MockObject\Generator\ClassIsReadonlyException;
use PHPUnit\Framework\MockObject\Generator\UnknownTypeException;
use PHPUnit\Framework\TestCase;
use PHPUnit\TestFixture\MockObject\AnInterface;
use PHPUnit\TestFixture\MockObject\Enumeration;
Expand Down Expand Up @@ -67,4 +68,11 @@ public function testCannotCreateMockObjectForEnumeration(): void

$this->createMock(Enumeration::class);
}

public function testCannotCreateMockObjectForUnknownType(): void
{
$this->expectException(UnknownTypeException::class);

$this->createMock('this\does\not\exist');
}
}
8 changes: 8 additions & 0 deletions tests/unit/Framework/MockObject/Creation/CreateStubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PHPUnit\Framework\MockObject\Generator\ClassIsEnumerationException;
use PHPUnit\Framework\MockObject\Generator\ClassIsFinalException;
use PHPUnit\Framework\MockObject\Generator\ClassIsReadonlyException;
use PHPUnit\Framework\MockObject\Generator\UnknownTypeException;
use PHPUnit\Framework\TestCase;
use PHPUnit\TestFixture\MockObject\AnInterface;
use PHPUnit\TestFixture\MockObject\Enumeration;
Expand Down Expand Up @@ -67,4 +68,11 @@ public function testCannotCreateTestStubForEnumeration(): void

$this->createStub(Enumeration::class);
}

public function testCannotCreateTestStubForUnknownType(): void
{
$this->expectException(UnknownTypeException::class);

$this->createStub('this\does\not\exist');
}
}

0 comments on commit 204079a

Please sign in to comment.