Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1059 from alexispeter/issue-1036
Browse files Browse the repository at this point in the history
Remove "cdnResource" and "cdnUserContent" from "CM_Render"-config
  • Loading branch information
alexispeter committed Mar 7, 2014
2 parents 5f7ed56 + 72ad48e commit 352564e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 63 deletions.
8 changes: 4 additions & 4 deletions library/CM/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function getUrlResource($type = null, $path = null) {
}
$urlPath .= '/' . $this->getSite()->getId() . '/' . CM_App::getInstance()->getDeployVersion() . '/' . $path;
}
return $this->getUrl($urlPath, self::_getConfig()->cdnResource);
return $this->getUrl($urlPath, true);
}

/**
Expand All @@ -338,7 +338,7 @@ public function getUrlStatic($path = null) {
if (null !== $path) {
$urlPath .= $path . '?' . CM_App::getInstance()->getDeployVersion();
}
return $this->getUrl($urlPath, self::_getConfig()->cdnResource);
return $this->getUrl($urlPath, true);
}

/**
Expand All @@ -347,9 +347,9 @@ public function getUrlStatic($path = null) {
*/
public function getUrlUserContent(CM_File_UserContent $file = null) {
if (is_null($file)) {
return $this->getUrl('/userfiles', self::_getConfig()->cdnUserContent);
return $this->getUrl('/userfiles', true);
}
return $this->getUrl('/userfiles/' . $file->getPathRelative(), self::_getConfig()->cdnUserContent);
return $this->getUrl('/userfiles/' . $file->getPathRelative(), true);
}

/**
Expand Down
3 changes: 0 additions & 3 deletions resources/config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

$config->timeZone = 'US/Central';

$config->CM_Render->cdnResource = true;
$config->CM_Render->cdnUserContent = true;

$config->CM_Mail->send = true;
$config->CM_Mail->mailDeliveryAgent = null;

Expand Down
56 changes: 27 additions & 29 deletions tests/library/CM/Asset/CssTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,9 @@ class CM_Asset_CssTest extends CMTest_TestCase {
/** @var CM_Render */
private $_render;

public static function setUpBeforeClass() {
CM_Config::get()->CM_Render->cdnResource = false;
CM_Config::get()->CM_Render->cdnUserContent = false;
CM_Config::get()->CM_Site_MockCss = new stdClass;
CM_Config::get()->CM_Site_MockCss->url = 'http://www.example.dev';
}

public function setUp() {
$site = $this->getMockForAbstractClass('CM_Site_Abstract', array(), 'CM_Site_MockCss', true, true, true, array('getId'));
$site->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->_render = new CM_Render($site);
}

