|
| 1 | +<?php |
| 2 | +// Copyright 1999-2023. Plesk International GmbH. |
| 3 | + |
| 4 | +namespace PleskXTest; |
| 5 | + |
| 6 | +class ServicePlanAddonTest extends AbstractTestCase |
| 7 | +{ |
| 8 | + public function testGet() |
| 9 | + { |
| 10 | + $servicePlanAddon = static::createServicePlanAddon(); |
| 11 | + $servicePlanAddonInfo = static::$client->servicePlanAddon()->get('id', $servicePlanAddon->id); |
| 12 | + |
| 13 | + $this->assertNotEmpty($servicePlanAddonInfo->name); |
| 14 | + $this->assertSame($servicePlanAddon->id, $servicePlanAddonInfo->id); |
| 15 | + } |
| 16 | + |
| 17 | + public function testGetAll() |
| 18 | + { |
| 19 | + static::createServicePlanAddon(); |
| 20 | + static::createServicePlanAddon(); |
| 21 | + static::createServicePlanAddon(); |
| 22 | + |
| 23 | + $servicePlanAddons = static::$client->servicePlanAddon()->getAll(); |
| 24 | + $this->assertIsArray($servicePlanAddons); |
| 25 | + $this->assertGreaterThan(2, count($servicePlanAddons)); |
| 26 | + $this->assertNotEmpty($servicePlanAddons[0]->name); |
| 27 | + } |
| 28 | + |
| 29 | + public function testCreate() |
| 30 | + { |
| 31 | + $servicePlanAddon = static::createServicePlanAddon(); |
| 32 | + $this->assertGreaterThan(0, $servicePlanAddon->id); |
| 33 | + |
| 34 | + static::$client->servicePlanAddon()->delete('id', $servicePlanAddon->id); |
| 35 | + } |
| 36 | + |
| 37 | + public function testDelete() |
| 38 | + { |
| 39 | + $servicePlanAddon = static::createServicePlanAddon(); |
| 40 | + $result = static::$client->servicePlanAddon()->delete('id', $servicePlanAddon->id); |
| 41 | + |
| 42 | + $this->assertTrue($result); |
| 43 | + } |
| 44 | + |
| 45 | + public function testCreateComplex() |
| 46 | + { |
| 47 | + $properties = [ |
| 48 | + 'name' => 'Complex Service Plan Addon', |
| 49 | + 'limits' => [ |
| 50 | + 'limit' => [ |
| 51 | + 'name' => 'disk_space', |
| 52 | + 'value' => 1024 * 1024 * 1024, // 1 GB |
| 53 | + ], |
| 54 | + ], |
| 55 | + ]; |
| 56 | + |
| 57 | + $servicePlanAddon = static::$client->servicePlanAddon()->create($properties); |
| 58 | + $this->assertGreaterThan(0, $servicePlanAddon->id); |
| 59 | + |
| 60 | + static::$client->servicePlanAddon()->delete('id', $servicePlanAddon->id); |
| 61 | + } |
| 62 | +} |
0 commit comments