Skip to content

Commit

Permalink
test: replace phpunit -> pest
Browse files Browse the repository at this point in the history
  • Loading branch information
guanguans committed Jan 15, 2024
1 parent 85c8057 commit fa936ae
Show file tree
Hide file tree
Showing 14 changed files with 462 additions and 485 deletions.
20 changes: 11 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,20 @@
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.8 || ^3.0",
"composer/composer": "^2.6",
"dms/phpunit-arraysubset-asserts": "^0.5",
"ergebnis/composer-normalize": "^2.20",
"friendsofphp/php-cs-fixer": "^3.4",
"guanguans/ai-commit": "dev-main",
"guanguans/monorepo-builder-worker": "^1.4",
"jetbrains/phpstorm-attributes": "^1.0",
"johnkary/phpunit-speedtrap": "^4.0",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.7",
"mockery/mockery": "^1.6",
"pestphp/pest": "^1.23 || ^2.0",
"pestphp/pest-plugin-faker": "^1.0 || ^2.0",
"php-mock/php-mock-phpunit": "^2.9",
"phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpunit/phpunit": "^9.6 || ^10.0",
"rector/rector": "^0.19",
"spatie/phpunit-snapshot-assertions": "^4.2",
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0",
Expand All @@ -70,7 +69,7 @@
},
"autoload-dev": {
"psr-4": {
"Guanguans\\Tests\\": "tests"
"Guanguans\\SoarPHPTests\\": "tests"
}
},
"bin": [
Expand All @@ -83,6 +82,7 @@
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
},
"apcu-autoloader": true,
Expand Down Expand Up @@ -158,8 +158,8 @@
"mark-start": "printf '\\n!\\n!\\t\\033[0;36m%s\\033[0m\\n!\\n\\n' \"Started\"",
"md-fix": "@md-lint --fix",
"md-lint": "lint-md --config .lintmdrc ./*.md ./.github/ ./docs/",
"pest": "@php ./vendor/bin/pest",
"pest-coverage": "@pest --coverage-html=./build/phpunit/ --coverage-clover=clover.xml --coverage",
"pest": "@php ./vendor/bin/pest --coverage",
"pest-coverage": "@pest --coverage-html=./build/phpunit/ --coverage-clover=./clover.xml",
"pest-migrate-configuration": "@pest --migrate-configuration",
"phpstan": "@php ./vendor/bin/phpstan analyse --ansi -v",
"phpstan-baseline": "@phpstan --generate-baseline --allow-empty-baseline",
Expand All @@ -179,9 +179,11 @@
"release-patch-dry-run": "@release-patch --dry-run",
"style-fix": "@php ./vendor/bin/php-cs-fixer fix --using-cache=yes --config=.php-cs-fixer.php --ansi -v",
"style-lint": "@style-fix --diff --dry-run",
"test": "@php ./vendor/bin/phpunit --coverage-text -v",
"test-coverage": "@test --coverage-html=./build/phpunit/ --coverage-clover=clover.xml",
"test-migrate-configuration": "@test --migrate-configuration",
"test": "@pest",
"test-coverage": "@pest-coverage",
"test-migrate-configuration": "@pest-migrate-configuration",
"test-phpunit": "@php ./vendor/bin/phpunit --cache-result-file=./build/phpunit/.phpunit.result.cache --coverage-text --ansi -v",
"test-phpunit-coverage": "@test --coverage-html=./build/phpunit/ --coverage-clover=clover.xml",
"yaml-lint": "@php ./vendor/bin/yaml-lint .github --ansi -v"
}
}
10 changes: 6 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
executionOrder="depends,defects"
executionOrder="random"
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
processIsolation="false"
resolveDependencies="true"
stopOnFailure="false"
testdox="true"
testdox="false"
verbose="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
Expand All @@ -31,7 +33,7 @@
</testsuite>
</testsuites>
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
<!--<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
<arguments>
<array>
<element key="slowThreshold">
Expand All @@ -45,6 +47,6 @@
</element>
</array>
</arguments>
</listener>
</listener>-->
</listeners>
</phpunit>
58 changes: 22 additions & 36 deletions tests/Concerns/ConcreteMagicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,27 @@
* This source file is subject to the MIT license that is bundled.
*/

namespace Guanguans\Tests\Concerns;

use Guanguans\SoarPHP\Soar;
use Guanguans\Tests\TestCase;

/**
* @internal
*
* @small
*/
class ConcreteMagicTest extends TestCase
{
public function testSleep(): void
{
$soar = Soar::create(require __DIR__.'/../../examples/soar.options.full.php');
$serializedSoar = serialize($soar);
$unserializedSoar = unserialize($serializedSoar);

$this->assertInstanceOf(Soar::class, $unserializedSoar);
$this->assertNotEmpty($unserializedSoar->getSoarBinary());
$this->assertNotEmpty($unserializedSoar->getOptions());
}

/**
* @noinspection DebugFunctionUsageInspection
*/
public function testSetState(): void
{
$soar = Soar::create(require __DIR__.'/../../examples/soar.options.full.php');
$exportedSoarStr = var_export($soar, true);
$exportedSoar = null;
eval("\$exportedSoar = $exportedSoarStr;");

$this->assertInstanceOf(Soar::class, $exportedSoar);
$this->assertNotEmpty($exportedSoar->getSoarBinary());
$this->assertNotEmpty($exportedSoar->getOptions());
}
}
uses(Guanguans\SoarPHPTests\TestCase::class);

test('sleep', function (): void {
$soar = Soar::create(require __DIR__.'/../../examples/soar.options.full.php');
$serializedSoar = serialize($soar);
$unserializedSoar = unserialize($serializedSoar);

expect($unserializedSoar)->toBeInstanceOf(Soar::class);
expect($unserializedSoar->getSoarBinary())->not->toBeEmpty();
expect($unserializedSoar->getOptions())->not->toBeEmpty();
});

test('set state', function (): void {
$soar = Soar::create(require __DIR__.'/../../examples/soar.options.full.php');
$exportedSoarStr = var_export($soar, true);
$exportedSoar = null;
eval("\$exportedSoar = $exportedSoarStr;");

expect($exportedSoar)->toBeInstanceOf(Soar::class);
expect($exportedSoar->getSoarBinary())->not->toBeEmpty();
expect($exportedSoar->getOptions())->not->toBeEmpty();
});
Loading

0 comments on commit fa936ae

Please sign in to comment.