-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from localheinz/fix/test
Fix: Add missing test
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
tests/Unit/Reflection/ObjectProphecyMethodReflectionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2018 Jan Gregor Emge-Triebel | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/Jan0707/phpstan-prophecy | ||
*/ | ||
|
||
namespace JanGregor\Prophecy\Test\Unit\Reflection; | ||
|
||
use JanGregor\Prophecy\Reflection\ObjectProphecyMethodReflection; | ||
use PHPStan\Reflection; | ||
use PHPStan\TrinaryLogic; | ||
use PHPStan\Type; | ||
use PHPUnit\Framework; | ||
use Prophecy\Prophecy; | ||
|
||
/** | ||
* @covers \JanGregor\Prophecy\Reflection\ObjectProphecyMethodReflection | ||
* | ||
* @internal | ||
*/ | ||
final class ObjectProphecyMethodReflectionTest extends Framework\TestCase | ||
{ | ||
public function testConstructorSetsValues(): void | ||
{ | ||
$classReflection = $this->prophesize(Reflection\ClassReflection::class); | ||
$name = 'hmm'; | ||
|
||
$reflection = new ObjectProphecyMethodReflection( | ||
$classReflection->reveal(), | ||
$name | ||
); | ||
|
||
self::assertSame($classReflection->reveal(), $reflection->getDeclaringClass()); | ||
self::assertSame($name, $reflection->getName()); | ||
} | ||
|
||
public function testDefaults(): void | ||
{ | ||
$reflection = new ObjectProphecyMethodReflection( | ||
$this->prophesize(Reflection\ClassReflection::class)->reveal(), | ||
'hmm' | ||
); | ||
|
||
self::assertNull($reflection->getDeprecatedDescription()); | ||
self::assertNull($reflection->getDocComment()); | ||
self::assertSame($reflection, $reflection->getPrototype()); | ||
self::assertNull($reflection->getThrowType()); | ||
|
||
$variants = [ | ||
new Reflection\FunctionVariant( | ||
Type\Generic\TemplateTypeMap::createEmpty(), | ||
null, | ||
[], | ||
true, | ||
new Type\ObjectType(Prophecy\MethodProphecy::class) | ||
), | ||
]; | ||
|
||
self::assertEquals($variants, $reflection->getVariants()); | ||
self::assertTrue($reflection->hasSideEffects()->equals(TrinaryLogic::createNo())); | ||
self::assertTrue($reflection->isDeprecated()->equals(TrinaryLogic::createNo())); | ||
self::assertTrue($reflection->isInternal()->equals(TrinaryLogic::createNo())); | ||
self::assertFalse($reflection->isPrivate()); | ||
self::assertTrue($reflection->isPublic()); | ||
self::assertFalse($reflection->isStatic()); | ||
} | ||
} |