16
16
17
17
use DigitalOceanV2 \Entity \AbstractEntity ;
18
18
use DigitalOceanV2 \Entity \Droplet ;
19
+ use DigitalOceanV2 \Entity \Image ;
20
+ use DigitalOceanV2 \Entity \Region ;
21
+ use DigitalOceanV2 \Entity \Size ;
19
22
use PHPUnit \Framework \TestCase ;
20
23
21
24
/**
@@ -25,14 +28,112 @@ class DropletEntityTest extends TestCase
25
28
{
26
29
public function testConstructor (): void
27
30
{
28
- $ droplet = new Droplet ([
29
- 'id ' => 123 ,
30
- 'name ' => 'Dave ' ,
31
- ]);
31
+ $ values = [
32
+ 'id ' => 3164444 ,
33
+ 'name ' => 'example.com ' ,
34
+ 'memory ' => 1024 ,
35
+ 'vcpus ' => 1 ,
36
+ 'disk ' => 25 ,
37
+ 'locked ' => false ,
38
+ 'status ' => 'active ' ,
39
+ 'kernel ' => null ,
40
+ 'created_at ' => '2020-07-21T18:37:44Z ' ,
41
+ 'features ' => [
42
+ 'backups ' ,
43
+ 'private_networking ' ,
44
+ 'ipv6 ' ,
45
+ ],
46
+ 'backup_ids ' => [
47
+ 53893572 ,
48
+ ],
49
+ 'next_backup_window ' => [
50
+ 'start ' => '2020-07-30T00:00:00Z ' ,
51
+ 'end ' => '2020-07-30T23:00:00Z ' ,
52
+ ],
53
+ 'snapshot_ids ' => [
54
+ 67512819 ,
55
+ ],
56
+ 'image ' => (object ) [
57
+ 'id ' => 63663980 ,
58
+ 'name ' => '20.04 (LTS) x64 ' ,
59
+ 'distribution ' => 'Ubuntu ' ,
60
+ 'slug ' => 'ubuntu-20-04-x64 ' ,
61
+ 'public ' => true ,
62
+ 'regions ' => [
63
+ 'ams2 ' ,
64
+ 'ams3 ' ,
65
+ 'blr1 ' ,
66
+ 'fra1 ' ,
67
+ 'tor1 ' ,
68
+ ],
69
+ 'created_at ' => '2020-05-15T05:47:50Z ' ,
70
+ 'type ' => 'snapshot ' ,
71
+ 'min_disk_size ' => 20 ,
72
+ 'size_gigabytes ' => 2.36 ,
73
+ 'description ' => '' ,
74
+ 'tags ' => [],
75
+ 'status ' => 'available ' ,
76
+ 'error_message ' => '' ,
77
+ ],
78
+ 'volume_ids ' => [],
79
+ 'size ' => (object ) [
80
+ 'slug ' => 's-1vcpu-1gb ' ,
81
+ 'memory ' => 1024 ,
82
+ 'vcpus ' => 1 ,
83
+ 'disk ' => 25 ,
84
+ 'transfer ' => 1 ,
85
+ 'price_monthly ' => 5 ,
86
+ 'price_hourly ' => 0.00743999984115362 ,
87
+ 'regions ' => [
88
+ 'ams2 ' ,
89
+ 'ams3 ' ,
90
+ 'blr1 ' ,
91
+ 'sgp1 ' ,
92
+ 'tor1 ' ,
93
+ ],
94
+ 'available ' => true ,
95
+ 'description ' => 'Basic ' ,
96
+ ],
97
+ 'size_slug ' => 's-1vcpu-1gb ' ,
98
+ 'region ' => (object ) [
99
+ 'name ' => 'New York 3 ' ,
100
+ 'slug ' => 'nyc3 ' ,
101
+ 'features ' => [
102
+ 'private_networking ' ,
103
+ 'backups ' ,
104
+ 'ipv6 ' ,
105
+ ],
106
+ 'available ' => true ,
107
+ 'sizes ' => [
108
+ 's-1vcpu-1gb ' ,
109
+ 's-1vcpu-2gb ' ,
110
+ 's-1vcpu-3gb ' ,
111
+ ],
112
+ ],
113
+ 'tags ' => [
114
+ 'web ' ,
115
+ 'env:prod ' ,
116
+ ],
117
+ 'vpc_uuid ' => '760e09ef-dc84-11e8-981e-3cfdfeaae000 ' ,
118
+ ];
119
+ $ droplet = new Droplet ($ values );
32
120
33
121
self ::assertInstanceOf (AbstractEntity::class, $ droplet );
34
122
self ::assertInstanceOf (Droplet::class, $ droplet );
35
- self ::assertSame (123 , $ droplet ->id );
36
- self ::assertSame ('Dave ' , $ droplet ->name );
123
+ self ::assertInstanceOf (Region::class, $ droplet ->region );
124
+ self ::assertInstanceOf (Size::class, $ droplet ->size );
125
+ self ::assertInstanceOf (Image::class, $ droplet ->image );
126
+ self ::assertSame ($ values ['id ' ], $ droplet ->id );
127
+ self ::assertSame ($ values ['name ' ], $ droplet ->name );
128
+ self ::assertSame ($ values ['memory ' ], $ droplet ->memory );
129
+ self ::assertSame ($ values ['vcpus ' ], $ droplet ->vcpus );
130
+ self ::assertSame ($ values ['disk ' ], $ droplet ->disk );
131
+ self ::assertSame ($ values ['size_slug ' ], $ droplet ->sizeSlug );
132
+ self ::assertSame ($ values ['locked ' ], $ droplet ->locked );
133
+ self ::assertSame ($ values ['status ' ], $ droplet ->status );
134
+ self ::assertSame ($ values ['created_at ' ], $ droplet ->createdAt );
135
+ self ::assertSame ($ values ['features ' ], $ droplet ->features );
136
+ self ::assertSame ($ values ['tags ' ], $ droplet ->tags );
137
+ self ::assertSame ($ values ['vpc_uuid ' ], $ droplet ->vpcUuid );
37
138
}
38
139
}
0 commit comments