1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-10-27 20:32:28 +01:00

Fix the surprisingly few broken tests

This commit is contained in:
Dane Everitt 2017-12-16 13:35:32 -06:00
parent 3c48947f9d
commit c6cece51ee
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
8 changed files with 43 additions and 66 deletions

View File

@ -2,9 +2,9 @@
namespace Pterodactyl\Console\Commands\Maintenance; namespace Pterodactyl\Console\Commands\Maintenance;
use SplFileInfo;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Symfony\Component\Finder\SplFileInfo;
use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
class CleanServiceBackupFilesCommand extends Command class CleanServiceBackupFilesCommand extends Command

View File

@ -1,27 +1,4 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
* Some Modifications (c) 2015 Dylan Seidt <dylan.seidt@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Http\Controllers\Base; namespace Pterodactyl\Http\Controllers\Base;

View File

@ -48,7 +48,7 @@
"fzaninotto/faker": "^1.6", "fzaninotto/faker": "^1.6",
"mockery/mockery": "^1.0", "mockery/mockery": "^1.0",
"php-mock/php-mock-phpunit": "^2.0", "php-mock/php-mock-phpunit": "^2.0",
"phpunit/phpunit": "^6.5" "phpunit/phpunit": "~6.4.0"
}, },
"autoload": { "autoload": {
"classmap": [ "classmap": [

52
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "adc287e0991b3755ac9384a9eb9e58e0", "content-hash": "5cdbf1cd4e3e64e939ca2201704d0141",
"packages": [ "packages": [
{ {
"name": "appstract/laravel-blade-directives", "name": "appstract/laravel-blade-directives",
@ -5061,22 +5061,22 @@
}, },
{ {
"name": "php-mock/php-mock-phpunit", "name": "php-mock/php-mock-phpunit",
"version": "2.0.0", "version": "2.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-mock/php-mock-phpunit.git", "url": "https://github.com/php-mock/php-mock-phpunit.git",
"reference": "173781abdc632c59200253e12e2b991ae6a4574f" "reference": "b42fc41ecb7538564067527f6c30b8854f149d32"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-mock/php-mock-phpunit/zipball/173781abdc632c59200253e12e2b991ae6a4574f", "url": "https://api.github.com/repos/php-mock/php-mock-phpunit/zipball/b42fc41ecb7538564067527f6c30b8854f149d32",
"reference": "173781abdc632c59200253e12e2b991ae6a4574f", "reference": "b42fc41ecb7538564067527f6c30b8854f149d32",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7", "php": ">=7",
"php-mock/php-mock-integration": "^2", "php-mock/php-mock-integration": "^2",
"phpunit/phpunit": "^6" "phpunit/phpunit": "^6 <6.5"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -5108,7 +5108,7 @@
"test", "test",
"test double" "test double"
], ],
"time": "2017-02-17T22:44:38+00:00" "time": "2017-12-02T09:49:02+00:00"
}, },
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
@ -5576,16 +5576,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "6.5.4", "version": "6.4.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "1b2f933d5775f9237369deaa2d2bfbf9d652be4c" "reference": "562f7dc75d46510a4ed5d16189ae57fbe45a9932"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1b2f933d5775f9237369deaa2d2bfbf9d652be4c", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/562f7dc75d46510a4ed5d16189ae57fbe45a9932",
"reference": "1b2f933d5775f9237369deaa2d2bfbf9d652be4c", "reference": "562f7dc75d46510a4ed5d16189ae57fbe45a9932",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5599,12 +5599,12 @@
"phar-io/version": "^1.0", "phar-io/version": "^1.0",
"php": "^7.0", "php": "^7.0",
"phpspec/prophecy": "^1.7", "phpspec/prophecy": "^1.7",
"phpunit/php-code-coverage": "^5.3", "phpunit/php-code-coverage": "^5.2.2",
"phpunit/php-file-iterator": "^1.4.3", "phpunit/php-file-iterator": "^1.4.2",
"phpunit/php-text-template": "^1.2.1", "phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^1.0.9", "phpunit/php-timer": "^1.0.9",
"phpunit/phpunit-mock-objects": "^5.0.5", "phpunit/phpunit-mock-objects": "^4.0.3",
"sebastian/comparator": "^2.1", "sebastian/comparator": "^2.0.2",
"sebastian/diff": "^2.0", "sebastian/diff": "^2.0",
"sebastian/environment": "^3.1", "sebastian/environment": "^3.1",
"sebastian/exporter": "^3.1", "sebastian/exporter": "^3.1",
@ -5630,7 +5630,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "6.5.x-dev" "dev-master": "6.4.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -5656,33 +5656,33 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2017-12-10T08:06:19+00:00" "time": "2017-11-08T11:26:09+00:00"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
"version": "5.0.5", "version": "4.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "283b9f4f670e3a6fd6c4ff95c51a952eb5c75933" "reference": "2f789b59ab89669015ad984afa350c4ec577ade0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/283b9f4f670e3a6fd6c4ff95c51a952eb5c75933", "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0",
"reference": "283b9f4f670e3a6fd6c4ff95c51a952eb5c75933", "reference": "2f789b59ab89669015ad984afa350c4ec577ade0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/instantiator": "^1.0.5", "doctrine/instantiator": "^1.0.5",
"php": "^7.0", "php": "^7.0",
"phpunit/php-text-template": "^1.2.1", "phpunit/php-text-template": "^1.2.1",
"sebastian/exporter": "^3.1" "sebastian/exporter": "^3.0"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": "<6.0" "phpunit/phpunit": "<6.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^6.5" "phpunit/phpunit": "^6.0"
}, },
"suggest": { "suggest": {
"ext-soap": "*" "ext-soap": "*"
@ -5690,7 +5690,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "5.0.x-dev" "dev-master": "4.0.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -5705,7 +5705,7 @@
"authors": [ "authors": [
{ {
"name": "Sebastian Bergmann", "name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de", "email": "sb@sebastian-bergmann.de",
"role": "lead" "role": "lead"
} }
], ],
@ -5715,7 +5715,7 @@
"mock", "mock",
"xunit" "xunit"
], ],
"time": "2017-12-10T08:01:53+00:00" "time": "2017-08-03T14:08:16+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",

View File

@ -48,7 +48,7 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
$file = new SplFileInfo('testfile.txt'); $file = new SplFileInfo('testfile.txt');
$this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]); $this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]);
$this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->subDays(100)); $this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->subDays(100)->getTimestamp());
$this->disk->shouldReceive('delete')->with($file->getPath())->once()->andReturnNull(); $this->disk->shouldReceive('delete')->with($file->getPath())->once()->andReturnNull();
$display = $this->runCommand($this->getCommand()); $display = $this->runCommand($this->getCommand());
@ -65,7 +65,7 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
$file = new SplFileInfo('testfile.txt'); $file = new SplFileInfo('testfile.txt');
$this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]); $this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]);
$this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()); $this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->getTimestamp());
$display = $this->runCommand($this->getCommand()); $display = $this->runCommand($this->getCommand());