public function testAdd() {
$css = new CM_Asset_Css($this->_render, 'font-size: 12;', '#foo');
$render = new CM_Render();
$css = new CM_Asset_Css($render, 'font-size: 12;', '#foo');
$css1 = <<<'EOD'
.test:visible {
color: black;
Expand All @@ -43,33 +31,37 @@ public function testAdd() {
}

public function testImage() {
$css = new CM_Asset_Css($this->_render, "background: image('icon/mailbox_read.png') no-repeat 66px 7px;");
$url = $this->_render->getUrlResource('layout', 'img/icon/mailbox_read.png');
$render = new CM_Render();
$css = new CM_Asset_Css($render, "background: image('icon/mailbox_read.png') no-repeat 66px 7px;");
$url = $render->getUrlResource('layout', 'img/icon/mailbox_read.png');
$expected = <<<EOD
background: url('$url') no-repeat 66px 7px;
EOD;
$this->assertEquals($expected, $css->get());
}

public function testBackgroundImage() {
$css = new CM_Asset_Css($this->_render, "background-image: image('icon/mailbox_read.png');");
$url = $this->_render->getUrlResource('layout', 'img/icon/mailbox_read.png');
$render = new CM_Render();
$css = new CM_Asset_Css($render, "background-image: image('icon/mailbox_read.png');");
$url = $render->getUrlResource('layout', 'img/icon/mailbox_read.png');
$expected = <<<EOD
background-image: url('$url');
EOD;
$this->assertEquals($expected, $css->get());
}

public function testUrlFont() {
$css = new CM_Asset_Css($this->_render, "src: url(urlFont('file.eot'));");
$url = $this->_render->getUrlStatic('/font/file.eot');
$render = new CM_Render();
$css = new CM_Asset_Css($render, "src: url(urlFont('file.eot'));");
$url = $render->getUrlStatic('/font/file.eot');
$expected = <<<EOD
src: url('$url');
EOD;
$this->assertEquals($expected, $css->get());
}

public function testMixin() {
$render = new CM_Render();
$css = <<<'EOD'
.mixin() {
font-size:5;
Expand All @@ -83,7 +75,7 @@ public function testMixin() {
.mixin;
}
EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$expected = <<<'EOD'
.foo {
color: red;
Expand All @@ -99,6 +91,7 @@ public function testMixin() {
}

public function testLinearGradient() {
$render = new CM_Render();
//horizontal
$css = <<<'EOD'
.foo {
Expand All @@ -117,7 +110,7 @@ public function testLinearGradient() {
}

EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$this->assertSame($expected, $css->get());
//vertical
$css = <<<'EOD'
Expand All @@ -137,7 +130,7 @@ public function testLinearGradient() {
}

EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$this->assertSame($expected, $css->get());
//illegal parameters
$css = <<<'EOD'
Expand All @@ -149,11 +142,12 @@ public function testLinearGradient() {
.gradient(foo, #000000, rgba(30, 50,30, 0.4));
}
EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$this->assertSame('', $css->get());
}

public function testBoxSizing() {
$render = new CM_Render();
$css = <<<'EOD'
.foo {
.box-sizing(border-box);
Expand All @@ -167,11 +161,12 @@ public function testBoxSizing() {
}

EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$this->assertSame($expected, $css->get());
}

public function testUserSelect() {
$render = new CM_Render();
$css = <<<'EOD'
.foo {
.user-select(none);
Expand All @@ -186,11 +181,12 @@ public function testUserSelect() {
}

EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$this->assertSame($expected, $css->get());
}

public function testTransform() {
$render = new CM_Render();
$css = <<<'EOD'
.foo {
.transform(matrix(0.866,0.5,-0.5,0.866,0,0));
Expand All @@ -206,11 +202,12 @@ public function testTransform() {
}

EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$this->assertSame($expected, $css->get());
}

public function testTransition() {
$render = new CM_Render();
$css = <<<'EOD'
.foo {
.transition(width 2s ease-in 2s);
Expand All @@ -224,11 +221,12 @@ public function testTransition() {
}

EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$this->assertSame($expected, $css->get());
}

public function testMedia() {
$render = new CM_Render();
$css = <<<'EOD'
.foo {
color: blue;
Expand All @@ -248,7 +246,7 @@ public function testMedia() {
}

EOD;
$css = new CM_Asset_Css($this->_render, $css);
$css = new CM_Asset_Css($render, $css);
$this->assertSame($expected, $css->get());
}
}
17 changes: 0 additions & 17 deletions tests/library/CM/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

class CM_RenderTest extends CMTest_TestCase {

public function setUp() {
CM_Config::get()->CM_Render->cdnResource = false;
CM_Config::get()->CM_Render->cdnUserContent = false;
}

public function tearDown() {
CMTest_TH::clearEnv();
}
Expand Down Expand Up @@ -104,12 +99,6 @@ public function testGetUrlResource() {
$render = new CM_Render();
$siteType = CM_Site_Abstract::factory()->getType();
$deployVersion = CM_App::getInstance()->getDeployVersion();
$this->assertSame('http://www.default.dev', $render->getUrlResource());
$this->assertSame('http://www.default.dev', $render->getUrlResource('layout'));
$this->assertSame('http://www.default.dev', $render->getUrlResource(null, 'foo/bar.jpg'));
$this->assertSame(
'http://www.default.dev/layout/' . $siteType . '/' . $deployVersion . '/foo/bar.jpg', $render->getUrlResource('layout', 'foo/bar.jpg'));
CM_Config::get()->CM_Render->cdnResource = true;
$this->assertSame('http://cdn.default.dev', $render->getUrlResource());
$this->assertSame('http://cdn.default.dev', $render->getUrlResource('layout'));
$this->assertSame('http://cdn.default.dev', $render->getUrlResource(null, 'foo/bar.jpg'));
Expand All @@ -122,10 +111,6 @@ public function testGetUrlResource() {
public function testGetUrlStatic() {
$render = new CM_Render();
$deployVersion = CM_App::getInstance()->getDeployVersion();
$this->assertSame('http://www.default.dev/static', $render->getUrlStatic());
$this->assertSame('http://www.default.dev/static/foo.jpg?' . $deployVersion, $render->getUrlStatic('/foo.jpg'));

CM_Config::get()->CM_Render->cdnResource = true;
$this->assertSame('http://cdn.default.dev/static', $render->getUrlStatic());
$this->assertSame('http://cdn.default.dev/static/foo.jpg?' . $deployVersion, $render->getUrlStatic('/foo.jpg'));
$this->assertSame('http://cdn.default.dev/static/0?' . $deployVersion, $render->getUrlStatic('/0'));
Expand All @@ -135,8 +120,6 @@ public function testGetUrlUserContent() {
$render = new CM_Render();
$userFile = $this->getMock('CM_File_UserContent', array('getPathRelative'), array(), '', false);
$userFile->expects($this->any())->method('getPathRelative')->will($this->returnValue('foo/bar.jpg'));
$this->assertSame('http://www.default.dev/userfiles/foo/bar.jpg', $render->getUrlUserContent($userFile));
CM_Config::get()->CM_Render->cdnUserContent = true;
$this->assertSame('http://cdn.default.dev/userfiles/foo/bar.jpg', $render->getUrlUserContent($userFile));
}

Expand Down
5 changes: 1 addition & 4 deletions tests/library/CM/SmartyPlugins/function.usertextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ public function setUp() {
$render = new CM_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $render);

CM_Config::get()->CM_Render->cdnResource = false;
CM_Config::get()->CM_Render->cdnUserContent = false;
}

public function tearDown() {
Expand Down Expand Up @@ -80,7 +77,7 @@ public function testIsMail() {
$emoticonId = CM_Db_Db::insert('cm_emoticon', array('code' => ':smiley:', 'codeAdditional' => ':-)', 'file' => '1.png'));

$this->_assertSame(
'<span class="usertext oneline">foo <img src="http://www.default.dev/layout//' . CM_App::getInstance()->getDeployVersion() .
'<span class="usertext oneline">foo <img src="http://cdn.default.dev/layout//' . CM_App::getInstance()->getDeployVersion() .
'/img/emoticon/1.png" class="emoticon emoticon-' .
$emoticonId . '" title=":smiley:" height="16" /></span>',
array('text' => 'foo :-)', 'mode' => 'oneline', 'isMail' => true));
Expand Down
9 changes: 3 additions & 6 deletions tests/library/CM/Usertext/Filter/EmoticonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ class CM_Usertext_Filter_EmoticonTest extends CMTest_TestCase {
protected $_mockSite;

public function setUp() {
$this->_mockSite = $this->getMockSite(null, 24, null, 'http://www.default.dev');
$this->_mockSite = $this->getMockSite(null, 24, null, 'http://www.default.dev', 'http://cdn.default.dev');
foreach ($this->_emoticonData as $emoticonCode => $emoticonData) {
$emoticonData['code'] = $emoticonCode;
$this->_emoticonId[$emoticonCode] = CM_Db_Db::insert('cm_emoticon', $emoticonData);
}

CM_Config::get()->CM_Render->cdnResource = false;
CM_Config::get()->CM_Render->cdnUserContent = false;
}

public function tearDown() {
Expand Down Expand Up @@ -66,13 +63,13 @@ public function testFalseSmileys() {
}

protected function _getEmoticonImg($emoticonCode, $height = null) {
$siteUrl = $this->_mockSite->getUrl();
$urlCdn = $this->_mockSite->getUrlCdn();
$siteType = $this->_mockSite->getId();
$deployVersion = CM_App::getInstance()->getDeployVersion();
$emoticonFile = $this->_emoticonData[$emoticonCode]['file'];
$emoticonId = $this->_emoticonId[$emoticonCode];
$heightAttribute = $height ? ' height="' . $height . '"' : '';
return '<img src="' . $siteUrl . '/layout/' . $siteType . '/' . $deployVersion . '/img/emoticon/' . $emoticonFile .
return '<img src="' . $urlCdn . '/layout/' . $siteType . '/' . $deployVersion . '/img/emoticon/' . $emoticonFile .
'" class="emoticon emoticon-' . $emoticonId . '" title="' . $emoticonCode . '"' . $heightAttribute . ' />';
}
}

0 comments on commit 352564e

Please sign in to comment.