|
2 | 2 |
|
3 | 3 | namespace Pterodactyl\Tests\Integration\Services\Deployment; |
4 | 4 |
|
| 5 | +use Exception; |
5 | 6 | use Pterodactyl\Models\Node; |
6 | 7 | use InvalidArgumentException; |
7 | 8 | use Pterodactyl\Models\Server; |
@@ -39,6 +40,34 @@ public function testExceptionIsThrownIfNoMemoryHasBeenSet() |
39 | 40 | $this->getService()->setDisk(10)->handle(); |
40 | 41 | } |
41 | 42 |
|
| 43 | + /** |
| 44 | + * Ensure that errors are not thrown back when passing in expected values. |
| 45 | + * |
| 46 | + * @see https://github.com/pterodactyl/panel/issues/2529 |
| 47 | + */ |
| 48 | + public function testNoExceptionIsThrownIfStringifiedIntegersArePassedForLocations() |
| 49 | + { |
| 50 | + $this->getService()->setLocations([1, 2, 3]); |
| 51 | + $this->getService()->setLocations(['1', '2', '3']); |
| 52 | + $this->getService()->setLocations(['1', 2, 3]); |
| 53 | + |
| 54 | + try { |
| 55 | + $this->getService()->setLocations(['a']); |
| 56 | + $this->assertTrue(false, 'This expectation should not be called.'); |
| 57 | + } catch (Exception $exception) { |
| 58 | + $this->assertInstanceOf(InvalidArgumentException::class, $exception); |
| 59 | + $this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage()); |
| 60 | + } |
| 61 | + |
| 62 | + try { |
| 63 | + $this->getService()->setLocations(['1.2', '1', 2]); |
| 64 | + $this->assertTrue(false, 'This expectation should not be called.'); |
| 65 | + } catch (Exception $exception) { |
| 66 | + $this->assertInstanceOf(InvalidArgumentException::class, $exception); |
| 67 | + $this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage()); |
| 68 | + } |
| 69 | + } |
| 70 | + |
42 | 71 | public function testExpectedNodeIsReturnedForLocation() |
43 | 72 | { |
44 | 73 | /** @var \Pterodactyl\Models\Location[] $locations */ |
|
0 commit comments