Find the best Rector rule to solve your problem. Searching through 1004 rules.
Found 4 rules, grouped by set: Clear
Testing
4 matches
Replace (new \Illuminate\Testing\TestResponse)->assertStatus(200) with (new \Illuminate\Testing\TestResponse)->assertOk()
class ExampleTest extends \Illuminate\Foundation\Testing\TestCase
{
public function testFoo()
{
- $this->get('/')->assertStatus(200);
- $this->get('/')->assertStatus(201);
- $this->get('/')->assertStatus(202);
- $this->get('/')->assertStatus(204);
- $this->get('/')->assertStatus(301);
- $this->get('/')->assertStatus(302);
- $this->get('/')->assertStatus(304);
- $this->get('/')->assertStatus(307);
- $this->get('/')->assertStatus(308);
- $this->get('/')->assertStatus(400);
- $this->get('/')->assertStatus(401);
- $this->get('/')->assertStatus(402);
- $this->get('/')->assertStatus(403);
- $this->get('/')->assertStatus(404);
- $this->get('/')->assertStatus(405);
- $this->get('/')->assertStatus(406);
- $this->get('/')->assertStatus(408);
- $this->get('/')->assertStatus(409);
- $this->get('/')->assertStatus(410);
- $this->get('/')->assertStatus(415);
- $this->get('/')->assertStatus(422);
- $this->get('/')->assertStatus(424);
- $this->get('/')->assertStatus(429);
- $this->get('/')->assertStatus(500);
- $this->get('/')->assertStatus(503);
+ $this->get('/')->assertOk();
+ $this->get('/')->assertCreated();
+ $this->get('/')->assertAccepted();
+ $this->get('/')->assertNoContent();
+ $this->get('/')->assertMovedPermanently();
+ $this->get('/')->assertFound();
+ $this->get('/')->assertNotModified();
+ $this->get('/')->assertTemporaryRedirect();
+ $this->get('/')->assertPermanentRedirect();
+ $this->get('/')->assertBadRequest();
+ $this->get('/')->assertUnauthorized();
+ $this->get('/')->assertPaymentRequired();
+ $this->get('/')->assertForbidden();
+ $this->get('/')->assertNotFound();
+ $this->get('/')->assertMethodNotAllowed();
+ $this->get('/')->assertNotAcceptable();
+ $this->get('/')->assertRequestTimeout();
+ $this->get('/')->assertConflict();
+ $this->get('/')->assertGone();
+ $this->get('/')->assertUnsupportedMediaType();
+ $this->get('/')->assertUnprocessable();
+ $this->get('/')->assertFailedDependency();
+ $this->get('/')->assertTooManyRequests();
+ $this->get('/')->assertInternalServerError();
+ $this->get('/')->assertServiceUnavailable();
}
}
Change method calls from $this->json to $this->postJson, $this->putJson, etc.
-$this->json("POST", "/api/v1/users", $data);
+$this->postJson("/api/v1/users", $data);
Use the $this->travelTo() method in Laravel's TestCase class instead of the Carbon::setTestNow() method.
use Illuminate\Support\Carbon;
use Illuminate\Foundation\Testing\TestCase;
class SomeTest extends TestCase
{
public function test()
{
- Carbon::setTestNow('2024-08-11');
+ $this->travelTo('2024-08-11');
}
}
Changes assert calls to use a type hinted closure.
-Bus::assertDispatched(OrderCreated::class, function ($job) {
+Bus::assertDispatched(function (OrderCreated $job) {
return true;
});