Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/vendor
.env
.env.backup
.phpunit.result.cache
/.phpunit.cache
Homestead.json
Homestead.yaml
auth.json
Expand Down
22 changes: 14 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
48 changes: 22 additions & 26 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
<source>
<include>
<directory suffix=".php">./app</directory>
</include>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/Console/Commands/CurlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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'),
Expand Down
18 changes: 9 additions & 9 deletions tests/Feature/Console/Commands/CurlCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -21,23 +21,23 @@ 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.');

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 ":".');

Artisan::call("shift:curl https://example.com --header 'foo'");
}

public function curlCommandFixtures()
public static function curlCommandFixtures(): array
{
return [
'GET request' => ['basic-get'],
Expand Down