File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
tests/Feature/Console/Commands Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 3
3
namespace Shift \CurlConverter \Models ;
4
4
5
5
use Illuminate \Support \Str ;
6
+ use InvalidArgumentException ;
6
7
7
8
class Request
8
9
{
@@ -36,6 +37,10 @@ public static function create(array $data): self
36
37
{
37
38
$ url = parse_url ($ data ['url ' ]);
38
39
40
+ if ($ url === false ) {
41
+ throw new InvalidArgumentException (sprintf ('The "%s" URL is invalid. ' , $ data ['url ' ]));
42
+ }
43
+
39
44
$ request = new self (self ::buildUrl ($ url ), $ data ['method ' ] ?? 'GET ' );
40
45
41
46
if (isset ($ url ['query ' ])) {
Original file line number Diff line number Diff line change 3
3
namespace Tests \Feature \Console \Commands ;
4
4
5
5
use Illuminate \Support \Facades \Artisan ;
6
+ use InvalidArgumentException ;
6
7
use Tests \TestCase ;
7
8
8
9
class CurlCommandTest extends TestCase
@@ -20,6 +21,14 @@ public function it_converts_curl_requests_to_http_client_code($fixture)
20
21
$ this ->assertSame ($ this ->fixture ($ fixture . '.out ' ), $ output );
21
22
}
22
23
24
+ public function test_it_throw_exception_when_for_invalid_url ()
25
+ {
26
+ $ this ->expectException (InvalidArgumentException::class);
27
+ $ this ->expectExceptionMessage ('The "https://{domain:port}/api/{id}/" URL is invalid. ' );
28
+
29
+ Artisan::call ('shift:curl -X GET "https://{domain:port}/api/{id}/" ' );
30
+ }
31
+
23
32
public function curlCommandFixtures ()
24
33
{
25
34
return [
You can’t perform that action at this time.
0 commit comments