Skip to content

Commit 2aabb3e

Browse files
miladrahimiMilad Rahimi
authored andcommitted
clean up tests
1 parent 5b96a0e commit 2aabb3e

File tree

4 files changed

+130
-83
lines changed

4 files changed

+130
-83
lines changed

tests/GroupedMappingTest.php renamed to tests/GroupingTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
use MiladRahimi\PhpRouter\Tests\Classes\SampleMiddleware;
1515
use Throwable;
1616

17-
class GroupedMappingTest extends TestCase
17+
class GroupingTest extends TestCase
1818
{
1919
/**
2020
* @throws Throwable
2121
*/
22-
public function test_simple_group_routing()
22+
public function test_simple_group()
2323
{
24-
$router = $this->createRouterWithMockedProperties();
24+
$router = $this->createRouter();
2525

2626
$router->group([], function (Router $router) {
2727
$router->map('GET', '/', $this->simpleController());
@@ -35,15 +35,15 @@ public function test_simple_group_routing()
3535
/**
3636
* @throws Throwable
3737
*/
38-
public function test_group_routing_with_middleware()
38+
public function test_middleware_object()
3939
{
4040
$groupMiddleware = new SampleMiddleware(777);
4141

4242
$groupAttributes = [
4343
RouteAttributes::MIDDLEWARE => $groupMiddleware,
4444
];
4545

46-
$router = $this->createRouterWithMockedProperties();
46+
$router = $this->createRouter();
4747

4848
$router->group($groupAttributes, function (Router $router) {
4949
$router->map('GET', '/', $this->simpleController());
@@ -58,13 +58,13 @@ public function test_group_routing_with_middleware()
5858
/**
5959
* @throws Throwable
6060
*/
61-
public function test_group_routing_with_string_middleware()
61+
public function test_string_middleware()
6262
{
6363
$groupAttributes = [
6464
RouteAttributes::MIDDLEWARE => SampleMiddleware::class,
6565
];
6666

67-
$router = $this->createRouterWithMockedProperties();
67+
$router = $this->createRouter();
6868

6969
$router->group($groupAttributes, function (Router $router) {
7070
$router->map('GET', '/', $this->simpleController());
@@ -78,7 +78,7 @@ public function test_group_routing_with_string_middleware()
7878
/**
7979
* @throws Throwable
8080
*/
81-
public function test_group_routing_with_a_group_and_a_route_middleware()
81+
public function test_middleware_it_should_ignore_group_middleware_where_route_middleware_is_present()
8282
{
8383
$groupMiddleware = new SampleMiddleware(1001);
8484
$routeMiddleware = new SampleMiddleware(1002);
@@ -87,7 +87,7 @@ public function test_group_routing_with_a_group_and_a_route_middleware()
8787
RouteAttributes::MIDDLEWARE => $groupMiddleware,
8888
];
8989

90-
$router = $this->createRouterWithMockedProperties();
90+
$router = $this->createRouter();
9191

9292
$router->group($groupAttributes, function (Router $router) use ($routeMiddleware) {
9393
$router->map('GET', '/', $this->simpleController(), $routeMiddleware);
@@ -103,15 +103,15 @@ public function test_group_routing_with_a_group_and_a_route_middleware()
103103
/**
104104
* @throws Throwable
105105
*/
106-
public function test_group_routing_with_prefix()
106+
public function test_prefix()
107107
{
108108
$this->mockRequest(HttpMethods::GET, 'http://example.com/group/page');
109109

110110
$groupAttributes = [
111111
RouteAttributes::PREFIX => '/group',
112112
];
113113

114-
$router = $this->createRouterWithMockedProperties();
114+
$router = $this->createRouter();
115115

116116
$router->group($groupAttributes, function (Router $router) {
117117
$router->map('GET', '/page', $this->simpleController());
@@ -125,15 +125,15 @@ public function test_group_routing_with_prefix()
125125
/**
126126
* @throws Throwable
127127
*/
128-
public function test_group_routing_with_domain()
128+
public function test_domain()
129129
{
130130
$this->mockRequest(HttpMethods::GET, 'http://sub.domain.tld/');
131131

132132
$groupAttributes = [
133133
RouteAttributes::DOMAIN => 'sub.domain.tld',
134134
];
135135

136-
$router = $this->createRouterWithMockedProperties();
136+
$router = $this->createRouter();
137137

138138
$router->group($groupAttributes, function (Router $router) {
139139
$router->map('GET', '/', $this->simpleController());
@@ -147,15 +147,15 @@ public function test_group_routing_with_domain()
147147
/**
148148
* @throws Throwable
149149
*/
150-
public function test_group_routing_with_domains_it_should_ignore_group_domain_when_the_route_has_one()
150+
public function test_domain_it_should_ignore_group_domain_where_route_domain_is_present()
151151
{
152152
$this->mockRequest(HttpMethods::GET, 'http://sub2.domain.tld/');
153153

154154
$groupAttributes = [
155155
RouteAttributes::DOMAIN => 'sub1.domain.tld',
156156
];
157157

158-
$router = $this->createRouterWithMockedProperties();
158+
$router = $this->createRouter();
159159

160160
$router->group($groupAttributes, function (Router $router) {
161161
$router->map('GET', '/', $this->simpleController(), [], 'sub2.domain.tld');
@@ -169,9 +169,9 @@ public function test_group_routing_with_domains_it_should_ignore_group_domain_wh
169169
/**
170170
* @throws Throwable
171171
*/
172-
public function test_simple_group_routing_it_should_remove_existing_name_before_the_group()
172+
public function test_naming_it_should_remove_existing_name_before_the_group()
173173
{
174-
$router = $this->createRouterWithMockedProperties();
174+
$router = $this->createRouter();
175175

176176
$router->useName('NameForNothing');
177177

tests/ResponseTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class ResponseTest extends TestCase
2222
*/
2323
public function test_empty_response_with_code_204()
2424
{
25-
$router = $this->createRouterWithMockedProperties();
25+
$router = $this->createRouter();
2626

27-
$router->map('GET', '/', function() {
27+
$router->map('GET', '/', function () {
2828
return new EmptyResponse(204);
2929
});
3030

@@ -38,9 +38,9 @@ public function test_empty_response_with_code_204()
3838
*/
3939
public function test_html_response_with_code_200()
4040
{
41-
$router = $this->createRouterWithMockedProperties();
41+
$router = $this->createRouter();
4242

43-
$router->map('GET', '/', function() {
43+
$router->map('GET', '/', function () {
4444
return new HtmlResponse('<html></html>', 200);
4545
});
4646

@@ -55,9 +55,9 @@ public function test_html_response_with_code_200()
5555
*/
5656
public function test_json_response_with_code_201()
5757
{
58-
$router = $this->createRouterWithMockedProperties();
58+
$router = $this->createRouter();
5959

60-
$router->map('GET', '/', function() {
60+
$router->map('GET', '/', function () {
6161
return new JsonResponse(['a' => 'x', 'b' => 'y'], 201);
6262
});
6363

@@ -72,9 +72,9 @@ public function test_json_response_with_code_201()
7272
*/
7373
public function test_text_response_with_code_203()
7474
{
75-
$router = $this->createRouterWithMockedProperties();
75+
$router = $this->createRouter();
7676

77-
$router->map('GET', '/', function() {
77+
$router->map('GET', '/', function () {
7878
return new TextResponse('Content', 203);
7979
});
8080

@@ -89,9 +89,9 @@ public function test_text_response_with_code_203()
8989
*/
9090
public function test_redirect_response_with_code_203()
9191
{
92-
$router = $this->createRouterWithMockedProperties();
92+
$router = $this->createRouter();
9393

94-
$router->map('GET', '/', function() {
94+
$router->map('GET', '/', function () {
9595
return new RedirectResponse('https://miladrahimi.com');
9696
});
9797

@@ -101,4 +101,4 @@ public function test_redirect_response_with_code_203()
101101
$this->assertEquals('', $this->getPublisher($router)->output);
102102
$this->assertContains('location: https://miladrahimi.com', $this->getPublisher($router)->headerLines);
103103
}
104-
}
104+
}

0 commit comments

Comments
 (0)