Refactor how repositories for the daemon work.
This commit is contained in:
parent
5f9fe4a69b
commit
d2afc29a80
58 changed files with 388 additions and 997 deletions
|
@ -98,10 +98,9 @@ class FileActionsControllerTest extends ControllerTestCase
|
|||
$this->setRequestAttribute('file_stats', 'fileStatsObject');
|
||||
$this->mockInjectJavascript(['stat' => 'fileStatsObject']);
|
||||
|
||||
$this->repository->shouldReceive('setNode')->with($server->node_id)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessServer')->with($server->uuid)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessToken')->with('abc123')->once()->andReturnSelf()
|
||||
->shouldReceive('getContent')->with($file)->once()->andReturn('file contents');
|
||||
$this->repository->shouldReceive('setServer')->with($server)->once()->andReturnSelf()
|
||||
->shouldReceive('setToken')->with('abc123')->once()->andReturnSelf()
|
||||
->shouldReceive('getContent')->with($file)->once()->andReturn((object) ['test']);
|
||||
|
||||
$response = $controller->view($this->request, '1234', $file);
|
||||
$this->assertIsViewResponse($response);
|
||||
|
@ -112,7 +111,7 @@ class FileActionsControllerTest extends ControllerTestCase
|
|||
$this->assertViewHasKey('directory', $response);
|
||||
$this->assertViewKeyEquals('file', $file, $response);
|
||||
$this->assertViewKeyEquals('stat', 'fileStatsObject', $response);
|
||||
$this->assertViewKeyEquals('contents', 'file contents', $response);
|
||||
$this->assertViewKeyEquals('contents', (object) ['test'], $response);
|
||||
$this->assertViewKeyEquals('directory', $expected, $response);
|
||||
}
|
||||
|
||||
|
@ -131,7 +130,7 @@ class FileActionsControllerTest extends ControllerTestCase
|
|||
$this->setRequestAttribute('server_token', 'abc123');
|
||||
$this->setRequestAttribute('file_stats', 'fileStatsObject');
|
||||
|
||||
$this->repository->shouldReceive('setNode')->with($server->node_id)->once()->andThrow($this->getExceptionMock());
|
||||
$this->repository->shouldReceive('setServer')->with($server)->once()->andThrow($this->getExceptionMock());
|
||||
|
||||
try {
|
||||
$controller->view($this->request, '1234', 'file.txt');
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace Tests\Unit\Http\Controllers\Server\Files;
|
||||
|
||||
use Mockery as m;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Tests\Traits\MocksRequestException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
@ -58,9 +59,8 @@ class RemoteRequestControllerTest extends ControllerTestCase
|
|||
|
||||
$controller->shouldReceive('authorize')->with('list-files', $server)->once()->andReturnNull();
|
||||
$this->request->shouldReceive('input')->with('directory', '/')->once()->andReturn('/');
|
||||
$this->repository->shouldReceive('setNode')->with($server->node_id)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessServer')->with($server->uuid)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessToken')->with('abc123')->once()->andReturnSelf()
|
||||
$this->repository->shouldReceive('setServer')->with($server)->once()->andReturnSelf()
|
||||
->shouldReceive('setToken')->with('abc123')->once()->andReturnSelf()
|
||||
->shouldReceive('getDirectory')->with('/')->once()->andReturn(['folders' => 1, 'files' => 2]);
|
||||
$this->config->shouldReceive('get')->with('pterodactyl.files.editable')->once()->andReturn([]);
|
||||
|
||||
|
@ -91,7 +91,7 @@ class RemoteRequestControllerTest extends ControllerTestCase
|
|||
|
||||
$controller->shouldReceive('authorize')->with('list-files', $server)->once()->andReturnNull();
|
||||
$this->request->shouldReceive('input')->with('directory', '/')->once()->andReturn('/');
|
||||
$this->repository->shouldReceive('setNode')->with($server->node_id)->once()->andThrow($this->getExceptionMock());
|
||||
$this->repository->shouldReceive('setServer')->with($server)->once()->andThrow($this->getExceptionMock());
|
||||
|
||||
try {
|
||||
$controller->directory($this->request);
|
||||
|
@ -115,10 +115,9 @@ class RemoteRequestControllerTest extends ControllerTestCase
|
|||
$controller->shouldReceive('authorize')->with('save-files', $server)->once()->andReturnNull();
|
||||
$this->request->shouldReceive('input')->with('file')->once()->andReturn('file.txt');
|
||||
$this->request->shouldReceive('input')->with('contents')->once()->andReturn('file contents');
|
||||
$this->repository->shouldReceive('setNode')->with($server->node_id)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessServer')->with($server->uuid)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessToken')->with('abc123')->once()->andReturnSelf()
|
||||
->shouldReceive('putContent')->with('file.txt', 'file contents')->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('setServer')->with($server)->once()->andReturnSelf()
|
||||
->shouldReceive('setToken')->with('abc123')->once()->andReturnSelf()
|
||||
->shouldReceive('putContent')->with('file.txt', 'file contents')->once()->andReturn(new Response);
|
||||
|
||||
$response = $controller->store($this->request);
|
||||
$this->assertIsResponse($response);
|
||||
|
@ -137,7 +136,7 @@ class RemoteRequestControllerTest extends ControllerTestCase
|
|||
$this->setRequestAttribute('server', $server);
|
||||
|
||||
$controller->shouldReceive('authorize')->with('save-files', $server)->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('setNode')->with($server->node_id)->once()->andThrow($this->getExceptionMock());
|
||||
$this->repository->shouldReceive('setServer')->with($server)->once()->andThrow($this->getExceptionMock());
|
||||
|
||||
try {
|
||||
$controller->store($this->request);
|
||||
|
|
Reference in a new issue