aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/filesystem/clean_path_test.php7
-rw-r--r--tests/filesystem/web_root_path_test.php55
2 files changed, 42 insertions, 20 deletions
diff --git a/tests/filesystem/clean_path_test.php b/tests/filesystem/clean_path_test.php
index 88352838bb..b79668fc33 100644
--- a/tests/filesystem/clean_path_test.php
+++ b/tests/filesystem/clean_path_test.php
@@ -14,7 +14,12 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case
public function setUp()
{
parent::setUp();
- $this->filesystem = new phpbb_filesystem(__DIR__ . './../../phpBB/');
+ $this->filesystem = new phpbb_filesystem(
+ new phpbb_symfony_request(
+ new phpbb_mock_request()
+ ),
+ dirname(__FILE__) . './../../phpBB/'
+ );
}
public function clean_path_data()
diff --git a/tests/filesystem/web_root_path_test.php b/tests/filesystem/web_root_path_test.php
index 8e0ba278e0..b681c26de9 100644
--- a/tests/filesystem/web_root_path_test.php
+++ b/tests/filesystem/web_root_path_test.php
@@ -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));
}
}