Fix immediately obvious deprecation notices while running command tests

This commit is contained in:
Dane Everitt 2020-06-23 21:33:56 -07:00
parent 86bc9da893
commit eaae74fe33
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
9 changed files with 63 additions and 85 deletions

View file

@ -1,11 +1,4 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Tests\Unit\Commands\Environment;
@ -58,7 +51,7 @@ class EmailSettingsCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], array_values($data));
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**
@ -90,7 +83,7 @@ class EmailSettingsCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**
@ -115,7 +108,7 @@ class EmailSettingsCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, ['--driver' => 'mail'], array_values($data));
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**
@ -136,7 +129,7 @@ class EmailSettingsCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], array_values($data));
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**
@ -164,7 +157,7 @@ class EmailSettingsCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**
@ -184,7 +177,7 @@ class EmailSettingsCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], array_values($data));
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**
@ -210,7 +203,7 @@ class EmailSettingsCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**
@ -235,7 +228,7 @@ class EmailSettingsCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**
@ -264,7 +257,7 @@ class EmailSettingsCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertContains('Updating stored environment configuration file.', $display);
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
}
/**

View file

@ -63,7 +63,7 @@ class DeleteLocationCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], [$location2->short]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.location.deleted'), $display);
$this->assertStringContainsString(trans('command/messages.location.deleted'), $display);
}
/**
@ -84,7 +84,7 @@ class DeleteLocationCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.location.deleted'), $display);
$this->assertStringContainsString(trans('command/messages.location.deleted'), $display);
}
/**
@ -103,8 +103,8 @@ class DeleteLocationCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], ['123_not_exist', 'another_not_exist', $location2->short]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.location.no_location_found'), $display);
$this->assertContains(trans('command/messages.location.deleted'), $display);
$this->assertStringContainsString(trans('command/messages.location.no_location_found'), $display);
$this->assertStringContainsString(trans('command/messages.location.deleted'), $display);
}
/**
@ -123,6 +123,6 @@ class DeleteLocationCommandTest extends CommandTestCase
$display = $this->withoutInteraction()->runCommand($this->command, ['--short' => 'randomTestString']);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.location.no_location_found'), $display);
$this->assertStringContainsString(trans('command/messages.location.no_location_found'), $display);
}
}

View file

@ -55,7 +55,7 @@ class MakeLocationCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], [$location->short, $location->long]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.location.created', [
$this->assertStringContainsString(trans('command/messages.location.created', [
'name' => $location->short,
'id' => $location->id,
]), $display);
@ -79,7 +79,7 @@ class MakeLocationCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.location.created', [
$this->assertStringContainsString(trans('command/messages.location.created', [
'name' => $location->short,
'id' => $location->id,
]), $display);

View file

@ -54,7 +54,7 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
$display = $this->runCommand($this->getCommand());
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.maintenance.deleting_service_backup', ['file' => 'testfile.txt']), $display);
$this->assertStringContainsString(trans('command/messages.maintenance.deleting_service_backup', ['file' => 'testfile.txt']), $display);
}
/**

View file

@ -1,11 +1,4 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Tests\Unit\Commands\Schedule;
@ -64,7 +57,7 @@ class ProcessRunnableCommandTest extends CommandTestCase
$display = $this->runCommand($this->command);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.schedule.output_line', [
$this->assertStringContainsString(trans('command/messages.schedule.output_line', [
'schedule' => $schedule->name,
'hash' => $schedule->hashid,
]), $display);
@ -83,7 +76,7 @@ class ProcessRunnableCommandTest extends CommandTestCase
$display = $this->runCommand($this->command);
$this->assertNotEmpty($display);
$this->assertNotContains(trans('command/messages.schedule.output_line', [
$this->assertStringNotContainsString(trans('command/messages.schedule.output_line', [
'schedule' => $schedule->name,
'hash' => $schedule->hashid,
]), $display);
@ -101,7 +94,7 @@ class ProcessRunnableCommandTest extends CommandTestCase
$display = $this->runCommand($this->command);
$this->assertNotEmpty($display);
$this->assertNotContains(trans('command/messages.schedule.output_line', [
$this->assertStringNotContainsString(trans('command/messages.schedule.output_line', [
'schedule' => $schedule->name,
'hash' => $schedule->hashid,
]), $display);

View file

@ -6,8 +6,10 @@ use Mockery as m;
use Pterodactyl\Models\Node;
use GuzzleHttp\Psr7\Response;
use Pterodactyl\Models\Server;
use Illuminate\Support\Collection;
use Illuminate\Validation\Factory;
use Tests\Unit\Commands\CommandTestCase;
use Illuminate\Validation\ValidationException;
use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
use Pterodactyl\Console\Commands\Server\BulkPowerActionCommand;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
@ -47,25 +49,18 @@ class BulkPowerActionCommandTest extends CommandTestCase
$server->setRelation('node', factory(Node::class)->make());
}
$this->repository->expects('getServersForPowerActionCount')->with([], [])->andReturns(2);
$this->repository->shouldReceive('getServersForPowerAction')
->once()
->with([], [])
->andReturn($servers);
$this->repository->expects('getServersForPowerActionCount')->with([], [])->andReturn(2);
$this->repository->expects('getServersForPowerAction')->with([], [])->andReturn($servers);
for ($i = 0; $i < count($servers); $i++) {
$this->powerRepository->shouldReceive('setNode->setServer->sendSignal')
->once()
->with('kill')
->andReturnNull();
$this->powerRepository->expects('setNode->setServer->send')->with('kill')->andReturnNull();
}
$display = $this->runCommand($this->getCommand(), ['action' => 'kill'], ['yes']);
$this->assertNotEmpty($display);
$this->assertContains('2/2', $display);
$this->assertContains(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 2]), $display);
$this->assertStringContainsString('2/2', $display);
$this->assertStringContainsString(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 2]), $display);
}
/**
@ -76,19 +71,17 @@ class BulkPowerActionCommandTest extends CommandTestCase
$server = factory(Server::class)->make();
$server->setRelation('node', $node = factory(Node::class)->make());
$this->repository->shouldReceive('getServersForPowerActionCount')
->once()
$this->repository->expects('getServersForPowerActionCount')
->with([1, 2], [3, 4])
->andReturn(1);
$this->repository->shouldReceive('getServersForPowerAction')
->once()
$this->repository->expects('getServersForPowerAction')
->with([1, 2], [3, 4])
->andReturn([$server]);
->andReturn(Collection::make([$server]));
$this->powerRepository->expects('setNode')->with($node)->andReturnSelf();
$this->powerRepository->expects('setServer')->with($server)->andReturnSelf();
$this->powerRepository->expects('sendSignal')->with('kill')->andReturn(new Response);
$this->powerRepository->expects('send')->with('kill')->andReturn(new Response);
$display = $this->runCommand($this->getCommand(), [
'action' => 'kill',
@ -97,8 +90,8 @@ class BulkPowerActionCommandTest extends CommandTestCase
], ['yes']);
$this->assertNotEmpty($display);
$this->assertContains('1/1', $display);
$this->assertContains(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 1]), $display);
$this->assertStringContainsString('1/1', $display);
$this->assertStringContainsString(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 1]), $display);
}
/**
@ -109,13 +102,12 @@ class BulkPowerActionCommandTest extends CommandTestCase
$server = factory(Server::class)->make();
$server->setRelation('node', factory(Node::class)->make());
$this->repository->shouldReceive('getServersForPowerActionCount')
->once()
$this->repository->expects('getServersForPowerActionCount')
->with([], [])
->andReturn(1);
$this->repository->shouldReceive('getServersForPowerAction')->once()->with([], [])->andReturn([$server]);
$this->powerRepository->shouldReceive('setNode->setServer->sendSignal')->once()->with('kill')->andReturnNull();
$this->repository->expects('getServersForPowerAction')->with([], [])->andReturn(Collection::make([$server]));
$this->powerRepository->expects('setNode->setServer->send')->with('kill')->andReturnNull();
$display = $this->runCommand($this->getCommand(), [
'action' => 'kill',
@ -124,8 +116,8 @@ class BulkPowerActionCommandTest extends CommandTestCase
], ['yes']);
$this->assertNotEmpty($display);
$this->assertContains('1/1', $display);
$this->assertContains(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 1]), $display);
$this->assertStringContainsString('1/1', $display);
$this->assertStringContainsString(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 1]), $display);
}
/**
@ -134,10 +126,10 @@ class BulkPowerActionCommandTest extends CommandTestCase
* @param array $data
*
* @dataProvider validationFailureDataProvider
* @expectedException \Illuminate\Validation\ValidationException
*/
public function testValidationErrors(array $data)
{
$this->expectException(ValidationException::class);
$this->runCommand($this->getCommand(), $data);
}

