Skip to content

Commit

Permalink
$conf->path_files のテスト追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tomk79 committed Jul 29, 2015
1 parent de1d5c1 commit 1c01fcd
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
53 changes: 53 additions & 0 deletions px-files/_sys/tests/apiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();





Expand Down
2 changes: 2 additions & 0 deletions px-files/_sys/tests/testData/standard/px-files/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{$dirname}/{$filename}_files/

0 comments on commit 1c01fcd

Please sign in to comment.