diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 41685fa..40abbf3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.3' tools: phplint, laravel/pint - name: Check syntax run: phplint . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1cc1559..2cd2863 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['8.0', '8.1', '8.2'] + php-version: ['8.3', '8.4'] steps: - name: Checkout uses: actions/checkout@v2 @@ -19,12 +19,12 @@ jobs: coverage: none - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Setup composer cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Install composer dependencies run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist diff --git a/.gitignore b/.gitignore index 4f72470..1e79b6d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ /vendor .env .env.backup -.phpunit.result.cache +/.phpunit.cache Homestead.json Homestead.yaml auth.json diff --git a/composer.json b/composer.json index bb47c03..6025ede 100644 --- a/composer.json +++ b/composer.json @@ -2,19 +2,25 @@ "name": "laravel-shift/curl-converter", "description": "A command line tool to convert curl requests to Laravel HTTP requests.", "type": "library", - "keywords": ["curl", "converter", "http", "laravel", "shift"], + "keywords": [ + "curl", + "converter", + "http", + "laravel", + "shift" + ], "license": "MIT", "require": { - "php": "^8.0", - "illuminate/console": "^9.0|^10.0", - "illuminate/support": "^9.0|^10.0", - "symfony/var-exporter": "^6.3" + "php": "^8.3", + "illuminate/console": "^11.0|^12.0", + "illuminate/support": "^11.0|^12.0", + "symfony/var-exporter": "^7.0" }, "require-dev": { - "laravel/pint": "^1.1", + "laravel/pint": "^1.24", "mockery/mockery": "^1.4.4", - "orchestra/testbench": "^7.0", - "phpunit/phpunit": "^9.5.10" + "orchestra/testbench": "^10.0", + "phpunit/phpunit": "^11.5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 9dc3ad8..bfa1b1c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,28 +1,24 @@ - - - - ./tests/Feature - - - - - ./app - - - - - - - - - - - - - + + + + ./tests/Feature + + + + + + + + + + + + + + + + ./app + + diff --git a/src/Console/Commands/CurlCommand.php b/src/Console/Commands/CurlCommand.php index 8ea27cd..1c3913d 100644 --- a/src/Console/Commands/CurlCommand.php +++ b/src/Console/Commands/CurlCommand.php @@ -7,7 +7,7 @@ class CurlCommand extends Command { - protected $signature = 'shift:curl {--X|request=} {--G|get} {--H|header=*} {--d|data=*} {--data-urlencode=*} {--data-raw=*} {--F|form=*} {--digest} {--basic} {--connect-timeout=} {--max-timeout=} {--retry=} {--s|silent} {--u|user=} {--L|location} {--compressed} {--insecure} {url}'; + protected $signature = 'shift:curl {--X|request=} {--G|get} {--H|header=*} {--d|data=*} {--data-urlencode=*} {--data-raw=*} {--F|form=*} {--digest} {--basic} {--connect-timeout=} {--max-timeout=} {--retry=} {--s|curl-silent} {--u|user=} {--L|location} {--compressed} {--insecure} {url}'; protected $description = 'Convert a UNIX curl request to an HTTP Client request'; @@ -38,7 +38,7 @@ private function gatherOptions() 'connectTimeout' => $this->option('connect-timeout'), 'maxTimeout' => $this->option('max-timeout'), 'retry' => $this->option('retry'), - 'silent' => $this->option('silent'), + 'silent' => $this->option('curl-silent'), 'user' => $this->option('user'), 'compressed' => $this->option('compressed'), 'insecure' => $this->option('insecure'), diff --git a/tests/Feature/Console/Commands/CurlCommandTest.php b/tests/Feature/Console/Commands/CurlCommandTest.php index 83c74d3..45033b5 100644 --- a/tests/Feature/Console/Commands/CurlCommandTest.php +++ b/tests/Feature/Console/Commands/CurlCommandTest.php @@ -4,15 +4,15 @@ use Illuminate\Support\Facades\Artisan; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Tests\TestCase; -class CurlCommandTest extends TestCase +final class CurlCommandTest extends TestCase { - /** - * @test - * @dataProvider curlCommandFixtures - */ - public function it_converts_curl_requests_to_http_client_code($fixture) + #[Test] + #[DataProvider('curlCommandFixtures')] + public function it_converts_curl_requests_to_http_client_code($fixture): void { $code = Artisan::call('shift:' . $this->fixture($fixture . '.in')); $output = trim(Artisan::output()); @@ -21,7 +21,7 @@ public function it_converts_curl_requests_to_http_client_code($fixture) $this->assertSame($this->fixture($fixture . '.out'), $output); } - public function test_it_throw_exception_when_for_invalid_url() + public function test_it_throw_exception_when_for_invalid_url(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The "https://{domain:port}/api/{id}/" URL is invalid.'); @@ -29,7 +29,7 @@ public function test_it_throw_exception_when_for_invalid_url() Artisan::call('shift:curl -X GET "https://{domain:port}/api/{id}/"'); } - public function test_it_throw_exception_when_for_invalid_headers() + public function test_it_throw_exception_when_for_invalid_headers(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The "foo" header must be a key/value pair separated by ":".'); @@ -37,7 +37,7 @@ public function test_it_throw_exception_when_for_invalid_headers() Artisan::call("shift:curl https://example.com --header 'foo'"); } - public function curlCommandFixtures() + public static function curlCommandFixtures(): array { return [ 'GET request' => ['basic-get'],