Path: blob/1.0-develop/tests/Integration/Api/Application/Nodes/NodeController/UpdateNodeTest.php
10263 views
<?php12namespace Pterodactyl\Tests\Integration\Api\Application\Nodes\NodeController;34use Mockery\MockInterface;5use Pterodactyl\Models\Node;6use GuzzleHttp\Psr7\Response;7use Pterodactyl\Models\Location;8use Pterodactyl\Repositories\Wings\DaemonConfigurationRepository;9use Pterodactyl\Tests\Integration\Api\Application\ApplicationApiIntegrationTestCase;1011class UpdateNodeTest extends ApplicationApiIntegrationTestCase12{13public function testCanUpdateNodeProperties(): void14{15$node = Node::factory()->for(Location::factory())->create();16$location = Location::factory()->create();1718$this->mock(DaemonConfigurationRepository::class, function (MockInterface $mock) use ($node) {19$mock->expects('setNode')->with(\Mockery::on(fn ($value) => $value->is($node)))->andReturnSelf();20$mock->expects('update')->withAnyArgs()->andReturn(21new Response()22);23});2425$this->patchJson(route('api.application.nodes.update', ['node' => $node]), [26'name' => 'New Name',27'description' => 'New Description',28'location_id' => $location->id,29'fqdn' => 'new.example.com',30'scheme' => 'https',31'memory' => 100,32'memory_overallocate' => 10,33'disk' => 200,34'disk_overallocate' => 20,35'daemon_sftp' => 1101,36'daemon_listen' => 1102,37])38->assertOk()39->assertJsonPath('object', 'node')40->assertJsonPath('attributes.name', 'New Name')41->assertJsonPath('attributes.description', 'New Description')42->assertJsonPath('attributes.fqdn', 'new.example.com')43->assertJsonPath('attributes.scheme', 'https')44->assertJsonPath('attributes.memory', 100)45->assertJsonPath('attributes.memory_overallocate', 10)46->assertJsonPath('attributes.disk', 200)47->assertJsonPath('attributes.disk_overallocate', 20)48->assertJsonPath('attributes.daemon_sftp', 1101)49->assertJsonPath('attributes.daemon_listen', 1102);5051$this->assertEquals($location->id, $node->refresh()->location_id);52}53}545556