1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 08:47:45 +02:00

[ticket/11832] Create phpbb_symfony_request to handle initiating symfony_request

Now symfony_request is also a service (removed the function
phpbb_create_symfony_request).

Inject symfony request into filesystem

Cleanup for the tests

PHPBB3-11832
This commit is contained in:
Nathan Guse
2013-09-13 09:52:02 -05:00
parent a194e6ce7a
commit aa710df2db
7 changed files with 110 additions and 75 deletions

View File

@@ -18,7 +18,8 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
$this->set_phpbb_root_path();
$this->filesystem = new phpbb_filesystem($this->phpbb_root_path);
$symfony_request = new phpbb_symfony_request(new phpbb_mock_request());
$this->filesystem = new phpbb_filesystem($symfony_request, $this->phpbb_root_path);
}
/**
@@ -40,13 +41,14 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
$this->assertEquals($this->phpbb_root_path, $this->filesystem->get_web_root_path());
}
public function update_web_root_path_data()
public function basic_update_web_root_path_data()
{
$this->set_phpbb_root_path();
return array(
array(
$this->phpbb_root_path . 'test.php',
$this->phpbb_root_path . 'test.php',
),
array(
'test.php',
@@ -54,7 +56,24 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
),
array(
$this->phpbb_root_path . $this->phpbb_root_path . 'test.php',
$this->phpbb_root_path . $this->phpbb_root_path . 'test.php',
),
);
}
/**
* @dataProvider basic_update_web_root_path_data
*/
public function test_basic_update_web_root_path($input, $expected)
{
$this->assertEquals($expected, $this->filesystem->update_web_root_path($input, $symfony_request));
}
public function update_web_root_path_data()
{
$this->set_phpbb_root_path();
return array(
array(
$this->phpbb_root_path . 'test.php',
$this->phpbb_root_path . 'test.php',
@@ -92,25 +111,23 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
/**
* @dataProvider update_web_root_path_data
*/
public function test_update_web_root_path($input, $expected = null, $getPathInfo = null, $getRequestUri = null, $getScriptName = null)
public function test_update_web_root_path($input, $expected, $getPathInfo, $getRequestUri = null, $getScriptName = null)
{
$expected = ($expected === null) ? $input : $expected;
$symfony_request = $this->getMock("phpbb_symfony_request", array(), array(
new phpbb_mock_request(),
));
$symfony_request->expects($this->any())
->method('getPathInfo')
->will($this->returnValue($getPathInfo));
$symfony_request->expects($this->any())
->method('getRequestUri')
->will($this->returnValue($getRequestUri));
$symfony_request->expects($this->any())
->method('getScriptName')
->will($this->returnValue($getScriptName));
$symfony_request = null;
if ($getPathInfo !== null)
{
$symfony_request = $this->getMock("Symfony\Component\HttpFoundation\Request");
$symfony_request->expects($this->any())
->method('getPathInfo')
->will($this->returnValue($getPathInfo));
$symfony_request->expects($this->any())
->method('getRequestUri')
->will($this->returnValue($getRequestUri));
$symfony_request->expects($this->any())
->method('getScriptName')
->will($this->returnValue($getScriptName));
}
$filesystem = new phpbb_filesystem($symfony_request, $this->phpbb_root_path);
$this->assertEquals($expected, $this->filesystem->update_web_root_path($input, $symfony_request));
$this->assertEquals($expected, $filesystem->update_web_root_path($input, $symfony_request));
}
}