Skip to content

Commit eaae74f

Browse files
committed
Fix immediately obvious deprecation notices while running command tests
1 parent 86bc9da commit eaae74f

File tree

9 files changed

+63
-85
lines changed

9 files changed

+63
-85
lines changed

tests/Unit/Commands/Environment/EmailSettingsCommandTest.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Tests\Unit\Commands\Environment;
114

@@ -58,7 +51,7 @@ public function testSmtpDriverSelection()
5851
$display = $this->runCommand($this->command, [], array_values($data));
5952

6053
$this->assertNotEmpty($display);
61-
$this->assertContains('Updating stored environment configuration file.', $display);
54+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
6255
}
6356

6457
/**
@@ -90,7 +83,7 @@ public function testSmtpDriverSelectionWithOptionsPassed()
9083
]);
9184

9285
$this->assertNotEmpty($display);
93-
$this->assertContains('Updating stored environment configuration file.', $display);
86+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
9487
}
9588

9689
/**
@@ -115,7 +108,7 @@ public function testPHPMailDriverSelection()
115108
$display = $this->runCommand($this->command, ['--driver' => 'mail'], array_values($data));
116109

117110
$this->assertNotEmpty($display);
118-
$this->assertContains('Updating stored environment configuration file.', $display);
111+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
119112
}
120113

121114
/**
@@ -136,7 +129,7 @@ public function testMailgunDriverSelection()
136129
$display = $this->runCommand($this->command, [], array_values($data));
137130

138131
$this->assertNotEmpty($display);
139-
$this->assertContains('Updating stored environment configuration file.', $display);
132+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
140133
}
141134

142135
/**
@@ -164,7 +157,7 @@ public function testMailgunDriverSelectionWithOptionsPassed()
164157
]);
165158

166159
$this->assertNotEmpty($display);
167-
$this->assertContains('Updating stored environment configuration file.', $display);
160+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
168161
}
169162

170163
/**
@@ -184,7 +177,7 @@ public function testMandrillDriverSelection()
184177
$display = $this->runCommand($this->command, [], array_values($data));
185178

186179
$this->assertNotEmpty($display);
187-
$this->assertContains('Updating stored environment configuration file.', $display);
180+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
188181
}
189182

190183
/**
@@ -210,7 +203,7 @@ public function testMandrillDriverSelectionWithOptionsPassed()
210203
]);
211204

212205
$this->assertNotEmpty($display);
213-
$this->assertContains('Updating stored environment configuration file.', $display);
206+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
214207
}
215208

216209
/**
@@ -235,7 +228,7 @@ public function testPostmarkDriverSelection()
235228
]);
236229

237230
$this->assertNotEmpty($display);
238-
$this->assertContains('Updating stored environment configuration file.', $display);
231+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
239232
}
240233

241234
/**
@@ -264,7 +257,7 @@ public function testPostmarkDriverSelectionWithOptionsPassed()
264257
]);
265258

266259
$this->assertNotEmpty($display);
267-
$this->assertContains('Updating stored environment configuration file.', $display);
260+
$this->assertStringContainsString('Updating stored environment configuration file.', $display);
268261
}
269262

270263
/**

tests/Unit/Commands/Location/DeleteLocationCommandTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testLocationIsDeleted()
6363
$display = $this->runCommand($this->command, [], [$location2->short]);
6464

6565
$this->assertNotEmpty($display);
66-
$this->assertContains(trans('command/messages.location.deleted'), $display);
66+
$this->assertStringContainsString(trans('command/messages.location.deleted'), $display);
6767
}
6868

6969
/**
@@ -84,7 +84,7 @@ public function testLocationIsDeletedIfPassedInOption()
8484
]);
8585

8686
$this->assertNotEmpty($display);
87-
$this->assertContains(trans('command/messages.location.deleted'), $display);
87+
$this->assertStringContainsString(trans('command/messages.location.deleted'), $display);
8888
}
8989

9090
/**
@@ -103,8 +103,8 @@ public function testInteractiveEnvironmentAllowsReAttemptingSearch()
103103
$display = $this->runCommand($this->command, [], ['123_not_exist', 'another_not_exist', $location2->short]);
104104

105105
$this->assertNotEmpty($display);
106-
$this->assertContains(trans('command/messages.location.no_location_found'), $display);
107-
$this->assertContains(trans('command/messages.location.deleted'), $display);
106+
$this->assertStringContainsString(trans('command/messages.location.no_location_found'), $display);
107+
$this->assertStringContainsString(trans('command/messages.location.deleted'), $display);
108108
}
109109

110110
/**
@@ -123,6 +123,6 @@ public function testNonInteractiveEnvironmentThrowsErrorIfNoLocationIsFound()
123123
$display = $this->withoutInteraction()->runCommand($this->command, ['--short' => 'randomTestString']);
124124

125125
$this->assertNotEmpty($display);
126-
$this->assertContains(trans('command/messages.location.no_location_found'), $display);
126+
$this->assertStringContainsString(trans('command/messages.location.no_location_found'), $display);
127127
}
128128
}

tests/Unit/Commands/Location/MakeLocationCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testLocationIsCreatedWithNoOptionsPassed()
5555
$display = $this->runCommand($this->command, [], [$location->short, $location->long]);
5656

5757
$this->assertNotEmpty($display);
58-
$this->assertContains(trans('command/messages.location.created', [
58+
$this->assertStringContainsString(trans('command/messages.location.created', [
5959
'name' => $location->short,
6060
'id' => $location->id,
6161
]), $display);
@@ -79,7 +79,7 @@ public function testLocationIsCreatedWhenOptionsArePassed()
7979
]);
8080

8181
$this->assertNotEmpty($display);
82-
$this->assertContains(trans('command/messages.location.created', [
82+
$this->assertStringContainsString(trans('command/messages.location.created', [
8383
'name' => $location->short,
8484
'id' => $location->id,
8585
]), $display);

tests/Unit/Commands/Maintenance/CleanServiceBackupFilesCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testCommandCleansFilesMoreThan5MinutesOld()
5454
$display = $this->runCommand($this->getCommand());
5555

5656
$this->assertNotEmpty($display);
57-
$this->assertContains(trans('command/messages.maintenance.deleting_service_backup', ['file' => 'testfile.txt']), $display);
57+
$this->assertStringContainsString(trans('command/messages.maintenance.deleting_service_backup', ['file' => 'testfile.txt']), $display);
5858
}
5959

6060
/**

tests/Unit/Commands/Schedule/ProcessRunnableCommandTest.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Tests\Unit\Commands\Schedule;
114

@@ -64,7 +57,7 @@ public function testScheduleIsQueued()
6457
$display = $this->runCommand($this->command);
6558

6659
$this->assertNotEmpty($display);
67-
$this->assertContains(trans('command/messages.schedule.output_line', [
60+
$this->assertStringContainsString(trans('command/messages.schedule.output_line', [
6861
'schedule' => $schedule->name,
6962
'hash' => $schedule->hashid,
7063
]), $display);
@@ -83,7 +76,7 @@ public function testScheduleWithNoTasksIsNotProcessed()
8376
$display = $this->runCommand($this->command);
8477

8578
$this->assertNotEmpty($display);
86-
$this->assertNotContains(trans('command/messages.schedule.output_line', [
79+
$this->assertStringNotContainsString(trans('command/messages.schedule.output_line', [
8780
'schedule' => $schedule->name,
8881
'hash' => $schedule->hashid,
8982
]), $display);
@@ -101,7 +94,7 @@ public function testScheduleWithTasksObjectThatIsNotInstanceOfCollectionIsNotPro
10194
$display = $this->runCommand($this->command);
10295

10396
$this->assertNotEmpty($display);
104-
$this->assertNotContains(trans('command/messages.schedule.output_line', [
97+
$this->assertStringNotContainsString(trans('command/messages.schedule.output_line', [
10598
'schedule' => $schedule->name,
10699
'hash' => $schedule->hashid,
107100
]), $display);

tests/Unit/Commands/Server/BulkPowerActionCommandTest.php

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
use Pterodactyl\Models\Node;
77
use GuzzleHttp\Psr7\Response;
88
use Pterodactyl\Models\Server;
9+
use Illuminate\Support\Collection;
910
use Illuminate\Validation\Factory;
1011
use Tests\Unit\Commands\CommandTestCase;
12+
use Illuminate\Validation\ValidationException;
1113
use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
1214
use Pterodactyl\Console\Commands\Server\BulkPowerActionCommand;
1315
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
@@ -47,25 +49,18 @@ public function testSendAction()
4749
$server->setRelation('node', factory(Node::class)->make());
4850
}
4951

50-
$this->repository->expects('getServersForPowerActionCount')->with([], [])->andReturns(2);
51-
52-
$this->repository->shouldReceive('getServersForPowerAction')
53-
->once()
54-
->with([], [])
55-
->andReturn($servers);
52+
$this->repository->expects('getServersForPowerActionCount')->with([], [])->andReturn(2);
53+
$this->repository->expects('getServersForPowerAction')->with([], [])->andReturn($servers);
5654

5755
for ($i = 0; $i < count($servers); $i++) {
58-
$this->powerRepository->shouldReceive('setNode->setServer->sendSignal')
59-
->once()
60-
->with('kill')
61-
->andReturnNull();
56+
$this->powerRepository->expects('setNode->setServer->send')->with('kill')->andReturnNull();
6257
}
6358

6459
$display = $this->runCommand($this->getCommand(), ['action' => 'kill'], ['yes']);
6560

6661
$this->assertNotEmpty($display);
67-
$this->assertContains('2/2', $display);
68-
$this->assertContains(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 2]), $display);
62+
$this->assertStringContainsString('2/2', $display);
63+
$this->assertStringContainsString(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 2]), $display);
6964
}
7065

7166
/**
@@ -76,19 +71,17 @@ public function testSendWithFilters()
7671
$server = factory(Server::class)->make();
7772
$server->setRelation('node', $node = factory(Node::class)->make());
7873

79-
$this->repository->shouldReceive('getServersForPowerActionCount')
80-
->once()
74+
$this->repository->expects('getServersForPowerActionCount')
8175
->with([1, 2], [3, 4])
8276
->andReturn(1);
8377

84-
$this->repository->shouldReceive('getServersForPowerAction')
85-
->once()
78+
$this->repository->expects('getServersForPowerAction')
8679
->with([1, 2], [3, 4])
87-
->andReturn([$server]);
80+
->andReturn(Collection::make([$server]));
8881

8982
$this->powerRepository->expects('setNode')->with($node)->andReturnSelf();
9083
$this->powerRepository->expects('setServer')->with($server)->andReturnSelf();
91-
$this->powerRepository->expects('sendSignal')->with('kill')->andReturn(new Response);
84+
$this->powerRepository->expects('send')->with('kill')->andReturn(new Response);
9285

9386
$display = $this->runCommand($this->getCommand(), [
9487
'action' => 'kill',
@@ -97,8 +90,8 @@ public function testSendWithFilters()
9790
], ['yes']);
9891

9992
$this->assertNotEmpty($display);
100-
$this->assertContains('1/1', $display);
101-
$this->assertContains(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 1]), $display);
93+
$this->assertStringContainsString('1/1', $display);
94+
$this->assertStringContainsString(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 1]), $display);
10295
}
10396

10497
/**
@@ -109,13 +102,12 @@ public function testSendWithEmptyOptions()
109102
$server = factory(Server::class)->make();
110103
$server->setRelation('node', factory(Node::class)->make());
111104

112-
$this->repository->shouldReceive('getServersForPowerActionCount')
113-
->once()
105+
$this->repository->expects('getServersForPowerActionCount')
114106
->with([], [])
115107
->andReturn(1);
116108

117-
$this->repository->shouldReceive('getServersForPowerAction')->once()->with([], [])->andReturn([$server]);
118-
$this->powerRepository->shouldReceive('setNode->setServer->sendSignal')->once()->with('kill')->andReturnNull();
109+
$this->repository->expects('getServersForPowerAction')->with([], [])->andReturn(Collection::make([$server]));
110+
$this->powerRepository->expects('setNode->setServer->send')->with('kill')->andReturnNull();
119111

120112
$display = $this->runCommand($this->getCommand(), [
121113
'action' => 'kill',
@@ -124,8 +116,8 @@ public function testSendWithEmptyOptions()
124116
], ['yes']);
125117

126118
$this->assertNotEmpty($display);
127-
$this->assertContains('1/1', $display);
128-
$this->assertContains(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 1]), $display);
119+
$this->assertStringContainsString('1/1', $display);
120+
$this->assertStringContainsString(trans('command/messages.server.power.confirm', ['action' => 'kill', 'count' => 1]), $display);
129121
}
130122

131123
/**
@@ -134,10 +126,10 @@ public function testSendWithEmptyOptions()
134126
* @param array $data
135127
*
136128
* @dataProvider validationFailureDataProvider
137-
* @expectedException \Illuminate\Validation\ValidationException
138129
*/
139130
public function testValidationErrors(array $data)
140131
{
132+
$this->expectException(ValidationException::class);
141133
$this->runCommand($this->getCommand(), $data);
142134
}
143135

