Skip to content

Commit

Permalink
Merge pull request #113 from localheinz/fix/test
Browse files Browse the repository at this point in the history
Fix: Add missing test
  • Loading branch information
localheinz authored Feb 5, 2020
2 parents 5b1ef41 + 826f7bb commit 72bd661
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
<testsuite name="Static Analysis">
<directory>tests/StaticAnalysis</directory>
</testsuite>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
</phpunit>
74 changes: 74 additions & 0 deletions tests/Unit/Reflection/ObjectProphecyMethodReflectionTest.php
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());
}
}

0 comments on commit 72bd661

Please sign in to comment.