mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: inline testing
This commit is contained in:
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -12,3 +12,7 @@ phpstan.neon export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
CONTRIBUTING.md export-ignore
|
||||
README.md export-ignore
|
||||
|
||||
# Inline
|
||||
/src/NotExported export-ignore
|
||||
/phpunit.inline.xml export-ignore
|
||||
|
||||
@ -51,8 +51,15 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"pestphp/pest-dev-tools": "^2.0.0",
|
||||
"pestphp/pest-plugin-inline": "2.x-dev",
|
||||
"symfony/process": "^6.2.0"
|
||||
},
|
||||
"repositories": {
|
||||
"inline": {
|
||||
"type": "path",
|
||||
"url": "../pest-plugin-inline"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
@ -70,6 +77,7 @@
|
||||
"test:lint": "pint --test",
|
||||
"test:types": "phpstan analyse --ansi --memory-limit=-1 --debug",
|
||||
"test:unit": "php bin/pest --colors=always --exclude-group=integration --compact",
|
||||
"test:inline": "php bin/pest --colors=always --configuration=phpunit.inline.xml",
|
||||
"test:parallel": "exit 1",
|
||||
"test:integration": "php bin/pest --colors=always --group=integration -v",
|
||||
"update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
|
||||
|
||||
34
phpunit.inline.xml
Normal file
34
phpunit.inline.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
cacheResult="false"
|
||||
colors="true"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
cacheDirectory=".phpunit.cache"
|
||||
backupStaticProperties="false"
|
||||
displayDetailsOnIncompleteTests="true"
|
||||
displayDetailsOnSkippedTests="true"
|
||||
displayDetailsOnTestsThatTriggerDeprecations="true"
|
||||
displayDetailsOnTestsThatTriggerErrors="true"
|
||||
displayDetailsOnTestsThatTriggerNotices="true"
|
||||
displayDetailsOnTestsThatTriggerWarnings="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="default">
|
||||
<directory suffix=".php">./src</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
</phpunit>
|
||||
18
src/NotExported/MyTestCase.php
Normal file
18
src/NotExported/MyTestCase.php
Normal 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);
|
||||
}
|
||||
}
|
||||
22
src/NotExported/MyTestableClass.php
Normal file
22
src/NotExported/MyTestableClass.php
Normal 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
|
||||
});
|
||||
@ -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);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Pest\NotExported\MyTestCase;
|
||||
use Tests\CustomTestCaseInSubFolders\SubFolder\SubFolder\CustomTestCaseInSubFolder;
|
||||
|
||||
uses(CustomTestCaseInSubFolder::class)->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder');
|
||||
|
||||
uses(MyTestCase::class)->in('../src/NotExported');
|
||||
|
||||
uses()->group('integration')->in('Visual');
|
||||
|
||||
// NOTE: global test value container to be mutated and checked across files, as needed
|
||||
|
||||
Reference in New Issue
Block a user