Skip to content

Commit

Permalink
Fixed typo in method name
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbyoung committed Jan 4, 2025
1 parent ba56a2d commit dfba578
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Routing/IRouteRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ interface IRouteRequestFactory
* @throws RouteRequestCreationException Thrown if there was an error generating the request
* @throws InvalidArgumentException Thrown if the the method is null and the route supports multiple methods
*/
public function createRouteUri(string $routeName, array $routeVariables = [], ?string $method = null): IRequest;
public function createRouteRequest(string $routeName, array $routeVariables = [], ?string $method = null): IRequest;
}
2 changes: 1 addition & 1 deletion src/Routing/RouteRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(private readonly RouteCollection $routes, ?IRouteUri
/**
* @inheritdoc
*/
public function createRouteUri(string $routeName, array $routeVariables = [], ?string $method = null): IRequest
public function createRouteRequest(string $routeName, array $routeVariables = [], ?string $method = null): IRequest
{
if (($route = $this->routes->getNamedRoute($routeName)) === null) {
throw new OutOfBoundsException("Route \"$routeName\" does not exist");
Expand Down
26 changes: 13 additions & 13 deletions tests/Routing/RouteRequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function foo(): void
}
};
$this->addRouteWithUriTemplate('foo', 'GET', null, '/foo', $controller, 'foo');
$request = $this->factory->createRouteUri('foo');
$request = $this->factory->createRouteRequest('foo');
$this->assertSame('GET', $request->method);
}

Expand All @@ -61,14 +61,14 @@ public function foo(): void
};
$this->expectExceptionMessage('Failed to reflect ' . $controller::class . '::bar');
$this->addRouteWithUriTemplate('foo', 'GET', null, '/foo', $controller, 'bar');
$this->factory->createRouteUri('foo');
$this->factory->createRouteRequest('foo');
}

public function testCreatingRequestForNonExistentRouteThrowsException(): void
{
$this->expectException(OutOfBoundsException::class);
$this->expectExceptionMessage("Route \"foo\" does not exist");
$this->factory->createRouteUri('foo');
$this->factory->createRouteRequest('foo');
}

public function testCreatingRequestForRouteWithMultipleMethodsAndNotSpecifyingAMethodThrowsException(): void
Expand All @@ -81,7 +81,7 @@ public function foo(): void
}
};
$this->addRouteWithUriTemplate('foo', ['GET', 'POST'], null, '/foo', $controller, 'foo');
$this->factory->createRouteUri('foo');
$this->factory->createRouteRequest('foo');
}

public function testCreatingRequestForRouteWitSingleNonGetMethodCreatesRequestForThatMethod(): void
Expand All @@ -92,7 +92,7 @@ public function foo(): void
}
};
$this->addRouteWithUriTemplate('foo', ['POST'], null, '/foo', $controller, 'foo');
$request = $this->factory->createRouteUri('foo');
$request = $this->factory->createRouteRequest('foo');
$this->assertSame('POST', $request->method);
}

Expand All @@ -106,7 +106,7 @@ public function foo(#[Header] string $foo): void
}
};
$this->addRouteWithUriTemplate('foo', 'GET', null, '/foo', $controller, 'foo');
$this->factory->createRouteUri('foo');
$this->factory->createRouteRequest('foo');
}

public function testCreatingRequestWithDefaultValueHeaderParameterSetsHeaderValueToDefaultValue(): void
Expand All @@ -117,7 +117,7 @@ public function foo(#[Header] string $foo = 'bar'): void
}
};
$this->addRouteWithUriTemplate('foo', 'GET', null, '/foo', $controller, 'foo');
$request = $this->factory->createRouteUri('foo');
$request = $this->factory->createRouteRequest('foo');
$this->assertSame('bar', $request->headers->getFirst('foo'));
}

Expand All @@ -129,7 +129,7 @@ public function foo(#[Header] string $foo): void
}
};
$this->addRouteWithUriTemplate('foo', 'GET', null, '/foo', $controller, 'foo');
$request = $this->factory->createRouteUri('foo', ['foo' => 'bar']);
$request = $this->factory->createRouteRequest('foo', ['foo' => 'bar']);
$this->assertSame('bar', $request->headers->getFirst('foo'));
}

Expand All @@ -141,7 +141,7 @@ public function foo(#[Header('bar')] string $foo): void
}
};
$this->addRouteWithUriTemplate('foo', 'GET', null, '/foo', $controller, 'foo');
$request = $this->factory->createRouteUri('foo', ['bar' => 'baz']);
$request = $this->factory->createRouteRequest('foo', ['bar' => 'baz']);
$this->assertSame('baz', $request->headers->getFirst('bar'));
}

Expand All @@ -153,7 +153,7 @@ public function foo(#[Header] string $foo): void
}
};
$this->addRouteWithUriTemplate('foo', 'GET', 'example.com', '/foo', $controller, 'foo');
$request = $this->factory->createRouteUri('foo', ['foo' => 'bar']);
$request = $this->factory->createRouteRequest('foo', ['foo' => 'bar']);
$this->assertSame('GET', $request->method);
$this->assertSame('https://example.com/foo', (string)$request->uri);
$this->assertSame('bar', $request->headers->getFirst('foo'));
Expand All @@ -167,7 +167,7 @@ public function foo(#[Header] string $foo, #[RouteVariable] string $bar, #[Query
}
};
$this->addRouteWithUriTemplate('foo', 'GET', null, '/:bar', $controller, 'foo');
$request = $this->factory->createRouteUri('foo', ['foo' => '1', 'bar' => '2', 'baz' => '3']);
$request = $this->factory->createRouteRequest('foo', ['foo' => '1', 'bar' => '2', 'baz' => '3']);
$this->assertSame('GET', $request->method);
$this->assertSame('/2?baz=3', (string)$request->uri);
$this->assertSame('1', $request->headers->getFirst('foo'));
Expand All @@ -181,7 +181,7 @@ public function foo(#[Header] string $foo): void
}
};
$this->addRouteWithUriTemplate('foo', 'GET', null, '/foo', $controller, 'foo');
$request = $this->factory->createRouteUri('foo', ['foo' => 'bar']);
$request = $this->factory->createRouteRequest('foo', ['foo' => 'bar']);
$this->assertSame('GET', $request->method);
$this->assertSame('/foo', (string)$request->uri);
$this->assertSame('bar', $request->headers->getFirst('foo'));
Expand All @@ -202,7 +202,7 @@ public function foo(): void
->method('createRouteUri')
->willThrowException(new RouteUriCreationException('foo'));
$factory = new RouteRequestFactory($this->routes, $uriFactory);
$factory->createRouteUri('foo');
$factory->createRouteRequest('foo');
}

/**
Expand Down

0 comments on commit dfba578

Please sign in to comment.