From 1c01fcd35c42f93b08622a7f00f129bed01babc4 Mon Sep 17 00:00:00 2001 From: Tomoya Koyanagi Date: Wed, 29 Jul 2015 11:47:10 +0900 Subject: [PATCH] =?UTF-8?q?$conf->path=5Ffiles=20=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- px-files/_sys/tests/apiTest.php | 53 +++++++++++++++++++ .../testData/standard/px-files/config.php | 2 + .../px-files/config_ex/path_files.txt | 1 + 3 files changed, 56 insertions(+) create mode 100755 px-files/_sys/tests/testData/standard/px-files/config_ex/path_files.txt diff --git a/px-files/_sys/tests/apiTest.php b/px-files/_sys/tests/apiTest.php index c503c3f0..27d3be49 100644 --- a/px-files/_sys/tests/apiTest.php +++ b/px-files/_sys/tests/apiTest.php @@ -730,6 +730,59 @@ public function testPxApiIsAnything(){ }//testPxApiIsAnything(); + /** + * dataProvidor: ディレクトリ一覧 + */ + public function confPathFilesProvider(){ + return array( + array('common-ext-dot', '/common/{$dirname}/{$filename}.{$ext}.files/', '/', '/sample_image.png', '/common/index.html.files/sample_image.png'), + array('noslashes', 'common/{$dirname}/{$filename}.{$ext}.files', '/abc/def.html', '/sample_image.png', '/common/abc/def.html.files/sample_image.png'), + array('manyslashes', '/////common/////{$dirname}////{$filename}.{$ext}.files///////', '/', '/sample_image.png', '/common/index.html.files/sample_image.png'), + array('default', '{$dirname}/{$filename}_files/', '/', '/sample_image.png', '/index_files/sample_image.png'), + ); + } + + + /** + * $conf->path_cache を変更して値の変化を確認するテスト + * @depends testPxApiGetAnything + * @depends testPxApiIsAnything + * @dataProvider confPathFilesProvider + */ + public function testConfPathCache($test_name, $conf_path_files, $page_path, $resource_path, $result){ + + // ------------------- + // api.get.path_files + clearstatcache(); + $this->fs->save_file( __DIR__.'/testData/standard/px-files/config_ex/path_files.txt', $conf_path_files ); + clearstatcache(); + $output = $this->passthru( ['php', __DIR__.'/testData/standard/.px_execute.php', $page_path.'?PX=api.get.path_files&path_resource='.urlencode($resource_path)] ); + $this->assertTrue( $this->common_error( $output ) ); + $output = json_decode($output); + // var_dump($output); + $this->assertEquals( $output, $result ); + + // ------------------- + // api.get.realpath_files + $output = $this->passthru( ['php', __DIR__.'/testData/standard/.px_execute.php', $page_path.'?PX=api.get.realpath_files&path_resource='.urlencode($resource_path)] ); + $this->assertTrue( $this->common_error( $output ) ); + $output = json_decode($output); + // var_dump($output); + $this->assertEquals( $output, $this->fs->get_realpath(__DIR__.'/testData/standard'.$result) ); + + + + // 後始末 + $output = $this->passthru( [ + 'php', __DIR__.'/testData/standard/.px_execute.php', '/?PX=clearcache' + ] ); + clearstatcache(); + $this->assertTrue( $this->common_error( $output ) ); + $this->assertFalse( is_dir( __DIR__.'/testData/standard/caches/p/' ) ); + $this->assertFalse( is_dir( __DIR__.'/testData/standard/px-files/_sys/ram/caches/sitemaps/' ) ); + }//testConfPathCache(); + + diff --git a/px-files/_sys/tests/testData/standard/px-files/config.php b/px-files/_sys/tests/testData/standard/px-files/config.php index 3812a98b..ce95ed60 100644 --- a/px-files/_sys/tests/testData/standard/px-files/config.php +++ b/px-files/_sys/tests/testData/standard/px-files/config.php @@ -13,6 +13,8 @@ $conf->path_top = '/'; // トップページのパス(デフォルト "/") $conf->path_publish_dir = null; // パブリッシュ先ディレクトリパス $conf->public_cache_dir = '/caches/'; // 公開キャッシュディレクトリ + clearstatcache(); + $conf->path_files = trim(file_get_contents(__DIR__.'/config_ex/path_files.txt')); $conf->ontents_manifesto = '/common/contents_manifesto.ignore.php'; // Contents Manifesto のパス // directory index diff --git a/px-files/_sys/tests/testData/standard/px-files/config_ex/path_files.txt b/px-files/_sys/tests/testData/standard/px-files/config_ex/path_files.txt new file mode 100755 index 00000000..d3c69897 --- /dev/null +++ b/px-files/_sys/tests/testData/standard/px-files/config_ex/path_files.txt @@ -0,0 +1 @@ +{$dirname}/{$filename}_files/ \ No newline at end of file