mirror of
https://github.com/pestphp/pest.git
synced 2026-07-21 17:10:03 +02:00
chore: moves to coding stlye
This commit is contained in:
+1
-2
@@ -23,8 +23,7 @@ return RectorConfig::configure()
|
|||||||
__DIR__.'/tests',
|
__DIR__.'/tests',
|
||||||
])
|
])
|
||||||
->withSets([
|
->withSets([
|
||||||
PestSetList::PEST_CODE_QUALITY,
|
PestSetList::CODING_STYLE,
|
||||||
PestSetList::PEST_CHAIN,
|
|
||||||
])
|
])
|
||||||
->withSkip([
|
->withSkip([
|
||||||
__DIR__.'/src/Plugins/Parallel/Paratest/WrapperRunner.php',
|
__DIR__.'/src/Plugins/Parallel/Paratest/WrapperRunner.php',
|
||||||
|
|||||||
+4
-2
@@ -1,12 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Pest\Plugin;
|
use Pest\Plugin;
|
||||||
|
|
||||||
trait PluginTrait
|
trait PluginTrait
|
||||||
{
|
{
|
||||||
public function assertPluginTraitGotRegistered(): void
|
public function assertPluginTraitGotRegistered(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +16,7 @@ trait SecondPluginTrait
|
|||||||
{
|
{
|
||||||
public function assertSecondPluginTraitGotRegistered(): void
|
public function assertSecondPluginTraitGotRegistered(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ afterAll(function () use ($file): void {
|
|||||||
|
|
||||||
test('deletes file after all', function () use ($file): void {
|
test('deletes file after all', function () use ($file): void {
|
||||||
file_put_contents($file, 'foo');
|
file_put_contents($file, 'foo');
|
||||||
$this->assertFileExists($file);
|
expect($file)->toBeFile();
|
||||||
register_shutdown_function(function (): void {
|
register_shutdown_function(function (): void {
|
||||||
// $this->assertFileDoesNotExist($file);
|
// $this->assertFileDoesNotExist($file);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,17 +10,12 @@ beforeEach(function (): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws exception if dataset does not exist', function (): void {
|
it('throws exception if dataset does not exist', function (): void {
|
||||||
$this->expectException(DatasetDoesNotExist::class);
|
expect(fn () => DatasetsRepository::resolve(['first'], __FILE__))->toThrow(DatasetDoesNotExist::class, "A dataset with the name `first` does not exist. You can create it using `dataset('first', ['a', 'b']);`.");
|
||||||
$this->expectExceptionMessage("A dataset with the name `first` does not exist. You can create it using `dataset('first', ['a', 'b']);`.");
|
|
||||||
|
|
||||||
DatasetsRepository::resolve(['first'], __FILE__);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws exception if dataset already exist', function (): void {
|
it('throws exception if dataset already exist', function (): void {
|
||||||
DatasetsRepository::set('second', [[]], __DIR__);
|
DatasetsRepository::set('second', [[]], __DIR__);
|
||||||
$this->expectException(DatasetAlreadyExists::class);
|
expect(fn () => DatasetsRepository::set('second', [[]], __DIR__))->toThrow(DatasetAlreadyExists::class, 'A dataset with the name `second` already exists in scope ['.__DIR__.'].');
|
||||||
$this->expectExceptionMessage('A dataset with the name `second` already exists in scope ['.__DIR__.'].');
|
|
||||||
DatasetsRepository::set('second', [[]], __DIR__);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets closures', function (): void {
|
it('sets closures', function (): void {
|
||||||
@@ -38,7 +33,7 @@ it('sets arrays', function (): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('gets bound to test case object', function ($value): void {
|
it('gets bound to test case object', function ($value): void {
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
})->with([['a'], ['b']]);
|
})->with([['a'], ['b']]);
|
||||||
|
|
||||||
test('it truncates the description', function (): void {
|
test('it truncates the description', function (): void {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
it('gives access the the underlying expectException', function (): void {
|
it('gives access the the underlying expectException', function (): void {
|
||||||
$this->expectException(InvalidArgumentException::class);
|
expect(fn () => throw new InvalidArgumentException)->toThrow(InvalidArgumentException::class);
|
||||||
|
|
||||||
throw new InvalidArgumentException;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('catch exceptions', function (): void {
|
it('catch exceptions', function (): void {
|
||||||
@@ -27,7 +25,7 @@ it('can just define the code', function (): void {
|
|||||||
})->throws(1);
|
})->throws(1);
|
||||||
|
|
||||||
it('not catch exceptions if given condition is false', function (): void {
|
it('not catch exceptions if given condition is false', function (): void {
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
})->throwsIf(false, Exception::class);
|
})->throwsIf(false, Exception::class);
|
||||||
|
|
||||||
it('catch exceptions if given condition is true', function (): void {
|
it('catch exceptions if given condition is true', function (): void {
|
||||||
@@ -59,7 +57,7 @@ it('can just define the code if given condition is 1', function (): void {
|
|||||||
})->throwsIf(1, 1);
|
})->throwsIf(1, 1);
|
||||||
|
|
||||||
it('not catch exceptions if given condition is true', function (): void {
|
it('not catch exceptions if given condition is true', function (): void {
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
})->throwsUnless(true, Exception::class);
|
})->throwsUnless(true, Exception::class);
|
||||||
|
|
||||||
it('catch exceptions if given condition is false', function (): void {
|
it('catch exceptions if given condition is false', function (): void {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
test('a test', function (): void {
|
test('a test', function (): void {
|
||||||
$this->assertArrayHasKey('key', ['key' => 'foo']);
|
expect(['key' => 'foo'])->toHaveKey('key');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('higher order message test')->expect(true)->toBeTrue();
|
test('higher order message test')->expect(true)->toBeTrue();
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ class ExampleTest extends Base\ExampleTest
|
|||||||
#[\Override]
|
#[\Override]
|
||||||
public function test_example(): void
|
public function test_example(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class MyCustomClassTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function assertTrueIsTrue(): void
|
public function assertTrueIsTrue(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -10,6 +10,6 @@ class CustomTestCaseInSubFolder extends TestCase
|
|||||||
{
|
{
|
||||||
public function assertCustomInSubFolderTrue(): void
|
public function assertCustomInSubFolderTrue(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ abstract class MyCustomClass extends TestCase
|
|||||||
{
|
{
|
||||||
public function assertTrueIsTrue(): void
|
public function assertTrueIsTrue(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(true);
|
expect(true)->toBeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user