View File

@ -50,13 +50,13 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForPassword() public function testUpdateControllerForPassword()
{ {
$this->setRequestMockClass(AccountDataFormRequest::class); $this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser(); $user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('password'); $this->request->shouldReceive('input')->with('do_action')->andReturn('password');
$this->request->shouldReceive('input')->with('new_password')->once()->andReturn('test-password'); $this->request->shouldReceive('input')->with('new_password')->once()->andReturn('test-password');
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull(); $this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['password' => 'test-password'])->once()->andReturnNull(); $this->updateService->shouldReceive('handle')->with($user, ['password' => 'test-password'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull(); $this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request); $response = $this->getController()->update($this->request);
@ -70,13 +70,13 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForEmail() public function testUpdateControllerForEmail()
{ {
$this->setRequestMockClass(AccountDataFormRequest::class); $this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser(); $user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('email'); $this->request->shouldReceive('input')->with('do_action')->andReturn('email');
$this->request->shouldReceive('input')->with('new_email')->once()->andReturn('test@example.com'); $this->request->shouldReceive('input')->with('new_email')->once()->andReturn('test@example.com');
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull(); $this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['email' => 'test@example.com'])->once()->andReturnNull(); $this->updateService->shouldReceive('handle')->with($user, ['email' => 'test@example.com'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull(); $this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request); $response = $this->getController()->update($this->request);
@ -90,7 +90,7 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForIdentity() public function testUpdateControllerForIdentity()
{ {
$this->setRequestMockClass(AccountDataFormRequest::class); $this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser(); $user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('identity'); $this->request->shouldReceive('input')->with('do_action')->andReturn('identity');
$this->request->shouldReceive('only')->with(['name_first', 'name_last', 'username'])->once()->andReturn([ $this->request->shouldReceive('only')->with(['name_first', 'name_last', 'username'])->once()->andReturn([
@ -98,7 +98,7 @@ class AccountControllerTest extends ControllerTestCase
]); ]);
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull(); $this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['test_data' => 'value'])->once()->andReturnNull(); $this->updateService->shouldReceive('handle')->with($user, ['test_data' => 'value'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull(); $this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request); $response = $this->getController()->update($this->request);

View File

@ -58,7 +58,7 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testIndexControllerWithDatabaseDriver() public function testIndexControllerWithDatabaseDriver()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->config->shouldReceive('get')->with('session.driver')->once()->andReturn('database'); $this->config->shouldReceive('get')->with('session.driver')->once()->andReturn('database');
$this->repository->shouldReceive('getUserSessions')->with($model->id)->once()->andReturn(['sessions']); $this->repository->shouldReceive('getUserSessions')->with($model->id)->once()->andReturn(['sessions']);
@ -89,7 +89,7 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testGenerateTotpController() public function testGenerateTotpController()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->twoFactorSetupService->shouldReceive('handle')->with($model)->once()->andReturn('qrCodeImage'); $this->twoFactorSetupService->shouldReceive('handle')->with($model)->once()->andReturn('qrCodeImage');
@ -103,10 +103,10 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testDisableTotpControllerSuccess() public function testDisableTotpControllerSuccess()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken'); $this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken');
$this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andReturnNull(); $this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andReturn(true);
$response = $this->getController()->disableTotp($this->request); $response = $this->getController()->disableTotp($this->request);
$this->assertIsRedirectResponse($response); $this->assertIsRedirectResponse($response);
@ -118,7 +118,7 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testDisableTotpControllerWhenExceptionIsThrown() public function testDisableTotpControllerWhenExceptionIsThrown()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken'); $this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken');
$this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andThrow(new TwoFactorAuthenticationTokenInvalid); $this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andThrow(new TwoFactorAuthenticationTokenInvalid);
@ -135,7 +135,7 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testRevokeController() public function testRevokeController()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->repository->shouldReceive('deleteUserSession')->with($model->id, 123)->once()->andReturnNull(); $this->repository->shouldReceive('deleteUserSession')->with($model->id, 123)->once()->andReturnNull();

View File

@ -133,7 +133,7 @@ class ServerCreationServiceTest extends TestCase
$this->configurationStructureService->shouldReceive('handle')->with($model)->once()->andReturn(['test' => 'struct']); $this->configurationStructureService->shouldReceive('handle')->with($model)->once()->andReturn(['test' => 'struct']);
$this->daemonServerRepository->shouldReceive('setNode')->with($model->node_id)->once()->andReturnSelf(); $this->daemonServerRepository->shouldReceive('setNode')->with($model->node_id)->once()->andReturnSelf();
$this->daemonServerRepository->shouldReceive('create')->with(['test' => 'struct'], ['start_on_completion' => false])->once()->andReturnNull(); $this->daemonServerRepository->shouldReceive('create')->with(['test' => 'struct'], ['start_on_completion' => false])->once();
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull(); $this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
$response = $this->getService()->create($model->toArray()); $response = $this->getService()->create($model->toArray());