]> git.mxchange.org Git - friendica-addons.git/blob
36a4c717fa07a5630e7a9fae1f573ebbfe6b3c7c
[friendica-addons.git] /
1 <?php
2
3 /*
4  * This file is part of the Fxp Composer Asset Plugin package.
5  *
6  * (c) François Pluchino <francois.pluchino@gmail.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Fxp\Composer\AssetPlugin\Tests\Converter;
13
14 use Fxp\Composer\AssetPlugin\Converter\BowerPackageConverter;
15 use Fxp\Composer\AssetPlugin\Type\AssetTypeInterface;
16
17 /**
18  * Tests of bower package converter.
19  *
20  * @author François Pluchino <francois.pluchino@gmail.com>
21  */
22 class BowerPackageConverterTest extends AbstractPackageConverterTest
23 {
24     protected function setUp()
25     {
26         parent::setUp();
27
28         /* @var AssetTypeInterface $type */
29         $type = $this->type;
30         $this->converter = new BowerPackageConverter($type);
31         $this->asset = (array) json_decode(file_get_contents(__DIR__.'/../Fixtures/package/bower.json'), true);
32     }
33
34     public function testConvert()
35     {
36         $composer = $this->converter->convert($this->asset);
37
38         $this->assertArrayHasKey('name', $composer);
39         $this->assertSame('ASSET/'.$this->asset['name'], $composer['name']);
40
41         $this->assertArrayHasKey('type', $composer);
42         $this->assertSame('ASSET_TYPE', $composer['type']);
43
44         $this->assertArrayHasKey('description', $composer);
45         $this->assertSame($this->asset['description'], $composer['description']);
46
47         $this->assertArrayHasKey('version', $composer);
48         $this->assertSame('1.0.0-pre', $composer['version']);
49
50         $this->assertArrayHasKey('keywords', $composer);
51         $this->assertSame($this->asset['keywords'], $composer['keywords']);
52
53         $this->assertArrayHasKey('require', $composer);
54         $this->assertSame(array(
55             'ASSET/library1' => '>= 1.0.0',
56             'ASSET/library2' => '>= 1.0.0',
57             'ASSET/library2-0.9.0' => '0.9.0',
58             'ASSET/library3' => '*',
59             'ASSET/library4' => '1.2.3',
60             'ASSET/library5' => 'dev-default#0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b',
61             'ASSET/library6' => 'dev-branch',
62             'ASSET/library7' => 'dev-1.2.* || 1.2.*',
63             'ASSET/library8' => 'dev-1.2.x || 1.2.x',
64             'ASSET/library9' => 'dev-master',
65             'ASSET/library10' => '1.0.0',
66             'ASSET/library11' => '*',
67             'ASSET/library12' => '>=1 <2',
68             'ASSET/library13' => '>=1 <2',
69             'ASSET/library14' => '*',
70             'ASSET/library15' => '*',
71             'ASSET/library16' => '>=1 <2',
72             'ASSET/test-library17-file' => '*',
73             'ASSET/test-library18-file' => '1.2.3',
74             'ASSET/test-library19-file' => '*',
75             'ASSET/test-library20-file' => '*',
76         ), $composer['require']);
77
78         $this->assertArrayHasKey('require-dev', $composer);
79         $this->assertSame(array(
80             'ASSET/dev-library1' => '>= 1.0.0',
81             'ASSET/dev-library2' => '>= 1.0.0',
82             'ASSET/dev-library2-0.9.0' => '0.9.0',
83         ), $composer['require-dev']);
84
85         $this->assertArrayHasKey('license', $composer);
86         $this->assertSame($this->asset['license'], $composer['license']);
87
88         $this->assertArrayHasKey('bin', $composer);
89         $this->assertSame($this->asset['bin'], $composer['bin']);
90
91         $this->assertArrayHasKey('extra', $composer);
92
93         $this->assertArrayHasKey('bower-asset-main', $composer['extra']);
94         $this->assertSame($this->asset['main'], $composer['extra']['bower-asset-main']);
95
96         $this->assertArrayHasKey('bower-asset-ignore', $composer['extra']);
97         $this->assertSame($this->asset['ignore'], $composer['extra']['bower-asset-ignore']);
98
99         $this->assertArrayHasKey('bower-asset-private', $composer['extra']);
100         $this->assertSame($this->asset['private'], $composer['extra']['bower-asset-private']);
101
102         $this->assertArrayNotHasKey('homepage', $composer);
103         $this->assertArrayNotHasKey('time', $composer);
104         $this->assertArrayNotHasKey('authors', $composer);
105         $this->assertArrayNotHasKey('support', $composer);
106         $this->assertArrayNotHasKey('conflict', $composer);
107         $this->assertArrayNotHasKey('replace', $composer);
108         $this->assertArrayNotHasKey('provide', $composer);
109         $this->assertArrayNotHasKey('suggest', $composer);
110         $this->assertArrayNotHasKey('autoload', $composer);
111         $this->assertArrayNotHasKey('autoload-dev', $composer);
112         $this->assertArrayNotHasKey('include-path', $composer);
113         $this->assertArrayNotHasKey('target-dir', $composer);
114         $this->assertArrayNotHasKey('archive', $composer);
115     }
116 }