Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void

public function getClass(): string
{
return 'PHPUnit\Framework\TestCase';
return 'PHPUnit\Framework\Assert';
}

public function isMethodSupported(
Expand Down
36 changes: 36 additions & 0 deletions tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php declare(strict_types = 1);

namespace PHPStan\Type\PHPUnit;

use PHPStan\Testing\TypeInferenceTestCase;

class AssertMethodTypeSpecifyingExtensionTest extends TypeInferenceTestCase
{

/** @return mixed[] */
public function dataFileAsserts(): iterable
{
yield from $this->gatherAssertTypes(__DIR__ . '/data/assert-method.php');
}

/**
* @dataProvider dataFileAsserts
* @param string $assertType
* @param string $file
* @param mixed ...$args
*/
public function testFileAsserts(
string $assertType,
string $file,
...$args
): void
{
$this->assertFileAsserts($assertType, $file, ...$args);
}

public static function getAdditionalConfigFiles(): array
{
return [__DIR__ . '/../../../extension.neon'];
}

}
17 changes: 17 additions & 0 deletions tests/Type/PHPUnit/data/assert-method.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace AssertMethod;

use function PHPStan\Testing\assertType;

class Foo
{

public function inheritedAssertMethodsNarrowType(?string $s): void
{
$customAsserter = new class () extends \PHPUnit\Framework\Assert {};
$customAsserter->assertNotNull($s);
assertType('string', $s);
}

}