Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/Rector/MethodCall/AssertStatusToAssertMethodRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ public function testUnprocessableEntity()
$this->get('/')->assertStatus(\Illuminate\Http\Response::HTTP_UNPROCESSABLE_ENTITY);
$this->get('/')->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_UNPROCESSABLE_ENTITY);
}

public function testGone()
{
$this->get('/')->assertStatus(410);
$this->get('/')->assertStatus(\Illuminate\Http\Response::HTTP_GONE);
$this->get('/')->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_GONE);
}

public function testInternalServerError()
{
$this->get('/')->assertStatus(500);
$this->get('/')->assertStatus(\Illuminate\Http\Response::HTTP_INTERNAL_SERVER_ERROR);
$this->get('/')->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_INTERNAL_SERVER_ERROR);
}

public function testServiceUnavailable()
{
$this->get('/')->assertStatus(503);
$this->get('/')->assertStatus(\Illuminate\Http\Response::HTTP_SERVICE_UNAVAILABLE);
$this->get('/')->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_SERVICE_UNAVAILABLE);
}
}
CODE_SAMPLE
,
Expand Down Expand Up @@ -114,6 +135,27 @@ public function testUnprocessableEntity()
$this->get('/')->assertUnprocessable();
$this->get('/')->assertUnprocessable();
}

public function testGone()
{
$this->get('/')->assertGone();
$this->get('/')->assertGone();
$this->get('/')->assertGone();
}

public function testInternalServerError()
{
$this->get('/')->assertInternalServerError();
$this->get('/')->assertInternalServerError();
$this->get('/')->assertInternalServerError();
}

public function testServiceUnavailable()
{
$this->get('/')->asserServiceUnavailable();
$this->get('/')->asserServiceUnavailable();
$this->get('/')->asserServiceUnavailable();
}
}
CODE_SAMPLE
),
Expand Down Expand Up @@ -165,7 +207,10 @@ private function updateAssertStatusCall(MethodCall $methodCall): ?MethodCall
401 => 'assertUnauthorized',
403 => 'assertForbidden',
404 => 'assertNotFound',
410 => 'assertGone',
422 => 'assertUnprocessable',
500 => 'assertInternalServerError',
503 => 'assertServiceUnavailable',
default => null
};
} else {
Expand All @@ -182,7 +227,10 @@ private function updateAssertStatusCall(MethodCall $methodCall): ?MethodCall
'HTTP_UNAUTHORIZED' => 'assertUnauthorized',
'HTTP_FORBIDDEN' => 'assertForbidden',
'HTTP_NOT_FOUND' => 'assertNotFound',
'HTTP_GONE' => 'assertGone',
'HTTP_UNPROCESSABLE_ENTITY' => 'assertUnprocessable',
'HTTP_INTERNAL_SERVER_ERROR' => 'assertInternalServerError',
'HTTP_SERVICE_UNAVAILABLE' => 'assertServiceUnavailable',
default => null
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function test(string $filePath): void
$this->doTestFile($filePath);
}

public function provideData(): Iterator
public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ class FixtureWithIlluminateTest
{
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_UNPROCESSABLE_ENTITY);
}

public function testGone(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_GONE);
}

public function testInternalServerError(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_INTERNAL_SERVER_ERROR);
}

public function testServiceUnavailable(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_SERVICE_UNAVAILABLE);
}
}

?>
Expand Down Expand Up @@ -72,6 +87,21 @@ class FixtureWithIlluminateTest
{
$response->assertUnprocessable();
}

public function testGone(\Illuminate\Testing\TestResponse $response)
{
$response->assertGone();
}

public function testInternalServerError(\Illuminate\Testing\TestResponse $response)
{
$response->assertInternalServerError();
}

public function testServiceUnavailable(\Illuminate\Testing\TestResponse $response)
{
$response->assertServiceUnavailable();
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ class FixtureTest
{
$response->assertStatus(422);
}

public function testGone(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(410);
}

public function testInternalServerError(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(500);
}

public function testServiceUnavailable(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(503);
}
}

?>
Expand Down Expand Up @@ -72,6 +87,21 @@ class FixtureTest
{
$response->assertUnprocessable();
}

public function testGone(\Illuminate\Testing\TestResponse $response)
{
$response->assertGone();
}

public function testInternalServerError(\Illuminate\Testing\TestResponse $response)
{
$response->assertInternalServerError();
}

public function testServiceUnavailable(\Illuminate\Testing\TestResponse $response)
{
$response->assertServiceUnavailable();
}
}

?>