feat: inline testing

This commit is contained in:
Nuno Maduro
2022-12-04 18:38:20 +00:00
parent 3324455e0a
commit 7ad045d6b7
7 changed files with 90 additions and 1 deletions

View File

@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Pest\NotExported;
use PHPUnit\Framework\TestCase;
/**
* @internal
*/
class MyTestCase extends TestCase // @phpstan-ignore-line
{
public function assertIsTestable(string $testable): void
{
static::assertSame(MyTestableClass::class, $testable);
}
}

View File

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Pest\NotExported;
/**
* @internal
*/
final class MyTestableClass
{
public function foo(): void
{
// ...
}
}
it('foo', function () {
$testable = new MyTestableClass();
$this->assertIsTestable(get_class($testable)); // @phpstan-ignore-line
});

View File

@ -23,7 +23,7 @@ final class Plugin
public static function uses(string ...$traits): void
{
self::$callables[] = function () use ($traits): void {
uses(...$traits)->in(TestSuite::getInstance()->rootPath.DIRECTORY_SEPARATOR.testDirectory());
uses(...$traits)->in(TestSuite::getInstance()->rootPath);
};
}
}