Commit f3296754 authored by webchick's avatar webchick

Issue #2330751 by dawehner, chx: Fixed Random test failures everywhere due to...

Issue #2330751 by dawehner, chx: Fixed Random test failures everywhere due to ->with(Request::create()).
parent e52aaf1e
......@@ -74,21 +74,21 @@ protected function setUp() {
public function testCreateFromPath() {
$this->router->expects($this->at(0))
->method('matchRequest')
->with(Request::create('/node'))
->with($this->getRequestConstraint('/node'))
->willReturn([
RouteObjectInterface::ROUTE_NAME => 'view.frontpage.page_1',
'_raw_variables' => new ParameterBag(),
]);
$this->router->expects($this->at(1))
->method('matchRequest')
->with(Request::create('/node/1'))
->with($this->getRequestConstraint('/node/1'))
->willReturn([
RouteObjectInterface::ROUTE_NAME => 'node_view',
'_raw_variables' => new ParameterBag(['node' => '1']),
]);
$this->router->expects($this->at(2))
->method('matchRequest')
->with(Request::create('/node/2/edit'))
->with($this->getRequestConstraint('/node/2/edit'))
->willReturn([
RouteObjectInterface::ROUTE_NAME => 'node_edit',
'_raw_variables' => new ParameterBag(['node' => '2']),
......@@ -104,6 +104,21 @@ public function testCreateFromPath() {
return $urls;
}
/**
* This constraint checks whether a Request object has the right path.
*
* @param string $path
* The path.
*
* @return \PHPUnit_Framework_Constraint_Callback
* The constraint checks whether a Request object has the right path.
*/
protected function getRequestConstraint($path) {
return $this->callback(function (Request $request) use ($path) {
return $request->getPathInfo() == $path;
});
}
/**
* Tests the createFromPath method with the special <front> path.
*
......@@ -124,7 +139,7 @@ public function testCreateFromPathFront() {
public function testCreateFromPathInvalid() {
$this->router->expects($this->once())
->method('matchRequest')
->with(Request::create('/non-existent'))
->with($this->getRequestConstraint('/non-existent'))
->will($this->throwException(new ResourceNotFoundException()));
$this->assertNull(Url::createFromPath('non-existent'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment