mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Merge branch 'develop' into 2.x
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"key": " <div class=\"container\">\n <div class=\"row\">\n <div class=\"col-md-12\">\n <h1>Snapshot<\/h1>\n <\/div>\n <\/div>\n <\/div>"
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"key": " <div class=\"container\">\n <div class=\"row\">\n <div class=\"col-md-12\">\n <h1>Snapshot<\/h1>\n <\/div>\n <\/div>\n <\/div>"
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
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
|
||||
@ -1,60 +0,0 @@
|
||||
|
||||
PASS Tests\Playground
|
||||
✓ basic
|
||||
|
||||
Tests: 1 passed
|
||||
Time: 0.20s
|
||||
Cov: 6.49%
|
||||
|
||||
Actions/AddsDefaults ........................................... 0.0 %
|
||||
Actions/AddsTests .............................................. 0.0 %
|
||||
Actions/LoadStructure .......................................... 0.0 %
|
||||
Actions/ValidatesConfiguration ................................. 0.0 %
|
||||
Actions/ValidatesEnvironment ................................... 0.0 %
|
||||
Concerns/TestCase 40..54, 71..88, 123..126, 147 ............... 44.4 %
|
||||
Console/Command ................................................ 0.0 %
|
||||
Contracts/HasPrintableTestCaseName ............................. 0.0 %
|
||||
Contracts/Plugins/AddsOutput ................................ 100.0 %
|
||||
Contracts/Plugins/HandlesArguments .......................... 100.0 %
|
||||
Datasets ....................................................... 0.0 %
|
||||
Exceptions/AfterAllAlreadyExist ................................ 0.0 %
|
||||
Exceptions/AfterEachAlreadyExist ............................... 0.0 %
|
||||
Exceptions/AttributeNotSupportedYet ............................ 0.0 %
|
||||
Exceptions/BeforeEachAlreadyExist .............................. 0.0 %
|
||||
Exceptions/DatasetAlreadyExist ................................. 0.0 %
|
||||
Exceptions/DatasetDoesNotExist ................................. 0.0 %
|
||||
Exceptions/FileOrFolderNotFound ................................ 0.0 %
|
||||
Exceptions/InvalidConsoleArgument .............................. 0.0 %
|
||||
Exceptions/InvalidPestCommand .................................. 0.0 %
|
||||
Exceptions/InvalidUsesPath ..................................... 0.0 %
|
||||
Exceptions/ShouldNotHappen ..................................... 0.0 %
|
||||
Exceptions/TestAlreadyExist .................................... 0.0 %
|
||||
Exceptions/TestCaseAlreadyInUse ................................ 0.0 %
|
||||
Exceptions/TestCaseClassOrTraitNotFound ........................ 0.0 %
|
||||
Factories/TestCaseFactory 111..133, 141..204 ................... 8.2 %
|
||||
Laravel/Commands/PestDatasetCommand ............................ 0.0 %
|
||||
Laravel/Commands/PestInstallCommand ............................ 0.0 %
|
||||
Laravel/Commands/PestTestCommand ............................... 0.0 %
|
||||
Laravel/PestServiceProvider .................................... 0.0 %
|
||||
PendingObjects/AfterEachCall ................................... 0.0 %
|
||||
PendingObjects/BeforeEachCall .................................. 0.0 %
|
||||
PendingObjects/TestCall ........................................ 0.0 %
|
||||
PendingObjects/UsesCall ........................................ 0.0 %
|
||||
Plugin ......................................................... 0.0 %
|
||||
Repositories/AfterAllRepository ................................ 0.0 %
|
||||
Repositories/AfterEachRepository 28..33 ....................... 60.0 %
|
||||
Repositories/BeforeAllRepository ............................... 0.0 %
|
||||
Repositories/BeforeEachRepository 26..31 ...................... 20.0 %
|
||||
Repositories/TestRepository .................................... 0.0 %
|
||||
Support/Backtrace .............................................. 0.0 %
|
||||
Support/ChainableClosure .................................... 100.0 %
|
||||
Support/Container .............................................. 0.0 %
|
||||
Support/ExceptionTrace 25..32 ................................. 28.6 %
|
||||
Support/HigherOrderMessage ..................................... 0.0 %
|
||||
Support/HigherOrderMessageCollection 24..25, 33, 43 ........... 50.0 %
|
||||
Support/HigherOrderTapProxy .................................... 0.0 %
|
||||
Support/NullClosure ......................................... 100.0 %
|
||||
Support/Reflection ............................................. 0.0 %
|
||||
Support/Str .................................................... 0.0 %
|
||||
TestSuite 80..87, 95..101, 105 ................................ 20.0 %
|
||||
globals ........................................................ 0.0 %
|
||||
@ -53,6 +53,7 @@
|
||||
✓ it appends CoversNothing to method attributes
|
||||
✓ it does not append CoversNothing to other methods
|
||||
✓ it throws exception if no class nor method has been found
|
||||
✓ a "describe" group of tests → it does not append CoversNothing to method attributes
|
||||
|
||||
PASS Tests\Features\DatasetsTests - 1 todo
|
||||
✓ it throws exception if dataset does not exist
|
||||
@ -172,6 +173,29 @@
|
||||
! deprecated → str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated // tests/Features/Deprecated.php:6
|
||||
! user deprecated → Since foo 1.0: This is a deprecation description // vendor/symfony/deprecation-contracts/function.php:25
|
||||
|
||||
PASS Tests\Features\Describe - 5 todos
|
||||
✓ before each
|
||||
✓ hooks → value
|
||||
✓ hooks in different orders → value
|
||||
↓ todo
|
||||
✓ previous describable before each does not get applied here
|
||||
↓ todo on hook → should not fail
|
||||
↓ todo on hook → should run
|
||||
↓ todo on describe → should not fail
|
||||
↓ todo on describe → should run
|
||||
✓ should run
|
||||
✓ with with (1)
|
||||
✓ with on hook → value with (2)
|
||||
✓ with on describe → value with (3)
|
||||
|
||||
PASS Tests\Features\DescriptionLess
|
||||
✓ get 'foo'
|
||||
✓ get 'foo' → get 'bar' → expect true → toBeTrue
|
||||
✓ get 'foo' → expect true → toBeTrue
|
||||
✓ a "describe" group of tests → get 'foo'
|
||||
✓ a "describe" group of tests → get 'foo' → get 'bar' → expect true → toBeTrue
|
||||
✓ a "describe" group of tests → get 'foo' → expect true → toBeTrue
|
||||
|
||||
PASS Tests\Features\Exceptions
|
||||
✓ it gives access the the underlying expectException
|
||||
✓ it catch exceptions
|
||||
@ -641,6 +665,18 @@
|
||||
✓ pass with class
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toMatchSnapshot
|
||||
✓ pass
|
||||
✓ pass with __toString
|
||||
✓ pass with toString
|
||||
✓ pass with dataset with ('my-datas-set-value')
|
||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||
✓ pass with toArray
|
||||
✓ pass with array
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toStartWith
|
||||
@ -714,18 +750,17 @@
|
||||
✓ it is not incompleted because of expect
|
||||
✓ it is not incompleted because of assert
|
||||
✓ it is not incompleted because of test with assertions
|
||||
… a "describe" group of tests → it is incompleted
|
||||
|
||||
PASS Tests\Features\It
|
||||
✓ it is a test
|
||||
✓ it is a higher order message test
|
||||
✓ a "describe" group of tests → it is a test
|
||||
✓ a "describe" group of tests → it is a higher order message test
|
||||
|
||||
NOTI Tests\Features\Notices
|
||||
! notice → This is a notice description // tests/Features/Notices.php:4
|
||||
|
||||
PASS Tests\Features\PendingHigherOrderTests
|
||||
✓ get 'foo'
|
||||
✓ get 'foo' → get 'bar' → expect true → toBeTrue
|
||||
✓ get 'foo' → expect true → toBeTrue
|
||||
! a "describe" group of tests → notice → This is a notice description // tests/Features/Notices.php:11
|
||||
|
||||
PASS Tests\Features\ScopedDatasets\Directory\NestedDirectory1\TestFileInNestedDirectoryWithDatasetsFile
|
||||
✓ uses dataset with (1)
|
||||
@ -787,6 +822,7 @@
|
||||
PASS Tests\Features\ThrowsNoExceptions
|
||||
✓ it allows access to the underlying expectNotToPerformAssertions method
|
||||
✓ it allows performing no expectations without being risky
|
||||
✓ a "describe" group of tests → it allows performing no expectations without being risky
|
||||
|
||||
PASS Tests\Features\Todo - 3 todos
|
||||
↓ something todo later
|
||||
@ -797,6 +833,7 @@
|
||||
WARN Tests\Features\Warnings
|
||||
! warning → Undefined property: P\Tests\Features\Warnings::$fooqwdfwqdfqw
|
||||
! user warning → This is a warning description
|
||||
! a "describe" group of tests → user warning → This is a warning description
|
||||
|
||||
WARN Tests\Fixtures\CollisionTest
|
||||
- error
|
||||
@ -1044,7 +1081,7 @@
|
||||
✓ todo
|
||||
✓ todo in parallel
|
||||
|
||||
PASS Tests\Visual\Version
|
||||
✓ visual snapshot of help command output
|
||||
WARN Tests\Visual\Version
|
||||
- visual snapshot of help command output
|
||||
|
||||
Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 8 todos, 18 skipped, 718 passed (1735 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 742 passed (1787 assertions)
|
||||
@ -7,6 +7,13 @@
|
||||
TODO Tests\Features\DatasetsTests - 1 todo
|
||||
↓ forbids to define tests in Datasets dirs and Datasets.php files
|
||||
|
||||
TODO Tests\Features\Describe - 5 todos
|
||||
↓ todo
|
||||
↓ todo on hook → should not fail
|
||||
↓ todo on hook → should run
|
||||
↓ todo on describe → should not fail
|
||||
↓ todo on describe → should run
|
||||
|
||||
TODO Tests\Features\Todo - 3 todos
|
||||
↓ something todo later
|
||||
↓ something todo later chained
|
||||
@ -15,4 +22,4 @@
|
||||
PASS Tests\CustomTestCase\ExecutedTest
|
||||
✓ that gets executed
|
||||
|
||||
Tests: 8 todos, 1 passed (1 assertions)
|
||||
Tests: 13 todos, 1 passed (1 assertions)
|
||||
|
||||
@ -30,4 +30,4 @@ test('contracts')
|
||||
'NunoMaduro\Collision\Contracts',
|
||||
'Pest\Factories\TestCaseMethodFactory',
|
||||
'Symfony\Component\Console',
|
||||
]);
|
||||
])->toBeInterfaces();
|
||||
|
||||
@ -7,7 +7,11 @@ beforeEach(function () use ($state) {
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
$this->state->bar = 2;
|
||||
$this->state->bar = 1;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
unset($this->state->bar);
|
||||
});
|
||||
|
||||
it('does not get executed before the test', function () {
|
||||
@ -18,3 +22,7 @@ it('gets executed after the test', function () {
|
||||
expect($this->state)->toHaveProperty('bar');
|
||||
expect($this->state->bar)->toBe(2);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
$this->state->bar = 2;
|
||||
});
|
||||
|
||||
@ -4,12 +4,24 @@ beforeEach(function () {
|
||||
$this->bar = 2;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->bar++;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->bar = 0;
|
||||
});
|
||||
|
||||
it('gets executed before each test', function () {
|
||||
expect($this->bar)->toBe(2);
|
||||
expect($this->bar)->toBe(1);
|
||||
|
||||
$this->bar = 'changed';
|
||||
});
|
||||
|
||||
it('gets executed before each test once again', function () {
|
||||
expect($this->bar)->toBe(2);
|
||||
expect($this->bar)->toBe(1);
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->bar++;
|
||||
});
|
||||
|
||||
@ -68,3 +68,11 @@ it('throws exception if no class nor method has been found', function () {
|
||||
|
||||
$testCall->covers('fakeName');
|
||||
})->throws(InvalidArgumentException::class, 'No class or method named "fakeName" has been found.');
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
it('does not append CoversNothing to method attributes', function () {
|
||||
$phpDoc = (new ReflectionClass($this))->getMethod($this->name());
|
||||
|
||||
expect(str_contains($phpDoc->getDocComment(), '* @coversNothing'))->toBeTrue();
|
||||
});
|
||||
})->coversNothing();
|
||||
|
||||
78
tests/Features/Describe.php
Normal file
78
tests/Features/Describe.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
beforeEach(fn () => $this->count = 1);
|
||||
|
||||
test('before each', function () {
|
||||
expect($this->count)->toBe(1);
|
||||
});
|
||||
|
||||
describe('hooks', function () {
|
||||
beforeEach(function () {
|
||||
$this->count++;
|
||||
});
|
||||
|
||||
test('value', function () {
|
||||
expect($this->count)->toBe(2);
|
||||
$this->count++;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
expect($this->count)->toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('hooks in different orders', function () {
|
||||
beforeEach(function () {
|
||||
$this->count++;
|
||||
});
|
||||
|
||||
test('value', function () {
|
||||
expect($this->count)->toBe(3);
|
||||
$this->count++;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
expect($this->count)->toBe(4);
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->count++;
|
||||
});
|
||||
});
|
||||
|
||||
test('todo')->todo()->shouldNotRun();
|
||||
|
||||
test('previous describable before each does not get applied here', function () {
|
||||
expect($this->count)->toBe(1);
|
||||
});
|
||||
|
||||
describe('todo on hook', function () {
|
||||
beforeEach()->todo();
|
||||
|
||||
test('should not fail')->shouldNotRun();
|
||||
test('should run')->expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
describe('todo on describe', function () {
|
||||
test('should not fail')->shouldNotRun();
|
||||
|
||||
test('should run')->expect(true)->toBeTrue();
|
||||
})->todo();
|
||||
|
||||
test('should run')->expect(true)->toBeTrue();
|
||||
|
||||
test('with', fn ($foo) => expect($foo)->toBe(1))->with([1]);
|
||||
|
||||
describe('with on hook', function () {
|
||||
beforeEach()->with([2]);
|
||||
|
||||
test('value', function ($foo) {
|
||||
expect($foo)->toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with on describe', function () {
|
||||
test('value', function ($foo) {
|
||||
expect($foo)->toBe(3);
|
||||
});
|
||||
})->with([3]);
|
||||
@ -29,3 +29,9 @@ trait Gettable
|
||||
get('foo'); // not incomplete because closure is created...
|
||||
get('foo')->get('bar')->expect(true)->toBeTrue();
|
||||
get('foo')->expect(true)->toBeTrue();
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
get('foo'); // not incomplete because closure is created...
|
||||
get('foo')->get('bar')->expect(true)->toBeTrue();
|
||||
get('foo')->expect(true)->toBeTrue();
|
||||
});
|
||||
122
tests/Features/Expect/toMatchSnapshot.php
Normal file
122
tests/Features/Expect/toMatchSnapshot.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
use Pest\TestSuite;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->snapshotable = <<<'HTML'
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Snapshot</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
HTML;
|
||||
});
|
||||
|
||||
test('pass', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this, $this->snapshotable);
|
||||
|
||||
expect($this->snapshotable)->toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('pass with `__toString`', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this, $this->snapshotable);
|
||||
|
||||
$object = new class($this->snapshotable)
|
||||
{
|
||||
public function __construct(protected string $snapshotable)
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->snapshotable;
|
||||
}
|
||||
};
|
||||
|
||||
expect($object)->toMatchSnapshot()->toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('pass with `toString`', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this, $this->snapshotable);
|
||||
|
||||
$object = new class($this->snapshotable)
|
||||
{
|
||||
public function __construct(protected string $snapshotable)
|
||||
{
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return $this->snapshotable;
|
||||
}
|
||||
};
|
||||
|
||||
expect($object)->toMatchSnapshot()->toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('pass with dataset', function ($data) {
|
||||
TestSuite::getInstance()->snapshots->save($this, $this->snapshotable);
|
||||
[$filename] = TestSuite::getInstance()->snapshots->get($this, $this->snapshotable);
|
||||
|
||||
expect($filename)->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap')
|
||||
->and($this->snapshotable)->toMatchSnapshot();
|
||||
})->with(['my-datas-set-value']);
|
||||
|
||||
describe('within describe', function () {
|
||||
test('pass with dataset', function ($data) {
|
||||
TestSuite::getInstance()->snapshots->save($this, $this->snapshotable);
|
||||
[$filename] = TestSuite::getInstance()->snapshots->get($this, $this->snapshotable);
|
||||
|
||||
expect($filename)->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap')
|
||||
->and($this->snapshotable)->toMatchSnapshot();
|
||||
});
|
||||
})->with(['my-datas-set-value']);
|
||||
|
||||
test('pass with `toArray`', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this, json_encode(['key' => $this->snapshotable], JSON_PRETTY_PRINT));
|
||||
|
||||
$object = new class($this->snapshotable)
|
||||
{
|
||||
public function __construct(protected string $snapshotable)
|
||||
{
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'key' => $this->snapshotable,
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
expect($object)->toMatchSnapshot()->toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('pass with array', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this, json_encode(['key' => $this->snapshotable], JSON_PRETTY_PRINT));
|
||||
|
||||
expect([
|
||||
'key' => $this->snapshotable,
|
||||
])->toMatchSnapshot()->toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this, $this->snapshotable);
|
||||
|
||||
expect('contain that does not match snapshot')->toMatchSnapshot();
|
||||
})->throws(ExpectationFailedException::class, 'Failed asserting that two strings are identical.');
|
||||
|
||||
test('failures with custom message', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this, $this->snapshotable);
|
||||
|
||||
expect('contain that does not match snapshot')->toMatchSnapshot('oh no');
|
||||
})->throws(ExpectationFailedException::class, 'oh no');
|
||||
|
||||
test('not failures', function () {
|
||||
TestSuite::getInstance()->snapshots->save($this, $this->snapshotable);
|
||||
|
||||
expect($this->snapshotable)->not->toMatchSnapshot();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
@ -15,3 +15,7 @@ it('is not incompleted because of assert')->assertTrue(true);
|
||||
it('is not incompleted because of test with assertions', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
it('is incompleted');
|
||||
});
|
||||
|
||||
@ -5,3 +5,11 @@ it('is a test', function () {
|
||||
});
|
||||
|
||||
it('is a higher order message test')->expect(true)->toBeTrue();
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
it('is a test', function () {
|
||||
expect(['key' => 'foo'])->toHaveKey('key')->key->toBeString();
|
||||
});
|
||||
|
||||
it('is a higher order message test')->expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
@ -5,3 +5,11 @@ test('notice', function () {
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
test('notice', function () {
|
||||
trigger_error('This is a notice description', E_USER_NOTICE);
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
@ -9,3 +9,9 @@ it('allows access to the underlying expectNotToPerformAssertions method', functi
|
||||
it('allows performing no expectations without being risky', function () {
|
||||
$result = 1 + 1;
|
||||
})->throwsNoExceptions();
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
it('allows performing no expectations without being risky', function () {
|
||||
$result = 1 + 1;
|
||||
});
|
||||
})->throwsNoExceptions();
|
||||
|
||||
@ -11,3 +11,11 @@ test('user warning', function () {
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
test('user warning', function () {
|
||||
trigger_error('This is a warning description', E_USER_WARNING);
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
<?php
|
||||
|
||||
test('collision', function (array $arguments) {
|
||||
$snapshot = __DIR__.'/../.snapshots/collision.txt';
|
||||
|
||||
if (in_array('--parallel', $arguments)) {
|
||||
$snapshot = __DIR__.'/../.snapshots/collision-parallel.txt';
|
||||
}
|
||||
|
||||
$output = function () use ($arguments) {
|
||||
$process = (new Symfony\Component\Process\Process(
|
||||
array_merge(['php', 'bin/pest', 'tests/Fixtures/CollisionTest.php'], $arguments),
|
||||
@ -19,23 +13,17 @@ test('collision', function (array $arguments) {
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
$outputContent = explode("\n", $output());
|
||||
$outputContent = explode("\n", $output());
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
|
||||
if (in_array('--parallel', $arguments)) {
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
|
||||
if (in_array('--parallel', $arguments)) {
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
}
|
||||
|
||||
file_put_contents($snapshot, implode("\n", $outputContent));
|
||||
|
||||
$this->markTestSkipped('Snapshot rebuilt.');
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
expect(implode("\n", $outputContent))->toMatchSnapshot();
|
||||
})->with([
|
||||
[['']],
|
||||
[['--parallel']],
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
test('visual snapshot of help command output', function () {
|
||||
$snapshot = __DIR__.'/../.snapshots/help-command.txt';
|
||||
|
||||
$output = function () {
|
||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
|
||||
|
||||
@ -11,11 +9,5 @@ test('visual snapshot of help command output', function () {
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
file_put_contents($snapshot, $output());
|
||||
|
||||
$this->markTestSkipped('Snapshot rebuilt.');
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
expect($output())->toMatchSnapshot();
|
||||
})->skipOnWindows();
|
||||
|
||||
@ -11,14 +11,12 @@ $run = function () {
|
||||
|
||||
$process->run();
|
||||
|
||||
// expect($process->getExitCode())->toBe(0);
|
||||
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
test('parallel', function () use ($run) {
|
||||
expect($run('--exclude-group=integration'))
|
||||
->toContain('Tests: 1 deprecated, 3 warnings, 4 incomplete, 1 notice, 8 todos, 15 skipped, 707 passed (1720 assertions)')
|
||||
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 732 passed (1773 assertions)')
|
||||
->toContain('Parallel: 3 processes');
|
||||
})->skipOnWindows();
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
test('visual snapshot of help command output', function () {
|
||||
$snapshot = __DIR__.'/../.snapshots/version-command.txt';
|
||||
|
||||
$output = function () {
|
||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--version'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
|
||||
|
||||
@ -11,11 +9,5 @@ test('visual snapshot of help command output', function () {
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
file_put_contents($snapshot, $output());
|
||||
|
||||
$this->markTestSkipped('Snapshot rebuilt.');
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
})->skipOnWindows();
|
||||
expect($output())->toMatchSnapshot();
|
||||
})->skipOnWindows()->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'));
|
||||
|
||||
Reference in New Issue
Block a user