StaticVersionStrategyTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Asset\Tests\VersionStrategy;
  11. use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
  12. class StaticVersionStrategyTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testGetVersion()
  15. {
  16. $version = 'v1';
  17. $path = 'test-path';
  18. $staticVersionStrategy = new StaticVersionStrategy($version);
  19. $this->assertEquals($version, $staticVersionStrategy->getVersion($path));
  20. }
  21. /**
  22. * @dataProvider getConfigs
  23. */
  24. public function testApplyVersion($path, $version, $format)
  25. {
  26. $staticVersionStrategy = new StaticVersionStrategy($version, $format);
  27. $formatted = sprintf($format ?: '%s?%s', $path, $version);
  28. $this->assertEquals($formatted, $staticVersionStrategy->applyVersion($path));
  29. }
  30. public function getConfigs()
  31. {
  32. return array(
  33. array('test-path', 'v1', null),
  34. array('test-path', 'v2', '%s?test%s'),
  35. );
  36. }
  37. }