Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP][2.3][FrameworkBundle][Templating] Generate assets with absolute url#7722

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
inoryy wants to merge5 commits intosymfony:masterfrominoryy:asset-url
Closed
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Added tests for AbsoluteUrlPackage
  • Loading branch information
@inoryy
inoryy committedApr 19, 2013
commitda3513a9b9c798060d48279f0f6d73d15ce58ae7
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Asset;

use Symfony\Component\Routing\RequestContext;
use Symfony\Bundle\FrameworkBundle\Templating\Asset\AbsoluteUrlPackage;

/**
* This package attempts to return absolute URL for assets
*
* @author Roman Marintšenko <roman.marintsenko@knplabs.com>
*/
class AbsoluteUrlPackageTest extends \PHPUnit_Framework_TestCase
{
public function testGetUrl()
{
$package = new AbsoluteUrlPackage(new RequestContext());
$this->assertEquals('http://example.com/foo.js', $package->getUrl('http://example.com/foo.js'), '->getUrl() does nothing if an absolute URL is already given');

$package = new AbsoluteUrlPackage(new RequestContext('', 'GET', 'symfony.com'));
Copy link
Contributor

Choose a reason for hiding this comment

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

have you tried a dataprovider for this test? just wondering

$this->assertEquals('http://symfony.com/foo.js', $package->getUrl('foo.js'), '->getUrl() prepends host and scheme to a given path');
$this->assertEquals('http://symfony.com/foo.js', $package->getUrl('/foo.js'), '->getUrl() prepends host and scheme to a given absolute path');

$package = new AbsoluteUrlPackage(new RequestContext('foo', 'GET', 'symfony.com'));
$this->assertEquals('http://symfony.com/foo/foo.js', $package->getUrl('foo.js'), '->getUrl() prepends base url to relative path');
$this->assertEquals('http://symfony.com/foo/foo.js', $package->getUrl('/foo.js'), '->getUrl() prepends base url to absolute path');

$package = new AbsoluteUrlPackage(new RequestContext('/foo', 'GET', 'symfony.com'));
$this->assertEquals('http://symfony.com/foo/foo.js', $package->getUrl('foo.js'), '->getUrl() prepends base url with backslash at beginning to relative path');

$package = new AbsoluteUrlPackage(new RequestContext('foo/', 'GET', 'symfony.com'));
$this->assertEquals('http://symfony.com/foo/foo.js', $package->getUrl('foo.js'), '->getUrl() prepends base url with backslash at end to relative path');

$package = new AbsoluteUrlPackage(new RequestContext('', 'GET', 'symfony.com', 'http', 8080));
$this->assertEquals('http://symfony.com:8080/foo.js', $package->getUrl('foo.js'), '->getUrl() prepends port if it is different than 80');

$package = new AbsoluteUrlPackage(new RequestContext('', 'GET', 'symfony.com', 'https', 80, 443));
$this->assertEquals('https://symfony.com/foo.js', $package->getUrl('foo.js'), '->getUrl() does not prepend 443 port if scheme is https');

$package = new AbsoluteUrlPackage(new RequestContext('', 'GET', 'symfony.com', 'https', 80, 444));
$this->assertEquals('https://symfony.com:444/foo.js', $package->getUrl('foo.js'), '->getUrl() prepends port if scheme is https and it is different than 443');

$package = new AbsoluteUrlPackage(new RequestContext('', 'GET', 'symfony.com'), 'abcd');
$this->assertEquals('http://symfony.com/foo.js?abcd', $package->getUrl('foo.js'), '->getUrl() appends the version if defined');
}
}

[8]ページ先頭

©2009-2025 Movatter.jp