mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 17:57:23 +01:00
Migrates to Pint
This commit is contained in:
@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user