예제 #1
0
 /**
  * @param string $file
  * @param string $result
  * @covers Mage_Core_Model_Design_Package::getSkinUrl
  * @dataProvider getViewUrlDataProvider
  * @magentoConfigFixture current_store dev/static/sign 1
  */
 public function testGetViewUrlSigned($devMode, $file, $result)
 {
     Mage::setIsDeveloperMode($devMode);
     $url = $this->_model->getViewFileUrl($file);
     $this->assertEquals(strpos($url, $result), 0);
     $lastModified = array();
     preg_match('/.*\\?(.*)$/i', $url, $lastModified);
     $this->assertArrayHasKey(1, $lastModified);
     $this->assertEquals(10, strlen($lastModified[1]));
     $this->assertLessThanOrEqual(time(), $lastModified[1]);
     $this->assertGreaterThan(1970, date('Y', $lastModified[1]));
 }
예제 #2
0
 /**
  * Get full url for image
  *
  * @param string $imagePath
  *
  * @return string
  */
 protected function _getImageUrl($imagePath)
 {
     if (!in_array($imagePath, array(null, 'no_selection', '/'))) {
         if (pathinfo($imagePath, PATHINFO_EXTENSION) == 'tmp') {
             $imageUrl = $this->_mediaConfig->getTmpMediaUrl(substr($imagePath, 0, -4));
         } else {
             $imageUrl = $this->_mediaConfig->getMediaUrl($imagePath);
         }
     } else {
         $imageUrl = $this->_design->getViewFileUrl('Mage_Adminhtml::images/image-placeholder.png');
     }
     return $imageUrl;
 }
예제 #3
0
 /**
  * Tests what happens when CSS file and its resources are changed - whether they are re-published or not
  *
  * @param bool $expectedPublished
  */
 protected function _testPublishChangedResourcesWhenUnchangedCss($expectedPublished)
 {
     $fixtureViewPath = self::$_fixtureTmpDir . '/frontend/test/default/';
     $publishedPath = self::$_themePublicDir . '/frontend/test/default/en_US/';
     // Prepare temporary fixture directory and publish files from it
     $this->_copyFixtureViewToTmpDir($fixtureViewPath);
     $this->_model->getViewFileUrl('style.css', array('locale' => 'en_US'));
     // Change referenced files
     copy($fixtureViewPath . 'images/rectangle.gif', $fixtureViewPath . 'images/square.gif');
     touch($fixtureViewPath . 'images/square.gif');
     file_put_contents($fixtureViewPath . 'sub.css', '.sub2 {border: 1px solid magenta}', FILE_APPEND);
     $this->_model->getViewFileUrl('style.css', array('locale' => 'en_US'));
     $assertFileComparison = $expectedPublished ? 'assertFileEquals' : 'assertFileNotEquals';
     $this->{$assertFileComparison}($fixtureViewPath . 'sub.css', $publishedPath . 'sub.css');
     $this->{$assertFileComparison}($fixtureViewPath . 'images/rectangle.gif', $publishedPath . 'images/square.gif');
 }