@@ -29,7 +29,7 @@ protected function setUp()
2929 /* @var AssetTypeInterface $type */
3030 $ type = $ this ->type ;
3131 $ this ->converter = new NpmPackageConverter ($ type );
32- $ this ->asset = ( array ) json_decode ( file_get_contents ( __DIR__ . ' /../Fixtures/package/npm.json ' ), true );
32+ $ this ->asset = $ this -> loadPackage ( );
3333 }
3434
3535 public function testConvert ()
@@ -164,6 +164,26 @@ public function testConvert()
164164 $ this ->assertArrayNotHasKey ('archive ' , $ composer );
165165 }
166166
167+ public function testConvertWithScope ()
168+ {
169+ $ this ->asset = $ this ->loadPackage ('npm-scope.json ' );
170+ $ composer = $ this ->converter ->convert ($ this ->asset );
171+
172+ $ this ->assertArrayHasKey ('name ' , $ composer );
173+ $ this ->assertSame ('ASSET/scope--test ' , $ composer ['name ' ]);
174+
175+ $ this ->assertArrayHasKey ('require ' , $ composer );
176+ $ this ->assertSame (array (
177+ 'ASSET/scope--library1 ' => '>= 1.0.0 ' ,
178+ 'ASSET/scope2--library2 ' => '>= 1.0.0 ' ,
179+ ), $ composer ['require ' ]);
180+
181+ $ this ->assertArrayHasKey ('require-dev ' , $ composer );
182+ $ this ->assertSame (array (
183+ 'ASSET/scope3--dev-library1 ' => '>= 1.0.0 ' ,
184+ ), $ composer ['require-dev ' ]);
185+ }
186+
167187 public function getConvertDistData ()
168188 {
169189 return array (
@@ -184,4 +204,16 @@ public function testConvertDist($value, $result)
184204 {
185205 $ this ->assertSame ($ result , NpmPackageUtil::convertDist ($ value ));
186206 }
207+
208+ /**
209+ * Load the package.
210+ *
211+ * @param string $package The package file name
212+ *
213+ * @return array
214+ */
215+ private function loadPackage ($ package = 'npm.json ' )
216+ {
217+ return (array ) json_decode (file_get_contents (__DIR__ .'/../Fixtures/package/ ' .$ package ), true );
218+ }
187219}
0 commit comments