View file

@ -63,7 +63,7 @@ class DeleteUserCommandTest extends CommandTestCase
$this->assertTableContains($user1->id, $display);
$this->assertTableContains($user1->email, $display);
$this->assertTableContains($user1->name, $display);
$this->assertContains(trans('command/messages.user.deleted'), $display);
$this->assertStringContainsString(trans('command/messages.user.deleted'), $display);
}
/**
@ -84,11 +84,11 @@ class DeleteUserCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], ['noResults', $user1->username, $user1->id, 'yes']);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.user.no_users_found'), $display);
$this->assertStringContainsString(trans('command/messages.user.no_users_found'), $display);
$this->assertTableContains($user1->id, $display);
$this->assertTableContains($user1->email, $display);
$this->assertTableContains($user1->name, $display);
$this->assertContains(trans('command/messages.user.deleted'), $display);
$this->assertStringContainsString(trans('command/messages.user.deleted'), $display);
}
/**
@ -107,11 +107,11 @@ class DeleteUserCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], [$user1->username, 0, $user1->username, $user1->id, 'yes']);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.user.select_search_user'), $display);
$this->assertStringContainsString(trans('command/messages.user.select_search_user'), $display);
$this->assertTableContains($user1->id, $display);
$this->assertTableContains($user1->email, $display);
$this->assertTableContains($user1->name, $display);
$this->assertContains(trans('command/messages.user.deleted'), $display);
$this->assertStringContainsString(trans('command/messages.user.deleted'), $display);
}
/**
@ -130,7 +130,7 @@ class DeleteUserCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], [$user1->username, $user1->id, 'no']);
$this->assertNotEmpty($display);
$this->assertNotContains(trans('command/messages.user.deleted'), $display);
$this->assertStringNotContainsString(trans('command/messages.user.deleted'), $display);
}
/**
@ -149,7 +149,7 @@ class DeleteUserCommandTest extends CommandTestCase
$display = $this->withoutInteraction()->runCommand($this->command, ['--user' => $user1->username]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.user.deleted'), $display);
$this->assertStringContainsString(trans('command/messages.user.deleted'), $display);
}
/**
@ -169,7 +169,7 @@ class DeleteUserCommandTest extends CommandTestCase
$display = $this->withoutInteraction()->runCommand($this->command, ['--user' => $user1->username]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.user.multiple_found'), $display);
$this->assertStringContainsString(trans('command/messages.user.multiple_found'), $display);
}
/**
@ -183,6 +183,6 @@ class DeleteUserCommandTest extends CommandTestCase
$display = $this->withoutInteraction()->runCommand($this->command, ['--user' => 123456]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.user.no_users_found'), $display);
$this->assertStringContainsString(trans('command/messages.user.no_users_found'), $display);
}
}

View file

@ -58,7 +58,7 @@ class DisableTwoFactorCommandTest extends CommandTestCase
$display = $this->runCommand($this->command, [], [$user->email]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.user.2fa_disabled', ['email' => $user->email]), $display);
$this->assertStringContainsString(trans('command/messages.user.2fa_disabled', ['email' => $user->email]), $display);
}
/**
@ -78,6 +78,6 @@ class DisableTwoFactorCommandTest extends CommandTestCase
$display = $this->withoutInteraction()->runCommand($this->command, ['--email' => $user->email]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.user.2fa_disabled', ['email' => $user->email]), $display);
$this->assertStringContainsString(trans('command/messages.user.2fa_disabled', ['email' => $user->email]), $display);
}
}

View file

@ -61,12 +61,12 @@ class MakeUserCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.user.ask_password_help'), $display);
$this->assertContains($user->uuid, $display);
$this->assertContains($user->email, $display);
$this->assertContains($user->username, $display);
$this->assertContains($user->name, $display);
$this->assertContains('Yes', $display);
$this->assertStringContainsString(trans('command/messages.user.ask_password_help'), $display);
$this->assertStringContainsString($user->uuid, $display);
$this->assertStringContainsString($user->email, $display);
$this->assertStringContainsString($user->username, $display);
$this->assertStringContainsString($user->name, $display);
$this->assertStringContainsString('Yes', $display);
}
/**
@ -90,7 +90,7 @@ class MakeUserCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertNotContains(trans('command/messages.user.ask_password_help'), $display);
$this->assertStringNotContainsString(trans('command/messages.user.ask_password_help'), $display);
}
/**
@ -119,11 +119,11 @@ class MakeUserCommandTest extends CommandTestCase
]);
$this->assertNotEmpty($display);
$this->assertNotContains(trans('command/messages.user.ask_password_help'), $display);
$this->assertContains($user->uuid, $display);
$this->assertContains($user->email, $display);
$this->assertContains($user->username, $display);
$this->assertContains($user->name, $display);
$this->assertContains('No', $display);
$this->assertStringNotContainsString(trans('command/messages.user.ask_password_help'), $display);
$this->assertStringContainsString($user->uuid, $display);
$this->assertStringContainsString($user->email, $display);
$this->assertStringContainsString($user->username, $display);
$this->assertStringContainsString($user->name, $display);
$this->assertStringContainsString('No', $display);
}
}