diff --git a/Tests/Feature/Tenant/Mock/TenantShowMockClient.php b/Tests/Feature/Tenant/Mock/TenantShowMockClient.php index 14da63f..56c170e 100644 --- a/Tests/Feature/Tenant/Mock/TenantShowMockClient.php +++ b/Tests/Feature/Tenant/Mock/TenantShowMockClient.php @@ -15,6 +15,7 @@ class TenantShowMockClient extends ClientMock { public const BASIC_TENANT = [ 'id' => 1, + 'name' => 'Test Tenant', 'plan' => 'lite', ]; protected string $path; diff --git a/Tests/Feature/Tenant/ShowTenantTest.php b/Tests/Feature/Tenant/ShowTenantTest.php index e08570f..db28700 100644 --- a/Tests/Feature/Tenant/ShowTenantTest.php +++ b/Tests/Feature/Tenant/ShowTenantTest.php @@ -57,4 +57,15 @@ public function it_should_show_current_tenant(): void static::assertSame(1, $tenant->id()); static::assertSame('lite', $tenant->plan()); } + + /** @test */ + public function it_should_show_tenant_name(): void + { + $client = new TenantShowMockClient(data: ['id' => 1]); + $service = new TenantService($client); + + $tenant = $service->find(); + + static::assertSame('Test Tenant', $tenant->name()); + } } diff --git a/src/Director/BodyTo/BodyToTenant.php b/src/Director/BodyTo/BodyToTenant.php index b742ef3..f8c3641 100644 --- a/src/Director/BodyTo/BodyToTenant.php +++ b/src/Director/BodyTo/BodyToTenant.php @@ -14,6 +14,7 @@ public static function build(array $data): Tenant { return (new TenantInternal()) ->setId($data['id']) + ->setName($data['name']) ->setPlan($data['plan']); } } diff --git a/src/Entity/Tenant.php b/src/Entity/Tenant.php index 24d2bdc..d12c1b5 100644 --- a/src/Entity/Tenant.php +++ b/src/Entity/Tenant.php @@ -8,12 +8,18 @@ class Tenant extends AbstractEntity { protected int $id; protected string $plan; + protected string $name; public function id(): int { return $this->id; } + public function name(): string + { + return $this->name; + } + public function plan(): string { return $this->plan; diff --git a/src/Entity/TenantInternal.php b/src/Entity/TenantInternal.php index 8c0c1d0..e2bc9dd 100644 --- a/src/Entity/TenantInternal.php +++ b/src/Entity/TenantInternal.php @@ -16,6 +16,16 @@ public function setId(int $id): self return $this; } + /** + * @internal + */ + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + /** * @internal */