Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fixes #846

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Assetic/Extension/Twig/AsseticExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Assetic/Extension/Twig/AsseticFilterFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
14 changes: 7 additions & 7 deletions tests/Assetic/Test/Asset/HttpAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you should download it over https:// and then it will work?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the relation with /usr/bin/env: node: No such file or directory error?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. I see mentioned error on failed build: https://travis-ci.org/kriswallsmith/assetic/jobs/203755333 , but probably it was failing before this PR as well.


/**
* @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');
}

Expand All @@ -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());
}
Expand All @@ -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');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend doing parse_url on self::ASSET_URL and then using what it returns in assertion. This way less duplication of url fragments in tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer giving the raw value of what I need on assertions.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I respect your coding style, but let's see maintainer opinion on this.

$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');
}
}