diff --git a/src/Endpoints/Provider.php b/src/Endpoints/Provider.php new file mode 100644 index 0000000..0a50762 --- /dev/null +++ b/src/Endpoints/Provider.php @@ -0,0 +1,11 @@ +getRequest("providers/{$provider}/metadata"); + } +} diff --git a/src/Resources/Resource.php b/src/Resources/Resource.php index e112d53..4e0c44b 100644 --- a/src/Resources/Resource.php +++ b/src/Resources/Resource.php @@ -24,11 +24,17 @@ public function toArray(): array return $this->attributes; } + /** + * @return mixed|null + */ public function __get(string $name) { return $this->attributes[$name] ?? null; } + /** + * @param mixed $value + */ public function __set(string $name, $value): void { $this->attributes[$name] = $value; diff --git a/tests/Endpoints/ProviderTest.php b/tests/Endpoints/ProviderTest.php new file mode 100644 index 0000000..0026761 --- /dev/null +++ b/tests/Endpoints/ProviderTest.php @@ -0,0 +1,37 @@ +client = Mockery::mock(Client::class); + $this->spinupwp = new SpinupWp('123', $this->client); + $this->endpoint = new Provider($this->spinupwp); + } + + public function test_metadata_request(): void + { + $this->client->shouldReceive('request')->once()->with('GET', 'providers/digitalocean/metadata', [])->andReturn( + new Response(200, [], json_encode(['regions' => [], 'sizes' => []])) + ); + + $result = $this->endpoint->metadata('digitalocean'); + $this->assertArrayHasKey('regions', $result); + $this->assertArrayHasKey('sizes', $result); + } +}