mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Merge branch '2.x' into 3.x
This commit is contained in:
1
tests/.cache/test-results
Normal file
1
tests/.cache/test-results
Normal file
@ -0,0 +1 @@
|
||||
{"version":"pest_2.32.2","defects":[],"times":{"P\\Tests\\Playground::__pest_evaluable_basic":0.005}}
|
||||
@ -0,0 +1 @@
|
||||
<input type="hidden" name="_token" value="1" />
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
Pest Testing Framework 3.0.0-dev-0004.
|
||||
Pest Testing Framework 3.0.0-dev-0005.
|
||||
|
||||
USAGE: pest <file> [options]
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
EXECUTION OPTIONS:
|
||||
--parallel ........................................... Run tests in parallel
|
||||
--update-snapshots Update snapshots for tests using the "toMatchSnapshot" expectation
|
||||
--process-isolation ................ Run each test in a separate PHP process
|
||||
--globals-backup ................. Backup and restore $GLOBALS for each test
|
||||
--static-backup ......... Backup and restore static properties for each test
|
||||
--strict-coverage ................... Be strict about code coverage metadata
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
|
||||
Pest Testing Framework 3.0.0-dev-0004.
|
||||
Pest Testing Framework 3.0.0-dev-0005.
|
||||
|
||||
|
||||
@ -151,6 +151,10 @@
|
||||
✓ it can correctly resolve a bound dataset that returns an array with (Closure)
|
||||
✓ it can correctly resolve a bound dataset that returns an array but wants to be spread with (Closure)
|
||||
↓ forbids to define tests in Datasets dirs and Datasets.php files
|
||||
✓ it may be used with high order with dataset "formal"
|
||||
✓ it may be used with high order with dataset "informal"
|
||||
✓ it may be used with high order even when bound with dataset "formal"
|
||||
✓ it may be used with high order even when bound with dataset "informal"
|
||||
|
||||
PASS Tests\Features\Depends
|
||||
✓ first
|
||||
@ -423,6 +427,7 @@
|
||||
PASS Tests\Features\Expect\toBeGreaterThan
|
||||
✓ passes
|
||||
✓ passes with DateTime and DateTimeImmutable
|
||||
✓ passes with strings
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
@ -430,6 +435,7 @@
|
||||
PASS Tests\Features\Expect\toBeGreaterThanOrEqual
|
||||
✓ passes
|
||||
✓ passes with DateTime and DateTimeImmutable
|
||||
✓ passes with strings
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
@ -458,6 +464,10 @@
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeIntBackedEnum
|
||||
✓ enum is backed by int
|
||||
✓ enum is not backed by int
|
||||
|
||||
PASS Tests\Features\Expect\toBeInvokable
|
||||
✓ class is invokable
|
||||
✓ opposite class is invokable
|
||||
@ -487,6 +497,7 @@
|
||||
PASS Tests\Features\Expect\toBeLessThan
|
||||
✓ passes
|
||||
✓ passes with DateTime and DateTimeImmutable
|
||||
✓ passes with strings
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
@ -494,6 +505,7 @@
|
||||
PASS Tests\Features\Expect\toBeLessThanOrEqual
|
||||
✓ passes
|
||||
✓ passes with DateTime and DateTimeImmutable
|
||||
✓ passes with strings
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
@ -564,6 +576,10 @@
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeStringBackedEnum
|
||||
✓ enum is backed by string
|
||||
✓ enum is not backed by string
|
||||
|
||||
PASS Tests\Features\Expect\toBeStudlyCase
|
||||
✓ pass
|
||||
✓ failures
|
||||
@ -634,6 +650,16 @@
|
||||
✓ failures with multiple needles (some failing)
|
||||
✓ not failures
|
||||
✓ not failures with multiple needles (all failing)
|
||||
✓ not failures with multiple needles (some failing)
|
||||
|
||||
PASS Tests\Features\Expect\toContainEqual
|
||||
✓ passes arrays
|
||||
✓ passes arrays with multiple needles
|
||||
✓ failures
|
||||
✓ failures with multiple needles (all failing)
|
||||
✓ failures with multiple needles (some failing)
|
||||
✓ not failures
|
||||
✓ not failures with multiple needles (all failing)
|
||||
✓ not failures with multiple needles (some failing)
|
||||
|
||||
PASS Tests\Features\Expect\toContainOnlyInstancesOf
|
||||
@ -827,6 +853,7 @@
|
||||
|
||||
PASS Tests\Features\Expect\toMatchSnapshot
|
||||
✓ pass
|
||||
✓ pass using pipes
|
||||
✓ pass with __toString
|
||||
✓ pass with toString
|
||||
✓ pass with dataset with ('my-datas-set-value')
|
||||
@ -1137,6 +1164,16 @@
|
||||
PASS Tests\Hooks\BeforeEachTest
|
||||
✓ global beforeEach execution order
|
||||
|
||||
PASS Tests\Overrides\VersionsTest
|
||||
✓ versions with dataset "Runner/Filter/NameFilterIterator.php"
|
||||
✓ versions with dataset "Runner/ResultCache/DefaultResultCache.php"
|
||||
✓ versions with dataset "Runner/TestSuiteLoader.php"
|
||||
✓ versions with dataset "TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php"
|
||||
✓ versions with dataset "TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php"
|
||||
✓ versions with dataset "TextUI/TestSuiteFilterProcessor.php"
|
||||
✓ versions with dataset "Event/Value/ThrowableBuilder.php"
|
||||
✓ versions with dataset "Logging/JUnit/JunitXmlLogger.php"
|
||||
|
||||
PASS Tests\PHPUnit\CustomAffixes\InvalidTestName
|
||||
✓ it runs file names like @#$%^&()-_=+.php
|
||||
|
||||
@ -1348,9 +1385,13 @@
|
||||
PASS Tests\Visual\Help
|
||||
✓ visual snapshot of help command output
|
||||
|
||||
WARN Tests\Visual\Parallel
|
||||
- parallel → Waiting for Parallel to be stable
|
||||
- a parallel test can extend another test with same name → Waiting for Parallel to be stable
|
||||
PASS Tests\Visual\JUnit
|
||||
✓ junit output
|
||||
✓ junit with parallel
|
||||
|
||||
PASS Tests\Visual\Parallel
|
||||
✓ parallel
|
||||
✓ a parallel test can extend another test with same name
|
||||
|
||||
PASS Tests\Visual\SingleTestOrDirectory
|
||||
✓ allows to run a single test
|
||||
@ -1373,4 +1414,4 @@
|
||||
WARN Tests\Visual\Version
|
||||
- visual snapshot of help command output
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 24 skipped, 970 passed (2295 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 24 skipped, 970 passed (2295 assertions)
|
||||
|
||||
@ -361,3 +361,23 @@ it('can correctly resolve a bound dataset that returns an array but wants to be
|
||||
]);
|
||||
|
||||
todo('forbids to define tests in Datasets dirs and Datasets.php files');
|
||||
|
||||
dataset('greeting-string', [
|
||||
'formal' => 'Evening',
|
||||
'informal' => 'yo',
|
||||
]);
|
||||
|
||||
it('may be used with high order')
|
||||
->with('greeting-string')
|
||||
->expect(fn (string $greeting) => $greeting)
|
||||
->throwsNoExceptions();
|
||||
|
||||
dataset('greeting-bound', [
|
||||
'formal' => fn () => 'Evening',
|
||||
'informal' => fn () => 'yo',
|
||||
]);
|
||||
|
||||
it('may be used with high order even when bound')
|
||||
->with('greeting-bound')
|
||||
->expect(fn (string $greeting) => $greeting)
|
||||
->throws(InvalidArgumentException::class);
|
||||
|
||||
@ -16,6 +16,11 @@ test('passes with DateTime and DateTimeImmutable', function () {
|
||||
expect($past)->not->toBeGreaterThan($now);
|
||||
});
|
||||
|
||||
test('passes with strings', function () {
|
||||
expect('b')->toBeGreaterThan('a');
|
||||
expect('a')->not->toBeGreaterThan('a');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect(4)->toBeGreaterThan(4);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -18,6 +18,11 @@ test('passes with DateTime and DateTimeImmutable', function () {
|
||||
expect($past)->not->toBeGreaterThanOrEqual($now);
|
||||
});
|
||||
|
||||
test('passes with strings', function () {
|
||||
expect('b')->toBeGreaterThanOrEqual('a');
|
||||
expect('a')->toBeGreaterThanOrEqual('a');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect(4)->toBeGreaterThanOrEqual(4.1);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
9
tests/Features/Expect/toBeIntBackedEnum.php
Normal file
9
tests/Features/Expect/toBeIntBackedEnum.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
test('enum is backed by int')
|
||||
->expect('Tests\Fixtures\Arch\ToBeIntBackedEnum\HasIntBacking')
|
||||
->toBeIntBackedEnum();
|
||||
|
||||
test('enum is not backed by int')
|
||||
->expect('Tests\Fixtures\Arch\ToBeIntBackedEnum\HasStringBacking')
|
||||
->not->toBeIntBackedEnum();
|
||||
@ -16,6 +16,11 @@ test('passes with DateTime and DateTimeImmutable', function () {
|
||||
expect($now)->not->toBeLessThan($now);
|
||||
});
|
||||
|
||||
test('passes with strings', function () {
|
||||
expect('a')->toBeLessThan('b');
|
||||
expect('a')->not->toBeLessThan('a');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect(4)->toBeLessThan(4);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -18,6 +18,11 @@ test('passes with DateTime and DateTimeImmutable', function () {
|
||||
expect($now)->not->toBeLessThanOrEqual($past);
|
||||
});
|
||||
|
||||
test('passes with strings', function () {
|
||||
expect('a')->toBeLessThanOrEqual('b');
|
||||
expect('a')->toBeLessThanOrEqual('a');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect(4)->toBeLessThanOrEqual(3.9);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
9
tests/Features/Expect/toBeStringBackedEnum.php
Normal file
9
tests/Features/Expect/toBeStringBackedEnum.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
test('enum is backed by string')
|
||||
->expect('Tests\Fixtures\Arch\ToBeStringBackedEnum\HasStringBacking')
|
||||
->toBeStringBackedEnum();
|
||||
|
||||
test('enum is not backed by string')
|
||||
->expect('Tests\Fixtures\Arch\ToBeStringBackedEnum\HasIntBacking')
|
||||
->not->toBeStringBackedEnum();
|
||||
35
tests/Features/Expect/toContainEqual.php
Normal file
35
tests/Features/Expect/toContainEqual.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('passes arrays', function () {
|
||||
expect([1, 2, 42])->toContainEqual('42');
|
||||
});
|
||||
|
||||
test('passes arrays with multiple needles', function () {
|
||||
expect([1, 2, 42])->toContainEqual('42', '2');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect([1, 2, 42])->toContainEqual('3');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with multiple needles (all failing)', function () {
|
||||
expect([1, 2, 42])->toContainEqual('3', '4');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with multiple needles (some failing)', function () {
|
||||
expect([1, 2, 42])->toContainEqual('1', '3', '4');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect([1, 2, 42])->not->toContainEqual('42');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures with multiple needles (all failing)', function () {
|
||||
expect([1, 2, 42])->not->toContainEqual('42', '2');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures with multiple needles (some failing)', function () {
|
||||
expect([1, 2, 42])->not->toContainEqual('42', '1');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
@ -21,6 +21,23 @@ test('pass', function () {
|
||||
expect($this->snapshotable)->toMatchSnapshot();
|
||||
});
|
||||
|
||||
expect()->pipe('toMatchSnapshot', function (Closure $next) {
|
||||
if (is_string($this->value)) {
|
||||
$this->value = preg_replace(
|
||||
'/name="_token" value=".*"/',
|
||||
'name="_token" value="1"',
|
||||
$this->value
|
||||
);
|
||||
}
|
||||
|
||||
return $next();
|
||||
});
|
||||
|
||||
test('pass using pipes', function () {
|
||||
expect('<input type="hidden" name="_token" value="'.random_int(1, 999).'" />')
|
||||
->toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('pass with `__toString`', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
||||
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Fixtures\Arch\ToBeIntBackedEnum\HasIntBacking;
|
||||
|
||||
enum HasIntBackingEnum: int
|
||||
{
|
||||
case IntBacked = 1;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Fixtures\Arch\ToBeIntBackedEnum\HasStringBacking;
|
||||
|
||||
enum HasStringBackingEnum: string
|
||||
{
|
||||
case StringBacked = 'Testing';
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Fixtures\Arch\ToBeStringBackedEnum\HasIntBacking;
|
||||
|
||||
enum HasIntBackingEnum: int
|
||||
{
|
||||
case IntBacked = 1;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Fixtures\Arch\ToBeStringBackedEnum\HasStringBacking;
|
||||
|
||||
enum HasStringBackingEnum: string
|
||||
{
|
||||
case StringBacked = 'Testing';
|
||||
}
|
||||
@ -4,16 +4,16 @@ uses()->afterEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('ith')
|
||||
->and($this->ith)
|
||||
->toBe(0);
|
||||
->toBe(1);
|
||||
|
||||
$this->ith = 1;
|
||||
$this->ith = 2;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('ith')
|
||||
->and($this->ith)
|
||||
->toBe(1);
|
||||
->toBe(2);
|
||||
});
|
||||
|
||||
test('global afterEach execution order', function () {
|
||||
|
||||
@ -1,15 +1,6 @@
|
||||
<?php
|
||||
|
||||
uses()->beforeEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('baz')
|
||||
->and($this->baz)
|
||||
->toBe(0);
|
||||
|
||||
$this->baz = 1;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('baz')
|
||||
->and($this->baz)
|
||||
@ -18,9 +9,18 @@ beforeEach(function () {
|
||||
$this->baz = 2;
|
||||
});
|
||||
|
||||
test('global beforeEach execution order', function () {
|
||||
beforeEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('baz')
|
||||
->and($this->baz)
|
||||
->toBe(2);
|
||||
|
||||
$this->baz = 3;
|
||||
});
|
||||
|
||||
test('global beforeEach execution order', function () {
|
||||
expect($this)
|
||||
->toHaveProperty('baz')
|
||||
->and($this->baz)
|
||||
->toBe(3);
|
||||
});
|
||||
|
||||
18
tests/Overrides/VersionsTest.php
Normal file
18
tests/Overrides/VersionsTest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Pest\Bootstrappers\BootOverrides;
|
||||
|
||||
test('versions', function (string $vendorPath, string $expectedHash) {
|
||||
expect(hash_file('sha256', $vendorPath))->toBe($expectedHash);
|
||||
})->with(function () {
|
||||
foreach (BootOverrides::FILES as $hash => $file) {
|
||||
$path = implode(DIRECTORY_SEPARATOR, [
|
||||
dirname(__DIR__, 2),
|
||||
'vendor/phpunit/phpunit/src',
|
||||
$file,
|
||||
]);
|
||||
yield $file => [$path, $hash];
|
||||
}
|
||||
});
|
||||
@ -3,6 +3,8 @@
|
||||
use Tests\CustomTestCase\CustomTestCase;
|
||||
use Tests\CustomTestCaseInSubFolders\SubFolder\SubFolder\CustomTestCaseInSubFolder;
|
||||
|
||||
$GLOBALS['__PEST_INTERNAL_TEST_SUITE'] = true;
|
||||
|
||||
uses(CustomTestCaseInSubFolder::class)->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder');
|
||||
|
||||
// test case for all the directories inside PHPUnit/GlobPatternTests/SubFolder/
|
||||
@ -33,9 +35,49 @@ uses()
|
||||
})
|
||||
->in('Hooks');
|
||||
|
||||
uses()
|
||||
->beforeEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('baz')
|
||||
->and($this->baz)
|
||||
->toBe(0);
|
||||
|
||||
$this->baz = 1;
|
||||
})
|
||||
->beforeAll(function () {
|
||||
expect($_SERVER['globalHook'])
|
||||
->toHaveProperty('beforeAll')
|
||||
->and($_SERVER['globalHook']->beforeAll)
|
||||
->toBe(0);
|
||||
|
||||
$_SERVER['globalHook']->beforeAll = 1;
|
||||
})
|
||||
->afterEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('ith')
|
||||
->and($this->ith)
|
||||
->toBe(0);
|
||||
|
||||
$this->ith = 1;
|
||||
})
|
||||
->afterAll(function () {
|
||||
expect($_SERVER['globalHook'])
|
||||
->toHaveProperty('afterAll')
|
||||
->and($_SERVER['globalHook']->afterAll)
|
||||
->toBe(0);
|
||||
|
||||
$_SERVER['globalHook']->afterAll = 1;
|
||||
})
|
||||
->in('Hooks');
|
||||
|
||||
function helper_returns_string()
|
||||
{
|
||||
return 'string';
|
||||
}
|
||||
|
||||
dataset('dataset_in_pest_file', ['A', 'B']);
|
||||
|
||||
function removeAnsiEscapeSequences(string $input): ?string
|
||||
{
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $input);
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ test('collision', function (array $arguments) {
|
||||
|
||||
$process->run();
|
||||
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
return removeAnsiEscapeSequences($process->getOutput());
|
||||
};
|
||||
|
||||
$outputContent = explode("\n", $output());
|
||||
|
||||
@ -6,7 +6,7 @@ test('visual snapshot of help command output', function () {
|
||||
|
||||
$process->run();
|
||||
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
return removeAnsiEscapeSequences($process->getOutput());
|
||||
};
|
||||
|
||||
expect($output())->toMatchSnapshot();
|
||||
|
||||
79
tests/Visual/JUnit.php
Normal file
79
tests/Visual/JUnit.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
$run = function () {
|
||||
$junitLogFile = tempnam(sys_get_temp_dir(), 'junit');
|
||||
|
||||
$process = new Process(
|
||||
array_merge(['php', 'bin/pest', '--log-junit', $junitLogFile], func_get_args()),
|
||||
dirname(__DIR__, 2),
|
||||
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
|
||||
);
|
||||
|
||||
$process->run();
|
||||
|
||||
$rawXmlContent = file_get_contents($junitLogFile);
|
||||
unlink($junitLogFile);
|
||||
|
||||
// convert xml to array
|
||||
try {
|
||||
$xml = new SimpleXMLElement(preg_replace("/(<\/?)(\w+):([^>]*>)/", '$1$2$3', $rawXmlContent));
|
||||
|
||||
return json_decode(json_encode((array) $xml), true);
|
||||
} catch (Exception $exception) {
|
||||
throw new XmlParseException($exception->getMessage(), $exception->getCode(), $exception->getPrevious());
|
||||
}
|
||||
};
|
||||
|
||||
$normalizedPath = function (string $path) {
|
||||
return str_replace('/', DIRECTORY_SEPARATOR, $path);
|
||||
};
|
||||
|
||||
test('junit output', function () use ($normalizedPath, $run) {
|
||||
$result = $run('tests/.tests/SuccessOnly.php');
|
||||
|
||||
expect($result['testsuite']['@attributes'])
|
||||
->name->toBe('Tests\tests\SuccessOnly')
|
||||
->file->toBe($normalizedPath('tests/.tests/SuccessOnly.php'))
|
||||
->tests->toBe('2')
|
||||
->assertions->toBe('2')
|
||||
->errors->toBe('0')
|
||||
->failures->toBe('0')
|
||||
->skipped->toBe('0');
|
||||
|
||||
expect($result['testsuite']['testcase'])
|
||||
->toHaveCount(2);
|
||||
|
||||
expect($result['testsuite']['testcase'][0]['@attributes'])
|
||||
->name->toBe('it can pass with comparison')
|
||||
->file->toBe($normalizedPath('tests/.tests/SuccessOnly.php::it can pass with comparison'))
|
||||
->class->toBe('Tests\tests\SuccessOnly')
|
||||
->classname->toBe('Tests.tests.SuccessOnly')
|
||||
->assertions->toBe('1')
|
||||
->time->toStartWith('0.0');
|
||||
});
|
||||
|
||||
test('junit with parallel', function () use ($normalizedPath, $run) {
|
||||
$result = $run('tests/.tests/SuccessOnly.php', '--parallel', '--processes=1', '--filter', 'can pass with comparison');
|
||||
|
||||
expect($result['testsuite']['@attributes'])
|
||||
->name->toBe('Tests\tests\SuccessOnly')
|
||||
->file->toBe($normalizedPath('tests/.tests/SuccessOnly.php'))
|
||||
->tests->toBe('1')
|
||||
->assertions->toBe('1')
|
||||
->errors->toBe('0')
|
||||
->failures->toBe('0')
|
||||
->skipped->toBe('0');
|
||||
|
||||
expect($result['testsuite']['testcase'])
|
||||
->toHaveCount(1);
|
||||
|
||||
expect($result['testsuite']['testcase']['@attributes'])
|
||||
->name->toBe('it can pass with comparison')
|
||||
->file->toBe($normalizedPath('tests/.tests/SuccessOnly.php::it can pass with comparison'))
|
||||
->class->toBe('Tests\tests\SuccessOnly')
|
||||
->classname->toBe('Tests.tests.SuccessOnly')
|
||||
->assertions->toBe('1')
|
||||
->time->toStartWith('0.0');
|
||||
});
|
||||
@ -13,12 +13,12 @@ $run = function () {
|
||||
|
||||
$process->run();
|
||||
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
return removeAnsiEscapeSequences($process->getOutput());
|
||||
};
|
||||
|
||||
test('parallel', function () use ($run) {
|
||||
expect($run('--exclude-group=integration'))
|
||||
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 965 passed (2285 assertions)')
|
||||
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 994 passed (2348 assertions)')
|
||||
->toContain('Parallel: 3 processes');
|
||||
})->skipOnWindows();
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ $run = function (string $target, $decorated = false) {
|
||||
|
||||
$process->run();
|
||||
|
||||
return $decorated ? $process->getOutput() : preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
return $decorated ? $process->getOutput() : removeAnsiEscapeSequences($process->getOutput());
|
||||
};
|
||||
|
||||
$snapshot = function ($name) {
|
||||
|
||||
@ -11,9 +11,7 @@ $run = function (string $target, bool $parallel) {
|
||||
|
||||
expect($process->getExitCode())->toBe(0);
|
||||
|
||||
$outputContent = preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
|
||||
return $outputContent;
|
||||
return removeAnsiEscapeSequences($process->getOutput());
|
||||
};
|
||||
|
||||
$snapshot = function ($name) {
|
||||
|
||||
@ -6,7 +6,7 @@ test('visual snapshot of help command output', function () {
|
||||
|
||||
$process->run();
|
||||
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
return removeAnsiEscapeSequences($process->getOutput());
|
||||
};
|
||||
|
||||
expect($output())->toMatchSnapshot();
|
||||
|
||||
Reference in New Issue
Block a user