From bedf0336556eb256659103a29ba6ebddb1cf0d54 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Thu, 25 Aug 2022 09:32:48 +0200 Subject: [PATCH 1/2] lint --- src/Actions/LoadStructure.php | 2 ++ src/Laravel/Commands/PestDatasetCommand.php | 2 ++ src/Laravel/Commands/PestInstallCommand.php | 2 ++ src/Laravel/Commands/PestTestCommand.php | 2 ++ src/Logging/JUnit.php | 6 ++++++ src/Logging/TeamCity.php | 5 +++++ src/Plugins/Version.php | 2 ++ tests/Features/Expect/sequence.php | 6 ++++-- tests/PHPUnit/CustomTestCase/CustomTestCase.php | 1 + tests/PHPUnit/CustomTestCase/ExecutedTest.php | 1 + tests/Unit/Plugins/Version.php | 2 ++ 11 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Actions/LoadStructure.php b/src/Actions/LoadStructure.php index 0aafee88..e065dc09 100644 --- a/src/Actions/LoadStructure.php +++ b/src/Actions/LoadStructure.php @@ -5,7 +5,9 @@ declare(strict_types=1); namespace Pest\Actions; use Pest\Support\Str; + use function Pest\testDirectory; + use PHPUnit\Util\FileLoader; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; diff --git a/src/Laravel/Commands/PestDatasetCommand.php b/src/Laravel/Commands/PestDatasetCommand.php index e5cab365..399611e1 100644 --- a/src/Laravel/Commands/PestDatasetCommand.php +++ b/src/Laravel/Commands/PestDatasetCommand.php @@ -8,7 +8,9 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Illuminate\Support\Str; use Pest\Exceptions\InvalidConsoleArgument; + use function Pest\testDirectory; + use Pest\TestSuite; /** diff --git a/src/Laravel/Commands/PestInstallCommand.php b/src/Laravel/Commands/PestInstallCommand.php index 75f6dd54..fb6275ce 100644 --- a/src/Laravel/Commands/PestInstallCommand.php +++ b/src/Laravel/Commands/PestInstallCommand.php @@ -8,7 +8,9 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Pest\Console\Thanks; use Pest\Exceptions\InvalidConsoleArgument; + use function Pest\testDirectory; + use Pest\TestSuite; /** diff --git a/src/Laravel/Commands/PestTestCommand.php b/src/Laravel/Commands/PestTestCommand.php index ee18e076..aa67459e 100644 --- a/src/Laravel/Commands/PestTestCommand.php +++ b/src/Laravel/Commands/PestTestCommand.php @@ -8,7 +8,9 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Pest\Exceptions\InvalidConsoleArgument; use Pest\Support\Str; + use function Pest\testDirectory; + use Pest\TestSuite; /** diff --git a/src/Logging/JUnit.php b/src/Logging/JUnit.php index 61e19a89..2c75cde3 100644 --- a/src/Logging/JUnit.php +++ b/src/Logging/JUnit.php @@ -13,11 +13,14 @@ declare(strict_types=1); namespace Pest\Logging; use function class_exists; + use DOMDocument; use DOMElement; use Exception; + use function get_class; use function method_exists; + use Pest\Concerns\Testable; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\ExceptionWrapper; @@ -32,9 +35,12 @@ use PHPUnit\Util\Printer; use PHPUnit\Util\Xml; use ReflectionClass; use ReflectionException; + use function sprintf; use function str_replace; + use Throwable; + use function trim; /** diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index d1dfe271..d0cb85f5 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -5,10 +5,13 @@ declare(strict_types=1); namespace Pest\Logging; use function getmypid; + use Pest\Concerns\Logging\WritesToConsole; use Pest\Concerns\Testable; use Pest\Support\ExceptionTrace; + use function Pest\version; + use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; @@ -16,9 +19,11 @@ use PHPUnit\Framework\TestResult; use PHPUnit\Framework\TestSuite; use PHPUnit\Framework\Warning; use PHPUnit\TextUI\DefaultResultPrinter; + use function round; use function str_replace; use function strlen; + use Throwable; final class TeamCity extends DefaultResultPrinter diff --git a/src/Plugins/Version.php b/src/Plugins/Version.php index 000bb3a3..0baeb0b0 100644 --- a/src/Plugins/Version.php +++ b/src/Plugins/Version.php @@ -5,7 +5,9 @@ declare(strict_types=1); namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; + use function Pest\version; + use Symfony\Component\Console\Output\OutputInterface; /** diff --git a/tests/Features/Expect/sequence.php b/tests/Features/Expect/sequence.php index 4f11b3a3..b15385e5 100644 --- a/tests/Features/Expect/sequence.php +++ b/tests/Features/Expect/sequence.php @@ -40,8 +40,10 @@ test('fails if the number of iterable items is greater than the number of expect test('it works with associative arrays', function () { expect(['foo' => 'bar', 'baz' => 'boom']) ->sequence( - function ($expectation, $key) { $expectation->toEqual('bar'); $key->toEqual('foo'); }, - function ($expectation, $key) { $expectation->toEqual('boom'); $key->toEqual('baz'); }, + function ($expectation, $key) { $expectation->toEqual('bar'); + $key->toEqual('foo'); }, + function ($expectation, $key) { $expectation->toEqual('boom'); + $key->toEqual('baz'); }, ); }); diff --git a/tests/PHPUnit/CustomTestCase/CustomTestCase.php b/tests/PHPUnit/CustomTestCase/CustomTestCase.php index 2eb0ad4e..a03b82c9 100644 --- a/tests/PHPUnit/CustomTestCase/CustomTestCase.php +++ b/tests/PHPUnit/CustomTestCase/CustomTestCase.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Tests\CustomTestCase; use function PHPUnit\Framework\assertTrue; + use PHPUnit\Framework\TestCase; class CustomTestCase extends TestCase diff --git a/tests/PHPUnit/CustomTestCase/ExecutedTest.php b/tests/PHPUnit/CustomTestCase/ExecutedTest.php index 71a32980..00e759bb 100644 --- a/tests/PHPUnit/CustomTestCase/ExecutedTest.php +++ b/tests/PHPUnit/CustomTestCase/ExecutedTest.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Tests\CustomTestCase; use function PHPUnit\Framework\assertTrue; + use PHPUnit\Framework\TestCase; class ExecutedTest extends TestCase diff --git a/tests/Unit/Plugins/Version.php b/tests/Unit/Plugins/Version.php index 211f11e3..ffb076c7 100644 --- a/tests/Unit/Plugins/Version.php +++ b/tests/Unit/Plugins/Version.php @@ -1,7 +1,9 @@ Date: Thu, 25 Aug 2022 09:46:32 +0200 Subject: [PATCH 2/2] lint --- tests/Features/Expect/sequence.php | 52 ++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/tests/Features/Expect/sequence.php b/tests/Features/Expect/sequence.php index b15385e5..e145f743 100644 --- a/tests/Features/Expect/sequence.php +++ b/tests/Features/Expect/sequence.php @@ -9,9 +9,15 @@ test('an exception is thrown if the the type is not iterable', function () { test('allows for sequences of checks to be run on iterable data', function () { expect([1, 2, 3]) ->sequence( - function ($expectation) { $expectation->toBeInt()->toEqual(1); }, - function ($expectation) { $expectation->toBeInt()->toEqual(2); }, - function ($expectation) { $expectation->toBeInt()->toEqual(3); }, + function ($expectation) { + $expectation->toBeInt()->toEqual(1); + }, + function ($expectation) { + $expectation->toBeInt()->toEqual(2); + }, + function ($expectation) { + $expectation->toBeInt()->toEqual(3); + }, ); expect(static::getCount())->toBe(6); @@ -20,9 +26,15 @@ test('allows for sequences of checks to be run on iterable data', function () { test('loops back to the start if it runs out of sequence items', function () { expect([1, 2, 3, 1, 2, 3, 1, 2]) ->sequence( - function ($expectation) { $expectation->toBeInt()->toEqual(1); }, - function ($expectation) { $expectation->toBeInt()->toEqual(2); }, - function ($expectation) { $expectation->toBeInt()->toEqual(3); }, + function ($expectation) { + $expectation->toBeInt()->toEqual(1); + }, + function ($expectation) { + $expectation->toBeInt()->toEqual(2); + }, + function ($expectation) { + $expectation->toBeInt()->toEqual(3); + }, ); expect(static::getCount())->toBe(16); @@ -31,19 +43,29 @@ test('loops back to the start if it runs out of sequence items', function () { test('fails if the number of iterable items is greater than the number of expectations', function () { expect([1, 2]) ->sequence( - function ($expectation) { $expectation->toBeInt()->toEqual(1); }, - function ($expectation) { $expectation->toBeInt()->toEqual(2); }, - function ($expectation) { $expectation->toBeInt()->toEqual(3); }, + function ($expectation) { + $expectation->toBeInt()->toEqual(1); + }, + function ($expectation) { + $expectation->toBeInt()->toEqual(2); + }, + function ($expectation) { + $expectation->toBeInt()->toEqual(3); + }, ); })->throws(ExpectationFailedException::class); test('it works with associative arrays', function () { expect(['foo' => 'bar', 'baz' => 'boom']) ->sequence( - function ($expectation, $key) { $expectation->toEqual('bar'); - $key->toEqual('foo'); }, - function ($expectation, $key) { $expectation->toEqual('boom'); - $key->toEqual('baz'); }, + function ($expectation, $key) { + $expectation->toEqual('bar'); + $key->toEqual('foo'); + }, + function ($expectation, $key) { + $expectation->toEqual('boom'); + $key->toEqual('baz'); + }, ); }); @@ -56,7 +78,9 @@ test('it can be passed non-callable values', function () { test('it can be passed a mixture of value types', function () { expect(['foo', 'bar', 'baz'])->sequence( 'foo', - function ($expectation) { $expectation->toEqual('bar')->toBeString(); }, + function ($expectation) { + $expectation->toEqual('bar')->toBeString(); + }, 'baz' );