File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,11 @@ CHANGE LOG
22==========
33
44
5+ ## 5.0.6 (UPCOMING)
6+
7+ * Fixed ` ProjectResource ` links hydration
8+
9+
510## 5.0.5 (03/05/2025)
611
712* Fixed ` FirewallRuleOutbound ` hydration
Original file line number Diff line number Diff line change @@ -27,4 +27,15 @@ final class ProjectResource extends AbstractEntity
2727 public array $ links ;
2828
2929 public string $ status ;
30+
31+ public function build (array $ parameters ): void
32+ {
33+ foreach ($ parameters as $ property => $ value ) {
34+ if ('links ' === static ::convertToCamelCase ($ property ) && $ value instanceof \stdClass) {
35+ $ parameters [$ property ] = \get_object_vars ($ value );
36+ }
37+ }
38+
39+ parent ::build ($ parameters );
40+ }
3041}
Original file line number Diff line number Diff line change @@ -42,4 +42,23 @@ public function testConstructor(): void
4242 self ::assertSame (['self ' => 'https://api.digitalocean.com/v2/droplets/123456789 ' ], $ projectResource ->links );
4343 self ::assertSame ('already_assigned ' , $ projectResource ->status );
4444 }
45+
46+ public function testConstructorAcceptsApiShapedLinksObject (): void
47+ {
48+ $ projectResource = new ProjectResource ([
49+ 'urn ' => 'do:droplet:123456789 ' ,
50+ 'assigned_at ' => '2022-08-04T04:26:24Z ' ,
51+ 'links ' => (object ) [
52+ 'self ' => 'https://api.digitalocean.com/v2/droplets/123456789 ' ,
53+ ],
54+ 'status ' => 'already_assigned ' ,
55+ ]);
56+
57+ self ::assertInstanceOf (AbstractEntity::class, $ projectResource );
58+ self ::assertInstanceOf (ProjectResource::class, $ projectResource );
59+ self ::assertSame ('do:droplet:123456789 ' , $ projectResource ->urn );
60+ self ::assertSame ('2022-08-04T04:26:24Z ' , $ projectResource ->assignedAt );
61+ self ::assertSame (['self ' => 'https://api.digitalocean.com/v2/droplets/123456789 ' ], $ projectResource ->links );
62+ self ::assertSame ('already_assigned ' , $ projectResource ->status );
63+ }
4564}
You can’t perform that action at this time.
0 commit comments