From 52ebe619fc5a64cad15a23723196220f851d8289 Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Tue, 21 Feb 2017 10:59:53 +0100 Subject: [PATCH 1/2] Deprecate AsseticFilterFunction This class extends \Twig_SimpleFunction which is final since Twig v2. It was used only one time to be a proxy with default options. The class is not used anymore and the option was moved to the AssecitExtension. --- src/Assetic/Extension/Twig/AsseticExtension.php | 6 +++++- src/Assetic/Extension/Twig/AsseticFilterFunction.php | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Assetic/Extension/Twig/AsseticExtension.php b/src/Assetic/Extension/Twig/AsseticExtension.php index 951e1c882..448e46568 100644 --- a/src/Assetic/Extension/Twig/AsseticExtension.php +++ b/src/Assetic/Extension/Twig/AsseticExtension.php @@ -48,7 +48,11 @@ public function getFunctions() { $functions = array(); foreach ($this->functions as $function => $filter) { - $functions[] = new AsseticFilterFunction($function); + $functions[] = new \Twig_SimpleFunction($function, null, array( + 'needs_environment' => false, + 'needs_context' => false, + 'node_class' => '\Assetic\Extension\Twig\AsseticFilterNode', + )); } return $functions; diff --git a/src/Assetic/Extension/Twig/AsseticFilterFunction.php b/src/Assetic/Extension/Twig/AsseticFilterFunction.php index 2c2b13c3d..7fec39a7c 100644 --- a/src/Assetic/Extension/Twig/AsseticFilterFunction.php +++ b/src/Assetic/Extension/Twig/AsseticFilterFunction.php @@ -11,6 +11,9 @@ namespace Assetic\Extension\Twig; +/** + * @deprecated since version 1.5, to be removed in 2.0. + */ class AsseticFilterFunction extends \Twig_SimpleFunction { public function __construct($name, $options = array()) From 7ead54ce8efcbf0fe5d5c9a36703c7fed4e2710a Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Tue, 21 Feb 2017 11:10:32 +0100 Subject: [PATCH 2/2] Change HttpAsset test URL to Bootstrap jQuery seems to not appreciate the downloading: RuntimeException: Unable to load asset from URL "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" --- tests/Assetic/Test/Asset/HttpAssetTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Assetic/Test/Asset/HttpAssetTest.php b/tests/Assetic/Test/Asset/HttpAssetTest.php index d36d2d35c..51440aece 100644 --- a/tests/Assetic/Test/Asset/HttpAssetTest.php +++ b/tests/Assetic/Test/Asset/HttpAssetTest.php @@ -15,14 +15,14 @@ class HttpAssetTest extends \PHPUnit_Framework_TestCase { - const JQUERY = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'; + const ASSET_URL = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'; /** * @group http */ public function testGetLastModified() { - $asset = new HttpAsset(self::JQUERY); + $asset = new HttpAsset(self::ASSET_URL); $this->assertInternalType('integer', $asset->getLastModified(), '->getLastModified() returns an integer'); } @@ -31,7 +31,7 @@ public function testGetLastModified() */ public function testProtocolRelativeUrl() { - $asset = new HttpAsset(substr(self::JQUERY, 5)); + $asset = new HttpAsset(substr(self::ASSET_URL, 6)); $asset->load(); $this->assertNotEmpty($asset->getContent()); } @@ -53,9 +53,9 @@ public function testInvalidUrl() public function testSourceMetadata() { - $asset = new HttpAsset(self::JQUERY); - $this->assertEquals('http://ajax.googleapis.com', $asset->getSourceRoot(), '->__construct() set the source root'); - $this->assertEquals('ajax/libs/jquery/1.6.1/jquery.min.js', $asset->getSourcePath(), '->__construct() set the source path'); - $this->assertEquals('http://ajax.googleapis.com/ajax/libs/jquery/1.6.1', $asset->getSourceDirectory(), '->__construct() sets the source directory'); + $asset = new HttpAsset(self::ASSET_URL); + $this->assertEquals('https://maxcdn.bootstrapcdn.com', $asset->getSourceRoot(), '->__construct() set the source root'); + $this->assertEquals('bootstrap/3.3.7/css/bootstrap.min.css', $asset->getSourcePath(), '->__construct() set the source path'); + $this->assertEquals('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css', $asset->getSourceDirectory(), '->__construct() sets the source directory'); } }