mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 22:33:44 +02:00
Add more location tests, more travis CI fix attempts
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
namespace Tests\Feature\Services;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Pterodactyl\Services\LocationService;
|
||||
@@ -201,4 +203,46 @@ class LocationServiceTest extends TestCase
|
||||
{
|
||||
$this->service->update(0, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a location can be deleted normally when no nodes are attached.
|
||||
*/
|
||||
public function testShouldDeleteExistingLocation()
|
||||
{
|
||||
$location = factory(Location::class)->create();
|
||||
|
||||
$this->assertDatabaseHas('locations', [
|
||||
'id' => $location->id,
|
||||
]);
|
||||
|
||||
$model = $this->service->delete($location);
|
||||
|
||||
$this->assertTrue($model);
|
||||
$this->assertDatabaseMissing('locations', [
|
||||
'id' => $location->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a location cannot be deleted if a node is attached to it.
|
||||
*
|
||||
* @expectedException \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function testShouldFailToDeleteExistingLocationWithAttachedNodes()
|
||||
{
|
||||
$location = factory(Location::class)->create();
|
||||
$node = factory(Node::class)->create(['location_id' => $location->id]);
|
||||
|
||||
$this->assertDatabaseHas('locations', ['id' => $location->id]);
|
||||
$this->assertDatabaseHas('nodes', ['id' => $node->id]);
|
||||
|
||||
try {
|
||||
$this->service->delete($location->id);
|
||||
} catch (\Exception $ex) {
|
||||
$this->assertInstanceOf(DisplayException::class, $ex);
|
||||
$this->assertNotEmpty($ex->getMessage());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user