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.

116 lines
4.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\BowerPackageConverter;
  12. use Fxp\Composer\AssetPlugin\Type\AssetTypeInterface;
  13. /**
  14. * Tests of bower package converter.
  15. *
  16. * @author François Pluchino <francois.pluchino@gmail.com>
  17. */
  18. class BowerPackageConverterTest extends AbstractPackageConverterTest
  19. {
  20. protected function setUp()
  21. {
  22. parent::setUp();
  23. /* @var AssetTypeInterface $type */
  24. $type = $this->type;
  25. $this->converter = new BowerPackageConverter($type);
  26. $this->asset = (array) json_decode(file_get_contents(__DIR__.'/../Fixtures/package/bower.json'), true);
  27. }
  28. public function testConvert()
  29. {
  30. $composer = $this->converter->convert($this->asset);
  31. $this->assertArrayHasKey('name', $composer);
  32. $this->assertSame('ASSET/'.$this->asset['name'], $composer['name']);
  33. $this->assertArrayHasKey('type', $composer);
  34. $this->assertSame('ASSET_TYPE', $composer['type']);
  35. $this->assertArrayHasKey('description', $composer);
  36. $this->assertSame($this->asset['description'], $composer['description']);
  37. $this->assertArrayHasKey('version', $composer);
  38. $this->assertSame('1.0.0-pre', $composer['version']);
  39. $this->assertArrayHasKey('keywords', $composer);
  40. $this->assertSame($this->asset['keywords'], $composer['keywords']);
  41. $this->assertArrayHasKey('require', $composer);
  42. $this->assertSame(array(
  43. 'ASSET/library1' => '>= 1.0.0',
  44. 'ASSET/library2' => '>= 1.0.0',
  45. 'ASSET/library2-0.9.0' => '0.9.0',
  46. 'ASSET/library3' => '*',
  47. 'ASSET/library4' => '1.2.3',
  48. 'ASSET/library5' => 'dev-default#0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b',
  49. 'ASSET/library6' => 'dev-branch',
  50. 'ASSET/library7' => 'dev-1.2.* || 1.2.*',
  51. 'ASSET/library8' => 'dev-1.2.x || 1.2.x',
  52. 'ASSET/library9' => 'dev-master',
  53. 'ASSET/library10' => '1.0.0',
  54. 'ASSET/library11' => '*',
  55. 'ASSET/library12' => '>=1 <2',
  56. 'ASSET/library13' => '>=1 <2',
  57. 'ASSET/library14' => '*',
  58. 'ASSET/library15' => '*',
  59. 'ASSET/library16' => '>=1 <2',
  60. 'ASSET/test-library17-file' => '*',
  61. 'ASSET/test-library18-file' => '1.2.3',
  62. 'ASSET/test-library19-file' => '*',
  63. ), $composer['require']);
  64. $this->assertArrayHasKey('require-dev', $composer);
  65. $this->assertSame(array(
  66. 'ASSET/dev-library1' => '>= 1.0.0',
  67. 'ASSET/dev-library2' => '>= 1.0.0',
  68. 'ASSET/dev-library2-0.9.0' => '0.9.0',
  69. ), $composer['require-dev']);
  70. $this->assertArrayHasKey('license', $composer);
  71. $this->assertSame($this->asset['license'], $composer['license']);
  72. $this->assertArrayHasKey('bin', $composer);
  73. $this->assertSame($this->asset['bin'], $composer['bin']);
  74. $this->assertArrayHasKey('extra', $composer);
  75. $this->assertArrayHasKey('bower-asset-main', $composer['extra']);
  76. $this->assertSame($this->asset['main'], $composer['extra']['bower-asset-main']);
  77. $this->assertArrayHasKey('bower-asset-ignore', $composer['extra']);
  78. $this->assertSame($this->asset['ignore'], $composer['extra']['bower-asset-ignore']);
  79. $this->assertArrayHasKey('bower-asset-private', $composer['extra']);
  80. $this->assertSame($this->asset['private'], $composer['extra']['bower-asset-private']);
  81. $this->assertArrayNotHasKey('homepage', $composer);
  82. $this->assertArrayNotHasKey('time', $composer);
  83. $this->assertArrayNotHasKey('authors', $composer);
  84. $this->assertArrayNotHasKey('support', $composer);
  85. $this->assertArrayNotHasKey('conflict', $composer);
  86. $this->assertArrayNotHasKey('replace', $composer);
  87. $this->assertArrayNotHasKey('provide', $composer);
  88. $this->assertArrayNotHasKey('suggest', $composer);
  89. $this->assertArrayNotHasKey('autoload', $composer);
  90. $this->assertArrayNotHasKey('autoload-dev', $composer);
  91. $this->assertArrayNotHasKey('include-path', $composer);
  92. $this->assertArrayNotHasKey('target-dir', $composer);
  93. $this->assertArrayNotHasKey('archive', $composer);
  94. }
  95. }