|
|
|
@ -45,13 +45,15 @@ final class AppTest extends TestCase { |
|
|
|
|
* @depends testInit |
|
|
|
|
* @dataProvider apiRewriteProvider |
|
|
|
|
* @covers App::update_SERVERIfNeeded |
|
|
|
|
* @param string $rootFolder, |
|
|
|
|
* @param string $filePath, |
|
|
|
|
* @param string $shortScriptName, |
|
|
|
|
* @param string $queryString, |
|
|
|
|
* @param string $waitedBaseUrl, |
|
|
|
|
* @param string $waitedPageId, |
|
|
|
|
* @param string $waitedPageUrl, |
|
|
|
|
* @param string $rootFolder |
|
|
|
|
* @param string $filePath |
|
|
|
|
* @param string $shortScriptName |
|
|
|
|
* @param string $queryString |
|
|
|
|
* @param string $waitedBaseUrl |
|
|
|
|
* @param string $waitedPageId |
|
|
|
|
* @param string $waitedPageUrl |
|
|
|
|
* @param string $waitedThemesUrl |
|
|
|
|
* @param string $waitedPluginsUrl |
|
|
|
|
*/ |
|
|
|
|
public function testApiRewrite( |
|
|
|
|
string $rootFolder, |
|
|
|
@ -61,6 +63,8 @@ final class AppTest extends TestCase { |
|
|
|
|
string $waitedBaseUrl, |
|
|
|
|
string $waitedPageId, |
|
|
|
|
string $waitedPageUrl, |
|
|
|
|
string $waitedThemesUrl, |
|
|
|
|
string $waitedPluginsUrl, |
|
|
|
|
): void |
|
|
|
|
{ |
|
|
|
|
$this->saveSERVER(); |
|
|
|
@ -94,6 +98,13 @@ final class AppTest extends TestCase { |
|
|
|
|
$this->assertEquals($waitedPageId,$currentPage['id'],"Not waited page's id"); |
|
|
|
|
$this->assertArrayHasKey('url',$currentPage,"Current Page should be an array with key 'url'"); |
|
|
|
|
$this->assertEquals($waitedPageUrl,$currentPage['url'],"Not waited page's url"); |
|
|
|
|
$twigVariables = $foundTh->getTwigVariables(); |
|
|
|
|
$this->assertIsArray($twigVariables,"Twigvariables should be an array"); |
|
|
|
|
$this->assertArrayHasKey('themes_url',$twigVariables,"Twigvariables should be an array with key 'themes_url'"); |
|
|
|
|
$this->assertEquals($waitedThemesUrl,$twigVariables['themes_url'],"Not waited themes_url"); |
|
|
|
|
$this->assertArrayHasKey('plugins_url',$twigVariables,"Twigvariables should be an array with key 'plugins_url'"); |
|
|
|
|
$this->assertEquals($waitedPluginsUrl,$twigVariables['plugins_url'],"Not waited plugins_url"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function apiRewriteProvider() |
|
|
|
@ -165,7 +176,8 @@ final class AppTest extends TestCase { |
|
|
|
|
if ($canRewriteFromRoot){ |
|
|
|
|
$this->prepareData($data,$name."*",$rootFolder,"index.php",$scriptName,$queryData['q'],$waitedUrl,$pageId,$pageUrl); |
|
|
|
|
} |
|
|
|
|
$this->prepareData($data,$name,$rootFolder,"$rootFolder/$pageIdInUrl/index.php",$scriptName,$queryData['q'],$waitedUrl,$pageId,$pageUrl); |
|
|
|
|
$formattedRootMiddle = empty($pageIdInUrl) ? '' : "/$pageIdInUrl"; |
|
|
|
|
$this->prepareData($data,$name,$rootFolder,"$rootFolder$formattedRootMiddle/index.php",$scriptName,$queryData['q'],$waitedUrl,$pageId,$pageUrl); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -180,10 +192,17 @@ final class AppTest extends TestCase { |
|
|
|
|
string $queryString, |
|
|
|
|
string $waitedBaseUrl, |
|
|
|
|
string $waitedPageId, |
|
|
|
|
string $waitedPageEndUrl, |
|
|
|
|
string $waitedPageEndUrl |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
$waitedPageUrl = $waitedBaseUrl.$waitedPageEndUrl; |
|
|
|
|
$nbLevels = in_array($shortScriptName,['/','/index.php']) ? 0 : count(explode('/',$rootFolder)); |
|
|
|
|
$prefix = implode('/',array_fill(0,$nbLevels,'..')); |
|
|
|
|
if (!empty($prefix)){ |
|
|
|
|
$prefix .= '/'; |
|
|
|
|
} |
|
|
|
|
$waitedThemesUrl = $waitedBaseUrl.$prefix.'vendor/picocms/themes'; |
|
|
|
|
$waitedPluginsUrl = $waitedBaseUrl.$prefix.'vendor/picocms/plugins'; |
|
|
|
|
$data[$name] = compact([ |
|
|
|
|
'rootFolder', |
|
|
|
|
'filePath', |
|
|
|
@ -191,7 +210,9 @@ final class AppTest extends TestCase { |
|
|
|
|
'queryString', |
|
|
|
|
'waitedBaseUrl', |
|
|
|
|
'waitedPageId', |
|
|
|
|
'waitedPageUrl' |
|
|
|
|
'waitedPageUrl', |
|
|
|
|
'waitedThemesUrl', |
|
|
|
|
'waitedPluginsUrl' |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|