tests/Unit/Commands/User/DeleteUserCommandTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testCommandWithNoOptions()
6363
$this->assertTableContains($user1->id, $display);
6464
$this->assertTableContains($user1->email, $display);
6565
$this->assertTableContains($user1->name, $display);
66-
$this->assertContains(trans('command/messages.user.deleted'), $display);
66+
$this->assertStringContainsString(trans('command/messages.user.deleted'), $display);
6767
}
6868

6969
/**
@@ -84,11 +84,11 @@ public function testCommandWithInvalidInitialSearch()
8484
$display = $this->runCommand($this->command, [], ['noResults', $user1->username, $user1->id, 'yes']);
8585

8686
$this->assertNotEmpty($display);
87-
$this->assertContains(trans('command/messages.user.no_users_found'), $display);
87+
$this->assertStringContainsString(trans('command/messages.user.no_users_found'), $display);
8888
$this->assertTableContains($user1->id, $display);
8989
$this->assertTableContains($user1->email, $display);
9090
$this->assertTableContains($user1->name, $display);
91-
$this->assertContains(trans('command/messages.user.deleted'), $display);
91+
$this->assertStringContainsString(trans('command/messages.user.deleted'), $display);
9292
}
9393

9494
/**
@@ -107,11 +107,11 @@ public function testReSearchAbility()
107107
$display = $this->runCommand($this->command, [], [$user1->username, 0, $user1->username, $user1->id, 'yes']);
108108

109109
$this->assertNotEmpty($display);
110-
$this->assertContains(trans('command/messages.user.select_search_user'), $display);
110+
$this->assertStringContainsString(trans('command/messages.user.select_search_user'), $display);
111111
$this->assertTableContains($user1->id, $display);
112112
$this->assertTableContains($user1->email, $display);
113113
$this->assertTableContains($user1->name, $display);
114-
$this->assertContains(trans('command/messages.user.deleted'), $display);
114+
$this->assertStringContainsString(trans('command/messages.user.deleted'), $display);
115115
}
116116

117117
/**
@@ -130,7 +130,7 @@ public function testAnsweringNoToDeletionConfirmationWillNotDeleteUser()
130130
$display = $this->runCommand($this->command, [], [$user1->username, $user1->id, 'no']);
131131

132132
$this->assertNotEmpty($display);
133-
$this->assertNotContains(trans('command/messages.user.deleted'), $display);
133+
$this->assertStringNotContainsString(trans('command/messages.user.deleted'), $display);
134134
}
135135

136136
/**
@@ -149,7 +149,7 @@ public function testNoInteractionWithSingleResult()
149149
$display = $this->withoutInteraction()->runCommand($this->command, ['--user' => $user1->username]);
150150

151151
$this->assertNotEmpty($display);
152-
$this->assertContains(trans('command/messages.user.deleted'), $display);
152+
$this->assertStringContainsString(trans('command/messages.user.deleted'), $display);
153153
}
154154

155155
/**
@@ -169,7 +169,7 @@ public function testNoInteractionWithMultipleResults()
169169
$display = $this->withoutInteraction()->runCommand($this->command, ['--user' => $user1->username]);
170170

171171
$this->assertNotEmpty($display);
172-
$this->assertContains(trans('command/messages.user.multiple_found'), $display);
172+
$this->assertStringContainsString(trans('command/messages.user.multiple_found'), $display);
173173
}
174174

175175
/**
@@ -183,6 +183,6 @@ public function testNoInteractionWithNoResults()
183183
$display = $this->withoutInteraction()->runCommand($this->command, ['--user' => 123456]);
184184

185185
$this->assertNotEmpty($display);
186-
$this->assertContains(trans('command/messages.user.no_users_found'), $display);
186+
$this->assertStringContainsString(trans('command/messages.user.no_users_found'), $display);
187187
}
188188
}

0 commit comments

Comments
 (0)