mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Migrates to Pint
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$file = __DIR__ . DIRECTORY_SEPARATOR . 'after-all-test';
|
||||
$file = __DIR__.DIRECTORY_SEPARATOR.'after-all-test';
|
||||
|
||||
beforeAll(function () use ($file) {
|
||||
@unlink($file);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$foo = new \stdClass();
|
||||
$foo = new \stdClass();
|
||||
$foo->bar = 0;
|
||||
|
||||
beforeAll(function () use ($foo) {
|
||||
|
||||
@ -35,16 +35,17 @@ it('adds coverage if --min exist', function () {
|
||||
});
|
||||
|
||||
it('generates coverage based on file input', function () {
|
||||
expect(Coverage::getMissingCoverage(new class() {
|
||||
expect(Coverage::getMissingCoverage(new class()
|
||||
{
|
||||
public function lineCoverageData(): array
|
||||
{
|
||||
return [
|
||||
1 => ['foo'],
|
||||
2 => ['bar'],
|
||||
4 => [],
|
||||
5 => [],
|
||||
6 => [],
|
||||
7 => null,
|
||||
1 => ['foo'],
|
||||
2 => ['bar'],
|
||||
4 => [],
|
||||
5 => [],
|
||||
6 => [],
|
||||
7 => null,
|
||||
100 => null,
|
||||
101 => ['foo'],
|
||||
102 => [],
|
||||
|
||||
@ -46,7 +46,7 @@ test('it truncates the description', function () {
|
||||
// it gets tested by the integration test
|
||||
})->with([str_repeat('Fooo', 10)]);
|
||||
|
||||
$state = new stdClass();
|
||||
$state = new stdClass();
|
||||
$state->text = '';
|
||||
|
||||
$datasets = [[1], [2]];
|
||||
@ -148,7 +148,7 @@ $datasets_a = [[1], [2]];
|
||||
$datasets_b = [[3], [4]];
|
||||
|
||||
test('lazy multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) {
|
||||
$state->text .= $text_a . $text_b;
|
||||
$state->text .= $text_a.$text_b;
|
||||
expect($datasets_a)->toContain([$text_a]);
|
||||
expect($datasets_b)->toContain([$text_b]);
|
||||
})->with($datasets_a, $datasets_b);
|
||||
@ -160,7 +160,7 @@ test('lazy multiple datasets did the job right', function () use ($state) {
|
||||
$state->text = '';
|
||||
|
||||
test('eager multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) {
|
||||
$state->text .= $text_a . $text_b;
|
||||
$state->text .= $text_a.$text_b;
|
||||
expect($datasets_a)->toContain([$text_a]);
|
||||
expect($datasets_b)->toContain([$text_b]);
|
||||
})->with(function () use ($datasets_a) {
|
||||
@ -174,7 +174,7 @@ test('eager multiple datasets did the job right', function () use ($state) {
|
||||
});
|
||||
|
||||
test('lazy registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) {
|
||||
$state->text .= $text_a . $text_b;
|
||||
$state->text .= $text_a.$text_b;
|
||||
expect($datasets)->toContain([$text_a]);
|
||||
expect($datasets)->toContain([$text_b]);
|
||||
})->with('numbers.array')->with('numbers.array');
|
||||
@ -184,7 +184,7 @@ test('lazy registered multiple datasets did the job right', function () use ($st
|
||||
});
|
||||
|
||||
test('eager registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) {
|
||||
$state->text .= $text_a . $text_b;
|
||||
$state->text .= $text_a.$text_b;
|
||||
expect($datasets)->toContain([$text_a]);
|
||||
expect($datasets)->toContain([$text_b]);
|
||||
})->with('numbers.array')->with('numbers.closure');
|
||||
@ -194,7 +194,7 @@ test('eager registered multiple datasets did the job right', function () use ($s
|
||||
});
|
||||
|
||||
test('eager wrapped registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) {
|
||||
$state->text .= $text_a . $text_b;
|
||||
$state->text .= $text_a.$text_b;
|
||||
expect($datasets)->toContain([$text_a]);
|
||||
expect($datasets)->toContain([$text_b]);
|
||||
})->with('numbers.closure.wrapped')->with('numbers.closure');
|
||||
@ -204,7 +204,7 @@ test('eager wrapped registered multiple datasets did the job right', function ()
|
||||
});
|
||||
|
||||
test('named multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) {
|
||||
$state->text .= $text_a . $text_b;
|
||||
$state->text .= $text_a.$text_b;
|
||||
expect($datasets_a)->toContain([$text_a]);
|
||||
expect($datasets_b)->toContain([$text_b]);
|
||||
})->with([
|
||||
@ -212,7 +212,7 @@ test('named multiple datasets', function ($text_a, $text_b) use ($state, $datase
|
||||
'two' => [2],
|
||||
])->with([
|
||||
'three' => [3],
|
||||
'four' => [4],
|
||||
'four' => [4],
|
||||
]);
|
||||
|
||||
test('named multiple datasets did the job right', function () use ($state) {
|
||||
@ -220,7 +220,7 @@ test('named multiple datasets did the job right', function () use ($state) {
|
||||
});
|
||||
|
||||
test('more than two datasets', function ($text_a, $text_b, $text_c) use ($state, $datasets_a, $datasets_b) {
|
||||
$state->text .= $text_a . $text_b . $text_c;
|
||||
$state->text .= $text_a.$text_b.$text_c;
|
||||
expect($datasets_a)->toContain([$text_a]);
|
||||
expect($datasets_b)->toContain([$text_b]);
|
||||
expect([5, 6])->toContain($text_c);
|
||||
|
||||
@ -131,7 +131,7 @@ class HasMethods
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'name' => $this->name(),
|
||||
'name' => $this->name(),
|
||||
'quantity' => $this->quantity(),
|
||||
];
|
||||
}
|
||||
@ -141,11 +141,11 @@ class HasMethods
|
||||
return [
|
||||
[
|
||||
'title' => 'Foo',
|
||||
'cost' => 20,
|
||||
'cost' => 20,
|
||||
],
|
||||
[
|
||||
'title' => 'Bar',
|
||||
'cost' => 30,
|
||||
'cost' => 30,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -72,11 +72,11 @@ class HasMethodsAndProperties
|
||||
public $posts = [
|
||||
[
|
||||
'is_published' => true,
|
||||
'title' => 'Foo',
|
||||
'title' => 'Foo',
|
||||
],
|
||||
[
|
||||
'is_published' => true,
|
||||
'title' => 'Bar',
|
||||
'title' => 'Bar',
|
||||
],
|
||||
];
|
||||
|
||||
@ -85,11 +85,11 @@ class HasMethodsAndProperties
|
||||
return [
|
||||
[
|
||||
'title' => 'Foo',
|
||||
'cost' => 20,
|
||||
'cost' => 20,
|
||||
],
|
||||
[
|
||||
'title' => 'Bar',
|
||||
'cost' => 30,
|
||||
'cost' => 30,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -86,11 +86,11 @@ class HasProperties
|
||||
public $posts = [
|
||||
[
|
||||
'is_published' => true,
|
||||
'title' => 'Foo',
|
||||
'title' => 'Foo',
|
||||
],
|
||||
[
|
||||
'is_published' => true,
|
||||
'title' => 'Bar',
|
||||
'title' => 'Bar',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ it('runs with falsy closure condition', function () {
|
||||
it('can be passed non-callable values', function () {
|
||||
expect('foo')
|
||||
->match('pest', [
|
||||
'bar' => 'foo',
|
||||
'bar' => 'foo',
|
||||
'pest' => 'baz',
|
||||
]
|
||||
);
|
||||
|
||||
@ -48,10 +48,10 @@ class State
|
||||
public function reset(): void
|
||||
{
|
||||
$this->appliedCount = $this->runCount = [
|
||||
'char' => 0,
|
||||
'number' => 0,
|
||||
'char' => 0,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'symbol' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -133,16 +133,16 @@ test('pipe is applied and can stop pipeline', function () use ($state) {
|
||||
expect($char)->toBe(new Char('A'))
|
||||
->and($state)
|
||||
->runCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'symbol' => 0,
|
||||
])
|
||||
->appliedCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'symbol' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
@ -152,16 +152,16 @@ test('pipe is run and can let the pipeline keep going', function () use ($state)
|
||||
expect(3)->toBe(3)
|
||||
->and($state)
|
||||
->runCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 1,
|
||||
'symbol' => 1,
|
||||
])
|
||||
->appliedCount->toMatchArray([
|
||||
'char' => 0,
|
||||
'number' => 0,
|
||||
'char' => 0,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'symbol' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
@ -173,16 +173,16 @@ test('pipe works with negated expectation', function () use ($state) {
|
||||
expect($char)->not->toBe(new Char('B'))
|
||||
->and($state)
|
||||
->runCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'symbol' => 0,
|
||||
])
|
||||
->appliedCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'symbol' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
@ -205,16 +205,16 @@ test('interceptor stops the pipeline', function () use ($state) {
|
||||
expect($number)->toBe(new Number(1))
|
||||
->and($state)
|
||||
->runCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 1,
|
||||
'char' => 1,
|
||||
'number' => 1,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'symbol' => 0,
|
||||
])
|
||||
->appliedCount->toMatchArray([
|
||||
'char' => 0,
|
||||
'number' => 1,
|
||||
'char' => 0,
|
||||
'number' => 1,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'symbol' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ use PHPUnit\Framework\ExpectationFailedException;
|
||||
expect(true)->toBeTrue()->and(false)->toBeFalse();
|
||||
|
||||
test('strict comparisons', function () {
|
||||
$nuno = new stdClass();
|
||||
$nuno = new stdClass();
|
||||
$dries = new stdClass();
|
||||
|
||||
expect($nuno)->toBe($nuno)->not->toBe($dries);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
beforeEach(function () {
|
||||
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
|
||||
touch($this->tempFile = sys_get_temp_dir().'/fake.file');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
beforeEach(function () {
|
||||
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
|
||||
touch($this->tempFile = sys_get_temp_dir().'/fake.file');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
beforeEach(function () {
|
||||
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
|
||||
touch($this->tempFile = sys_get_temp_dir().'/fake.file');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
||||
@ -3,24 +3,24 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
$object = new stdClass();
|
||||
$object = new stdClass();
|
||||
$object->name = 'Jhon';
|
||||
$object->age = 21;
|
||||
$object->age = 21;
|
||||
|
||||
expect($object)->toHaveProperties(['name', 'age']);
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
$object = new stdClass();
|
||||
$object = new stdClass();
|
||||
$object->name = 'Jhon';
|
||||
|
||||
expect($object)->toHaveProperties(['name', 'age']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
$object = new stdClass();
|
||||
$object = new stdClass();
|
||||
$object->name = 'Jhon';
|
||||
$object->age = 21;
|
||||
$object->age = 21;
|
||||
|
||||
expect($object)->not->toHaveProperties(['name', 'age']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->foo = 'bar';
|
||||
$obj = new stdClass();
|
||||
$obj->foo = 'bar';
|
||||
$obj->fooNull = null;
|
||||
|
||||
test('pass', function () use ($obj) {
|
||||
|
||||
@ -4,22 +4,22 @@ use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->user = [
|
||||
'id' => 1,
|
||||
'name' => 'Nuno',
|
||||
'id' => 1,
|
||||
'name' => 'Nuno',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
];
|
||||
});
|
||||
|
||||
test('pass', function () {
|
||||
expect($this->user)->toMatchArray([
|
||||
'name' => 'Nuno',
|
||||
'name' => 'Nuno',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
]);
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect($this->user)->toMatchArray([
|
||||
'name' => 'Not the same name',
|
||||
'name' => 'Not the same name',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
]);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -4,33 +4,34 @@ use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->user = (object) [
|
||||
'id' => 1,
|
||||
'name' => 'Nuno',
|
||||
'id' => 1,
|
||||
'name' => 'Nuno',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
];
|
||||
});
|
||||
|
||||
test('pass', function () {
|
||||
expect($this->user)->toMatchObject([
|
||||
'name' => 'Nuno',
|
||||
'name' => 'Nuno',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
]);
|
||||
});
|
||||
|
||||
test('pass with class', function () {
|
||||
expect(new class() {
|
||||
expect(new class()
|
||||
{
|
||||
public $name = 'Nuno';
|
||||
|
||||
public $email = 'enunomaduro@gmail.com';
|
||||
})->toMatchObject([
|
||||
'name' => 'Nuno',
|
||||
'name' => 'Nuno',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
]);
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect($this->user)->toMatchObject([
|
||||
'name' => 'Not the same name',
|
||||
'name' => 'Not the same name',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
]);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -38,13 +38,13 @@ test('passes', function () {
|
||||
test('failures 1', function () {
|
||||
expect(function () {
|
||||
})->toThrow(RuntimeException::class);
|
||||
})->throws(ExpectationFailedException::class, 'Exception "' . RuntimeException::class . '" not thrown.');
|
||||
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
|
||||
|
||||
test('failures 2', function () {
|
||||
expect(function () {
|
||||
})->toThrow(function (RuntimeException $e) {
|
||||
});
|
||||
})->throws(ExpectationFailedException::class, 'Exception "' . RuntimeException::class . '" not thrown.');
|
||||
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
|
||||
|
||||
test('failures 3', function () {
|
||||
expect(function () {
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->unlessObject = new stdClass();
|
||||
$this->unlessObject = new stdClass();
|
||||
$this->unlessObject->trueValue = true;
|
||||
$this->unlessObject->foo = 'foo';
|
||||
$this->unlessObject->foo = 'foo';
|
||||
});
|
||||
|
||||
it('pass', function () {
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->whenObject = new stdClass();
|
||||
$this->whenObject = new stdClass();
|
||||
$this->whenObject->trueValue = true;
|
||||
$this->whenObject->foo = 'foo';
|
||||
$this->whenObject->foo = 'foo';
|
||||
});
|
||||
|
||||
it('pass', function () {
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
|
||||
use function PHPUnit\Framework\assertFalse;
|
||||
|
||||
$foo = new stdClass();
|
||||
$foo->beforeAll = false;
|
||||
$foo = new stdClass();
|
||||
$foo->beforeAll = false;
|
||||
$foo->beforeEach = false;
|
||||
$foo->afterEach = false;
|
||||
$foo->afterAll = false;
|
||||
$foo->afterEach = false;
|
||||
$foo->afterAll = false;
|
||||
|
||||
beforeAll(function () {
|
||||
$foo->beforeAll = true;
|
||||
|
||||
@ -4,7 +4,7 @@ use Pest\Support\Str;
|
||||
|
||||
// HACK: we have to determine our $_SERVER['globalHook-]>calls baseline. This is because
|
||||
// two other tests are executed before this one due to filename ordering.
|
||||
$args = $_SERVER['argv'] ?? [];
|
||||
$args = $_SERVER['argv'] ?? [];
|
||||
$single = (isset($args[1]) && Str::endsWith(__FILE__, $args[1])) || ($_SERVER['PEST_PARALLEL'] ?? false);
|
||||
$offset = $single ? 0 : 2;
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace Tests\CustomTestCase;
|
||||
|
||||
use function PHPUnit\Framework\assertTrue;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class CustomTestCase extends TestCase
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace Tests\CustomTestCase;
|
||||
|
||||
use function PHPUnit\Framework\assertTrue;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExecutedTest extends TestCase
|
||||
|
||||
@ -34,7 +34,7 @@ it('show only the names of multiple named datasets in their description', functi
|
||||
],
|
||||
[
|
||||
'three' => [3],
|
||||
'four' => [[4]],
|
||||
'four' => [[4]],
|
||||
],
|
||||
]));
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Pest\Plugins\Version;
|
||||
|
||||
use function Pest\version;
|
||||
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
it('outputs the version when --version is used', function () {
|
||||
@ -11,7 +9,7 @@ it('outputs the version when --version is used', function () {
|
||||
$plugin = new Version($output);
|
||||
|
||||
$plugin->handleArguments(['foo', '--version']);
|
||||
expect($output->fetch())->toContain('Pest ' . version());
|
||||
expect($output->fetch())->toContain('Pest '.version());
|
||||
});
|
||||
|
||||
it('do not outputs version when --version is not used', function () {
|
||||
|
||||
@ -10,7 +10,8 @@ it('gets file name from closure', function () {
|
||||
});
|
||||
|
||||
it('gets property values', function () {
|
||||
$class = new class() {
|
||||
$class = new class()
|
||||
{
|
||||
private $foo = 'bar';
|
||||
};
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ use Pest\TestSuite;
|
||||
|
||||
it('does not allow to add the same test description twice', function () {
|
||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||
$method = new TestCaseMethodFactory('foo', 'bar', null);
|
||||
$method = new TestCaseMethodFactory('foo', 'bar', null);
|
||||
|
||||
$testSuite->tests->set($method);
|
||||
$testSuite->tests->set($method);
|
||||
@ -44,7 +44,7 @@ it('can return an array of all test suite filenames', function () {
|
||||
it('can filter the test suite filenames to those with the only method', function () {
|
||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||
|
||||
$testWithOnly = new TestCaseMethodFactory('a', 'b', null);
|
||||
$testWithOnly = new TestCaseMethodFactory('a', 'b', null);
|
||||
$testWithOnly->only = true;
|
||||
$testSuite->tests->set($testWithOnly);
|
||||
|
||||
@ -63,7 +63,7 @@ it('does not filter the test suite filenames to those with the only method when
|
||||
$test = function () {
|
||||
};
|
||||
|
||||
$testWithOnly = new TestCaseMethodFactory('a', 'b', null);
|
||||
$testWithOnly = new TestCaseMethodFactory('a', 'b', null);
|
||||
$testWithOnly->only = true;
|
||||
$testSuite->tests->set($testWithOnly);
|
||||
|
||||
|
||||
@ -4,18 +4,18 @@ use Pest\Console\Help;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
test('visual snapshot of help command output', function () {
|
||||
$snapshot = __DIR__ . '/../.snapshots/help-command.txt';
|
||||
$snapshot = __DIR__.'/../.snapshots/help-command.txt';
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
$outputBuffer = new BufferedOutput();
|
||||
$plugin = new Help($outputBuffer);
|
||||
$plugin = new Help($outputBuffer);
|
||||
|
||||
$plugin();
|
||||
|
||||
file_put_contents($snapshot, $outputBuffer->fetch());
|
||||
}
|
||||
|
||||
$output = function () {
|
||||
$output = function () {
|
||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
|
||||
|
||||
$process->run();
|
||||
|
||||
@ -6,11 +6,11 @@ use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Framework\Warning;
|
||||
|
||||
beforeEach(function () {
|
||||
file_put_contents(__DIR__ . '/junit.html', '');
|
||||
file_put_contents(__DIR__.'/junit.html', '');
|
||||
});
|
||||
|
||||
it('is can successfully call all public methods', function () {
|
||||
$junit = new JUnit(__DIR__ . '/junit.html');
|
||||
$junit = new JUnit(__DIR__.'/junit.html');
|
||||
$junit->startTestSuite(new TestSuite());
|
||||
$junit->startTest($this);
|
||||
$junit->addError($this, new Exception(), 0);
|
||||
@ -25,5 +25,5 @@ it('is can successfully call all public methods', function () {
|
||||
})->skip('Not supported yet.');
|
||||
|
||||
afterEach(function () {
|
||||
unlink(__DIR__ . '/junit.html');
|
||||
unlink(__DIR__.'/junit.html');
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
$run = function (string $target, $decorated = false) {
|
||||
$run = function (string $target, $decorated = false) {
|
||||
$process = new Process(['php', 'bin/pest', $target, '--colors=always'], dirname(__DIR__, 2),
|
||||
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
|
||||
);
|
||||
@ -12,7 +12,7 @@ $run = function (string $target, $decorated = false) {
|
||||
return $decorated ? $process->getOutput() : preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
$snapshot = function ($name) {
|
||||
$snapshot = function ($name) {
|
||||
$testsPath = dirname(__DIR__);
|
||||
|
||||
return file_get_contents(implode(DIRECTORY_SEPARATOR, [
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
test('visual snapshot of test suite on success', function () {
|
||||
$testsPath = dirname(__DIR__);
|
||||
$snapshot = implode(DIRECTORY_SEPARATOR, [
|
||||
$snapshot = implode(DIRECTORY_SEPARATOR, [
|
||||
$testsPath,
|
||||
'.snapshots',
|
||||
'success.txt',
|
||||
]);
|
||||
|
||||
$output = function () use ($testsPath) {
|
||||
$output = function () use ($testsPath) {
|
||||
$process = (new Symfony\Component\Process\Process(
|
||||
['php', 'bin/pest'],
|
||||
dirname($testsPath),
|
||||
@ -31,12 +31,12 @@ test('visual snapshot of test suite on success', function () {
|
||||
$outputContent = preg_replace('/Time\: \s+\d+\.\d+s\s+/m', '', $output());
|
||||
|
||||
file_put_contents($snapshot, $outputContent);
|
||||
} elseif (!getenv('EXCLUDE')) {
|
||||
} elseif (! getenv('EXCLUDE')) {
|
||||
$output = explode("\n", $output());
|
||||
array_pop($output);
|
||||
array_pop($output);
|
||||
|
||||
expect(implode("\n", $output))->toContain(file_get_contents($snapshot));
|
||||
}
|
||||
})->skip(!getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
|
||||
})->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
|
||||
->skip(PHP_OS_FAMILY === 'Windows');
|
||||
|
||||
@ -8,11 +8,11 @@ use PHPUnit\Framework\Warning;
|
||||
use PHPUnit\TextUI\DefaultResultPrinter;
|
||||
|
||||
beforeEach(function () {
|
||||
file_put_contents(__DIR__ . '/output.txt', '');
|
||||
file_put_contents(__DIR__.'/output.txt', '');
|
||||
});
|
||||
|
||||
it('is can successfully call all public methods', function () {
|
||||
$teamCity = new TeamCity(__DIR__ . '/output.txt', false, DefaultResultPrinter::COLOR_ALWAYS);
|
||||
$teamCity = new TeamCity(__DIR__.'/output.txt', false, DefaultResultPrinter::COLOR_ALWAYS);
|
||||
expect($teamCity::isPestTest($this))->toBeTrue();
|
||||
$teamCity->startTestSuite(new TestSuite());
|
||||
$teamCity->startTest($this);
|
||||
@ -28,5 +28,5 @@ it('is can successfully call all public methods', function () {
|
||||
})->skip('Not supported yet.');
|
||||
|
||||
afterEach(function () {
|
||||
unlink(__DIR__ . '/output.txt');
|
||||
unlink(__DIR__.'/output.txt');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user