Skip to content

Commit 1d92443

Browse files
committed
Set up testing layer
1 parent 05cc461 commit 1d92443

File tree

8 files changed

+37
-21
lines changed

8 files changed

+37
-21
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Tests\Feature\Console\Commands;
4+
5+
use Illuminate\Support\Facades\Artisan;
6+
use Tests\TestCase;
7+
8+
class CurlCommandTest extends TestCase
9+
{
10+
/**
11+
* @test
12+
* @dataProvider curlCommandFixtures
13+
*/
14+
public function it_converts_curl_requests_to_http_client_code($fixture)
15+
{
16+
$code = Artisan::call('shift:' . trim(file_get_contents('tests/fixtures/' . $fixture . '.in')));
17+
$output = Artisan::output();
18+
19+
$this->assertSame(0, $code);
20+
$this->assertSame(file_get_contents('tests/fixtures/' . $fixture . '.out'), $output);
21+
}
22+
23+
public function curlCommandFixtures()
24+
{
25+
return [
26+
'GET request' => ['basic-get'],
27+
'POST request' => ['basic-post'],
28+
'POST request with multiple data' => ['post-with-multiple-data'],
29+
];
30+
}
31+
}

tests/Feature/ExampleTest.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/fixtures/basic-get.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl https://laravelshift.com

tests/fixtures/basic-get.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Http::get('https://laravelshift.com');

tests/fixtures/basic-post.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl -X POST -d 'foo=bar' https://example.com

tests/fixtures/basic-post.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Http::post('https://example.com', ['foo' => 'bar']);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl -X POST -d 'foo=bar' -d 'rho[]=1' -d 'baz=qui&rho[]=2' https://example.com
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Http::post('https://example.com', ['foo' => 'bar', 'rho' => [1, 2], 'baz' => 'qui']);

0 commit comments

Comments
 (0)