mirror of
https://github.com/e107inc/e107.git
synced 2025-08-13 18:14:26 +02:00
Closes #5191 - Match static URL to previously called/generated static url when present.
This commit is contained in:
@@ -381,6 +381,60 @@ class e_jsmanagerTest extends \Codeception\Test\Unit
|
||||
$this->assertTrue($result, $var['expected'] . " was not found in the rendered links. Render links result:" . $actual . "\n\n");
|
||||
}
|
||||
|
||||
// -----------------
|
||||
$static = [
|
||||
'https://static.mydomain.com/',
|
||||
'https://static2.mydomain.com/',
|
||||
'https://static3.mydomain.com/',
|
||||
];
|
||||
|
||||
$tp->setStaticUrl(null);
|
||||
e107::getParser()->setStaticUrl($static);
|
||||
|
||||
$staticTests = [
|
||||
0 => array(
|
||||
'expected' => '<link rel="preload" href="https://static.mydomain.com/e107_web/script.js?0" as="script" />',
|
||||
'input' => array('rel' => 'preload', 'href' => '{e_WEB}script.js', 'as' => 'script'),
|
||||
'cacheid' => true,
|
||||
'static' => true,
|
||||
),
|
||||
1 => array(
|
||||
'expected' => '<link rel="preload" as="image" type="image/jpeg" href="https://static.mydomain.com/e107_themes/bootstrap3/image/header.jpg" media="(max-width: 415px)" />',
|
||||
'input' => ['rel'=>'preload', 'as'=>'image', 'type'=> "image/jpeg", 'href'=>THEME_ABS.'image/header.jpg', 'media'=>"(max-width: 415px)"],
|
||||
'cacheid' => false,
|
||||
'static' => true,
|
||||
),
|
||||
2 => array(
|
||||
'expected' => '<link rel="preload" as="image" type="image/jpeg" href="https://static.mydomain.com/e107_themes/bootstrap3/image/header.jpg" media="(max-width: 415px)" />',
|
||||
'input' => ['rel'=>'preload', 'as'=>'image', 'type'=> "image/jpeg", 'href'=>THEME_ABS.'image/header.jpg', 'media'=>"(max-width: 415px)"],
|
||||
'cacheid' => false,
|
||||
'static' => true,
|
||||
),
|
||||
3 => array(
|
||||
'expected' => '<link rel="preload" as="image" type="image/jpeg" href="https://static.mydomain.com/e107_themes/bootstrap3/image/header.jpg" media="(max-width: 415px)" />',
|
||||
'input' => ['rel'=>'preload', 'as'=>'image', 'type'=> "image/jpeg", 'href'=>THEME_ABS.'image/header.jpg', 'media'=>"(max-width: 415px)"],
|
||||
'cacheid' => false,
|
||||
'static' => true,
|
||||
),
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
foreach($staticTests as $var)
|
||||
{
|
||||
$this->js->addLink($var['input'], $var['cacheid']);
|
||||
}
|
||||
|
||||
$actual = $this->js->renderLinks(true);
|
||||
|
||||
|
||||
foreach($staticTests as $var)
|
||||
{
|
||||
$result = (strpos($actual, $var['expected']) !== false);
|
||||
self::assertTrue($result, $var['expected'] . " was not found in the rendered links. Render links result:" . $actual . "\n\n");
|
||||
}
|
||||
|
||||
$tp->setStaticUrl(null);
|
||||
|
||||
|
||||
|
@@ -1798,7 +1798,7 @@ EXPECTED;
|
||||
// Test with Static Array
|
||||
|
||||
$static = [
|
||||
'https://static.mydomain.com/',
|
||||
'https://static1.mydomain.com/',
|
||||
'https://static2.mydomain.com/',
|
||||
'https://static3.mydomain.com/',
|
||||
];
|
||||
@@ -1806,7 +1806,7 @@ EXPECTED;
|
||||
$this->tp->setStaticUrl($static);
|
||||
$tests = [
|
||||
1 => array(
|
||||
'expected' => 'https://static.mydomain.com/e107_themes/bootstrap3/images/myimage1.jpg',
|
||||
'expected' => 'https://static1.mydomain.com/e107_themes/bootstrap3/images/myimage1.jpg',
|
||||
'input' => '{THEME}images/myimage1.jpg',
|
||||
'static' => true,
|
||||
),
|
||||
@@ -1820,9 +1820,14 @@ EXPECTED;
|
||||
'input' => '{THEME}images/myimage3.jpg',
|
||||
'static' => true,
|
||||
),
|
||||
4 => array(
|
||||
'expected' => 'https://static.mydomain.com/e107_themes/bootstrap3/images/myimage4.jpg',
|
||||
'input' => '{THEME}images/myimage4.jpg',
|
||||
4 => array( // test that previously generated static URL retains the same static domain when called again.
|
||||
'expected' => 'https://static3.mydomain.com/e107_themes/bootstrap3/images/myimage3.jpg',
|
||||
'input' => '{THEME}images/myimage3.jpg',
|
||||
'static' => true,
|
||||
),
|
||||
5 => array( // test that previously generated static URL retains the same static domain when called again.
|
||||
'expected' => 'https://static2.mydomain.com/e107_themes/bootstrap3/images/myimage2.jpg',
|
||||
'input' => '{THEME}images/myimage2.jpg',
|
||||
'static' => true,
|
||||
),
|
||||
|
||||
@@ -1835,7 +1840,7 @@ EXPECTED;
|
||||
}
|
||||
|
||||
$map = $this->tp->getStaticUrlMap();
|
||||
self::assertStringContainsString('myimage2.jpg', $map['e107-themes/bootstrap3/images/myimage2.jpg'] );
|
||||
self::assertStringContainsString('https://static2.mydomain.com', $map['e107-themes/bootstrap3/images/myimage2.jpg'] );
|
||||
|
||||
$this->tp->setStaticUrl(null);
|
||||
}
|
||||
|
Reference in New Issue
Block a user