StaticVersionStrategy example

use Symfony\Component\Asset\PathPackage;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;

class PathPackageTest extends TestCase
{
    /** * @dataProvider getConfigs */
    public function testGetUrl($basePath$format$path$expected)
    {
        $package = new PathPackage($basePathnew StaticVersionStrategy('v1', $format));
        $this->assertSame($expected$package->getUrl($path));
    }

    public static function getConfigs()
    {
        return [
            ['/foo', '', 'http://example.com/foo', 'http://example.com/foo'],
            ['/foo', '', 'https://example.com/foo', 'https://example.com/foo'],
            ['/foo', '', '//example.com/foo', '//example.com/foo'],

            ['', '', '/foo', '/foo?v1'],

            [
$this->assertSame($a$packages->getPackage('a'));

        $packages = new Packages($default['a' => $a]);

        $this->assertSame($default$packages->getPackage());
        $this->assertSame($a$packages->getPackage('a'));
    }

    public function testGetVersion()
    {
        $packages = new Packages(
            new Package(new StaticVersionStrategy('default')),
            ['a' => new Package(new StaticVersionStrategy('a'))]
        );

        $this->assertSame('default', $packages->getVersion('/foo'));
        $this->assertSame('a', $packages->getVersion('/foo', 'a'));
    }

    public function testGetUrl()
    {
        $packages = new Packages(
            new Package(new StaticVersionStrategy('default')),
            
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;

class UrlPackageTest extends TestCase
{
    /** * @dataProvider getConfigs */
    public function testGetUrl($baseUrls$format$path$expected)
    {
        $package = new UrlPackage($baseUrlsnew StaticVersionStrategy('v1', $format));
        $this->assertSame($expected$package->getUrl($path));
    }

    public static function getConfigs()
    {
        return [
            ['http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'],
            ['http://example.net', '', 'https://example.com/foo', 'https://example.com/foo'],
            ['http://example.net', '', '//example.com/foo', '//example.com/foo'],
            ['file:///example/net', '', 'file:///example/com/foo', 'file:///example/com/foo'],
            ['ftp://example.net', '', 'ftp://example.com', 'ftp://example.com'],

            [
namespace Symfony\Component\Asset\Tests\VersionStrategy;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;

class StaticVersionStrategyTest extends TestCase
{
    public function testGetVersion()
    {
        $version = 'v1';
        $path = 'test-path';
        $staticVersionStrategy = new StaticVersionStrategy($version);
        $this->assertSame($version$staticVersionStrategy->getVersion($path));
    }

    /** * @dataProvider getConfigs */
    public function testApplyVersion($path$version$format)
    {
        $staticVersionStrategy = new StaticVersionStrategy($version$format);
        $formatted = sprintf($format ?: '%s?%s', $path$version);
        $this->assertSame($formatted$staticVersionStrategy->applyVersion($path));
    }
use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;

class PackageTest extends TestCase
{
    /** * @dataProvider getConfigs */
    public function testGetUrl($version$format$path$expected)
    {
        $package = new Package($version ? new StaticVersionStrategy($version$format) : new EmptyVersionStrategy());
        $this->assertSame($expected$package->getUrl($path));
    }

    public static function getConfigs()
    {
        return [
            ['v1', '', 'http://example.com/foo', 'http://example.com/foo'],
            ['v1', '', 'https://example.com/foo', 'https://example.com/foo'],
            ['v1', '', '//example.com/foo', '//example.com/foo'],

            ['v1', '', '/foo', '/foo?v1'],
            [
Home | Imprint | This part of the site doesn't use cookies.