Skip to content

Commit 0bdd91e

Browse files
committed
compatible PHP 7.2
1 parent ffb4ccc commit 0bdd91e

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

src/Console/ParallelCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Recca0120\LaravelParallel\Console;
44

5+
use Carbon\Carbon;
56
use Exception;
67
use Illuminate\Contracts\Auth\Authenticatable;
78
use Illuminate\Contracts\Database\ModelIdentifier;
89
use Illuminate\Contracts\Foundation\Application;
910
use Illuminate\Foundation\Testing\Concerns\MakesHttpRequests;
1011
use Illuminate\Queue\SerializesAndRestoresModelIdentifiers;
11-
use Illuminate\Support\Carbon;
1212
use Illuminate\Support\Facades\Auth;
1313
use Recca0120\LaravelParallel\ResponseIdentifier;
1414
use Symfony\Component\Console\Command\Command;
@@ -71,7 +71,7 @@ protected function configure(): void
7171
$this->addOption('disableCookieEncryption', null, InputOption::VALUE_REQUIRED);
7272
$this->addOption('user', null, InputOption::VALUE_OPTIONAL);
7373
$this->addOption('guard', null, InputOption::VALUE_OPTIONAL);
74-
$this->addOption('date', null, InputOption::VALUE_OPTIONAL);
74+
$this->addOption('testNow', null, InputOption::VALUE_OPTIONAL);
7575
}
7676

7777
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -96,7 +96,7 @@ private function makeRequest(InputInterface $input): Response
9696
->handleFollowRedirects($input)
9797
->handleWithCredentials($input)
9898
->handleAuthenticatable($input)
99-
->handleDate($input);
99+
->handleTestNow($input);
100100

101101
return $this->makeTestResponse($input)->baseResponse;
102102
}
@@ -186,12 +186,12 @@ private function handleWithoutMiddleware(InputInterface $input): self
186186
return $this;
187187
}
188188

189-
private function handleDate(InputInterface $input): self
189+
private function handleTestNow(InputInterface $input): self
190190
{
191-
$date = $input->getOption('date');
191+
$testNow = $input->getOption('testNow');
192192

193-
if (! empty($date)) {
194-
Carbon::setTestNow($date);
193+
if (! empty($testNow)) {
194+
Carbon::setTestNow($testNow);
195195
}
196196

197197
return $this;

src/ParallelRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Recca0120\LaravelParallel;
44

5+
use Carbon\Carbon;
56
use GuzzleHttp\Promise\PromiseInterface;
67
use Illuminate\Http\Request;
78
use Illuminate\Http\Response;
8-
use Illuminate\Support\Carbon;
99
use Recca0120\LaravelParallel\Concerns\InteractsWithAuthentication;
1010
use Recca0120\LaravelParallel\Concerns\MakesHttpRequests;
1111
use Recca0120\LaravelParallel\Console\ParallelCommand;
@@ -97,7 +97,7 @@ private function toParams(
9797
'--disableCookieEncryption' => ! $this->encryptCookies,
9898
'--user' => $this->user,
9999
'--guard' => $this->guard,
100-
'--date' => Carbon::getTestNow()?->toIso8601String(),
100+
'--testNow' => Carbon::getTestNow() ? Carbon::getTestNow()->toIso8601String() : null,
101101
'--ansi',
102102
];
103103
}

tests/Fixtures/artisan

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<?php
33

44
use Illuminate\Http\Request;
5-
use Illuminate\Support\Carbon;
65
use Illuminate\Support\Facades\Auth;
76
use Illuminate\Support\Facades\Session;
87
use Orchestra\Testbench\Concerns\CreatesApplication;
@@ -15,10 +14,9 @@ use Symfony\Component\Console\Input\InputArgument;
1514
use Symfony\Component\Console\Input\InputInterface;
1615
use Symfony\Component\Console\Output\OutputInterface;
1716

18-
require_once __DIR__ . '/../../vendor/autoload.php';
17+
require_once __DIR__.'/../../vendor/autoload.php';
1918

20-
$laravel = new class()
21-
{
19+
$laravel = new class() {
2220
use CreatesApplication;
2321
use setupDatabase;
2422
use HandlesRoutes;
@@ -105,8 +103,8 @@ $laravel = new class()
105103
return response()->json($request->user());
106104
});
107105

108-
$router->middleware('web')->get('/date', function (Request $request) {
109-
return Carbon::now()->toIso8601String();
106+
$router->middleware('web')->get('/test-now', function (Request $request) {
107+
return now()->toIso8601String();
110108
});
111109
}
112110

@@ -130,8 +128,8 @@ class EchoCommand extends Command
130128
}
131129

132130
/**
133-
* @param InputInterface $input
134-
* @param OutputInterface $output
131+
* @param InputInterface $input
132+
* @param OutputInterface $output
135133
* @return int
136134
*/
137135
protected function execute(InputInterface $input, OutputInterface $output): int

tests/ParallelRequestTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Recca0120\LaravelParallel\Tests;
44

5+
use Carbon\Carbon;
56
use Illuminate\Auth\GenericUser;
6-
use Illuminate\Support\Carbon;
77
use Recca0120\LaravelParallel\Tests\Fixtures\User;
88
use Throwable;
99

@@ -174,10 +174,9 @@ public function test_it_should_set_test_date(): void
174174
Carbon::setTestNow($testDate);
175175

176176
$request = ParallelRequest::create();
177+
$response = $request->get('/test-now')->wait();
177178

178-
$response = $request->get('/date')->wait();
179-
180-
$response->assertOk()->assertContent($testDate->toIso8601String());
179+
$response->assertOk()->assertSee($testDate->toIso8601String());
181180
}
182181

183182
/**

0 commit comments

Comments
 (0)