You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.5KB

  1. <?php
  2. /*
  3. * This file is part of the Fxp Composer Asset Plugin package.
  4. *
  5. * (c) François Pluchino <francois.pluchino@gmail.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 Fxp\Composer\AssetPlugin\Tests\Converter;
  11. use Fxp\Composer\AssetPlugin\Converter\PackageConverterInterface;
  12. use Fxp\Composer\AssetPlugin\Tests\Fixtures\Converter\InvalidPackageConverter;
  13. use Fxp\Composer\AssetPlugin\Type\AssetTypeInterface;
  14. /**
  15. * Abstract tests of asset package converter.
  16. *
  17. * @author François Pluchino <francois.pluchino@gmail.com>
  18. */
  19. abstract class AbstractPackageConverterTest extends \PHPUnit_Framework_TestCase
  20. {
  21. /**
  22. * @var AssetTypeInterface
  23. */
  24. protected $type;
  25. /**
  26. * @var PackageConverterInterface
  27. */
  28. protected $converter;
  29. /**
  30. * @var array
  31. */
  32. protected $asset;
  33. protected function setUp()
  34. {
  35. $versionConverter = $this->getMock('Fxp\Composer\AssetPlugin\Converter\VersionConverterInterface');
  36. $versionConverter->expects($this->any())
  37. ->method('convertVersion')
  38. ->will($this->returnCallback(function ($value) {
  39. return $value;
  40. }));
  41. $versionConverter->expects($this->any())
  42. ->method('convertRange')
  43. ->will($this->returnCallback(function ($value) {
  44. return $value;
  45. }));
  46. $type = $this->getMock('Fxp\Composer\AssetPlugin\Type\AssetTypeInterface');
  47. $type->expects($this->any())
  48. ->method('getComposerVendorName')
  49. ->will($this->returnValue('ASSET'));
  50. $type->expects($this->any())
  51. ->method('getComposerType')
  52. ->will($this->returnValue('ASSET_TYPE'));
  53. $type->expects($this->any())
  54. ->method('getVersionConverter')
  55. ->will($this->returnValue($versionConverter));
  56. $type->expects($this->any())
  57. ->method('formatComposerName')
  58. ->will($this->returnCallback(function ($value) {
  59. return 'ASSET/'.$value;
  60. }));
  61. $this->type = $type;
  62. }
  63. protected function tearDown()
  64. {
  65. $this->type = null;
  66. $this->converter = null;
  67. $this->asset = array();
  68. }
  69. public function testConversionWithInvalidKey()
  70. {
  71. $this->setExpectedException('InvalidArgumentException');
  72. $this->converter = new InvalidPackageConverter($this->type);
  73. $this->converter->convert(array(
  74. 'name' => 'foo',
  75. ));
  76. }
  77. }