File tree Expand file tree Collapse file tree 4 files changed +47
-32
lines changed
Expand file tree Collapse file tree 4 files changed +47
-32
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ class Auth {
3+ //
4+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,14 @@ class Client
1212
1313 public function __construct (string $ url , string $ key )
1414 {
15+ if (!filter_var ($ url , FILTER_VALIDATE_URL )) {
16+ throw new \InvalidArgumentException ("Invalid URL: $ url " );
17+ } else if (!is_string ($ key )){
18+ throw \InvalidArgumentException ("Invalid apiKey: $ key " );
19+ }else {
20+
1521 $ this ->url = $ url ;
1622 $ this ->apiKey = $ key ;
23+ }
1724 }
1825}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tests ;
6+
7+ use PHPUnit \Framework \Attributes \CoversClass ;
8+ use PHPUnit \Framework \Attributes \Test ;
9+ use PHPUnit \Framework \TestCase ;
10+ use Supabase \Client ;
11+
12+ #[CoversClass(Client::class)]
13+ final class ClientTest extends TestCase
14+ {
15+ #[Test]
16+ public function it_can_be_instantiated (): void
17+ {
18+ $ key = 'test-api-key ' ;
19+ $ url = 'https://api.example.com ' ;
20+
21+ $ client = new Client ($ key , $ url );
22+
23+ $ this ->assertInstanceOf (Client::class, $ client );
24+ }
25+
26+ #[Test]
27+ public function it_throws_exception_with_invalid_url (): void
28+ {
29+ $ this ->expectException (\InvalidArgumentException::class);
30+
31+ $ key = 'test-api-key ' ;
32+ $ url = 'https://example.com ' ;
33+
34+ new Client ($ key , $ url );
35+ }
36+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments