comparison vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 7a779792577d
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2 namespace Composer\Installers\Test;
3
4 use Composer\Installers\Installer;
5 use Composer\Util\Filesystem;
6 use Composer\Package\Package;
7 use Composer\Package\RootPackage;
8 use Composer\Composer;
9 use Composer\Config;
10
11 class InstallerTest extends TestCase
12 {
13 private $composer;
14 private $config;
15 private $vendorDir;
16 private $binDir;
17 private $dm;
18 private $repository;
19 private $io;
20 private $fs;
21
22 /**
23 * setUp
24 *
25 * @return void
26 */
27 public function setUp()
28 {
29 $this->fs = new Filesystem;
30
31 $this->composer = new Composer();
32 $this->config = new Config();
33 $this->composer->setConfig($this->config);
34
35 $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor';
36 $this->ensureDirectoryExistsAndClear($this->vendorDir);
37
38 $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin';
39 $this->ensureDirectoryExistsAndClear($this->binDir);
40
41 $this->config->merge(array(
42 'config' => array(
43 'vendor-dir' => $this->vendorDir,
44 'bin-dir' => $this->binDir,
45 ),
46 ));
47
48 $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager')
49 ->disableOriginalConstructor()
50 ->getMock();
51 $this->composer->setDownloadManager($this->dm);
52
53 $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
54 $this->io = $this->getMock('Composer\IO\IOInterface');
55 }
56
57 /**
58 * tearDown
59 *
60 * @return void
61 */
62 public function tearDown()
63 {
64 $this->fs->removeDirectory($this->vendorDir);
65 $this->fs->removeDirectory($this->binDir);
66 }
67
68 /**
69 * testSupports
70 *
71 * @return void
72 *
73 * @dataProvider dataForTestSupport
74 */
75 public function testSupports($type, $expected)
76 {
77 $installer = new Installer($this->io, $this->composer);
78 $this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type));
79 }
80
81 /**
82 * dataForTestSupport
83 */
84 public function dataForTestSupport()
85 {
86 return array(
87 array('agl-module', true),
88 array('aimeos-extension', true),
89 array('annotatecms-module', true),
90 array('annotatecms-component', true),
91 array('annotatecms-service', true),
92 array('attogram-module', true),
93 array('bitrix-module', true),
94 array('bitrix-component', true),
95 array('bitrix-theme', true),
96 array('bonefish-package', true),
97 array('cakephp', false),
98 array('cakephp-', false),
99 array('cakephp-app', false),
100 array('cakephp-plugin', true),
101 array('chef-cookbook', true),
102 array('chef-role', true),
103 array('cockpit-module', true),
104 array('codeigniter-app', false),
105 array('codeigniter-library', true),
106 array('codeigniter-third-party', true),
107 array('codeigniter-module', true),
108 array('concrete5-block', true),
109 array('concrete5-package', true),
110 array('concrete5-theme', true),
111 array('concrete5-core', true),
112 array('concrete5-update', true),
113 array('craft-plugin', true),
114 array('croogo-plugin', true),
115 array('croogo-theme', true),
116 array('decibel-app', true),
117 array('dokuwiki-plugin', true),
118 array('dokuwiki-template', true),
119 array('drupal-module', true),
120 array('dolibarr-module', true),
121 array('ee3-theme', true),
122 array('ee3-addon', true),
123 array('ee2-theme', true),
124 array('ee2-addon', true),
125 array('elgg-plugin', true),
126 array('eliasis-module', true),
127 array('ezplatform-assets', true),
128 array('ezplatform-meta-assets', true),
129 array('fuel-module', true),
130 array('fuel-package', true),
131 array('fuel-theme', true),
132 array('fuelphp-component', true),
133 array('hurad-plugin', true),
134 array('hurad-theme', true),
135 array('imagecms-template', true),
136 array('imagecms-module', true),
137 array('imagecms-library', true),
138 array('itop-extension', true),
139 array('joomla-library', true),
140 array('kanboard-plugin', true),
141 array('kirby-plugin', true),
142 array('kohana-module', true),
143 array('lms-plugin', true),
144 array('lms-template', true),
145 array('lms-document-template', true),
146 array('lms-userpanel-module', true),
147 array('laravel-library', true),
148 array('lavalite-theme', true),
149 array('lavalite-package', true),
150 array('lithium-library', true),
151 array('magento-library', true),
152 array('mako-package', true),
153 array('modxevo-snippet', true),
154 array('modxevo-plugin', true),
155 array('modxevo-module', true),
156 array('modxevo-template', true),
157 array('modxevo-lib', true),
158 array('mediawiki-extension', true),
159 array('mediawiki-skin', true),
160 array('microweber-module', true),
161 array('modulework-module', true),
162 array('moodle-mod', true),
163 array('october-module', true),
164 array('october-plugin', true),
165 array('piwik-plugin', true),
166 array('phpbb-extension', true),
167 array('pimcore-plugin', true),
168 array('plentymarkets-plugin', true),
169 array('ppi-module', true),
170 array('prestashop-module', true),
171 array('prestashop-theme', true),
172 array('puppet-module', true),
173 array('porto-container', true),
174 array('radphp-bundle', true),
175 array('redaxo-addon', true),
176 array('redaxo-bestyle-plugin', true),
177 array('reindex-theme', true),
178 array('reindex-plugin', true),
179 array('roundcube-plugin', true),
180 array('shopware-backend-plugin', true),
181 array('shopware-core-plugin', true),
182 array('shopware-frontend-plugin', true),
183 array('shopware-theme', true),
184 array('shopware-plugin', true),
185 array('shopware-frontend-theme', true),
186 array('silverstripe-module', true),
187 array('silverstripe-theme', true),
188 array('smf-module', true),
189 array('smf-theme', true),
190 array('sydes-module', true),
191 array('sydes-theme', true),
192 array('symfony1-plugin', true),
193 array('thelia-module', true),
194 array('thelia-frontoffice-template', true),
195 array('thelia-backoffice-template', true),
196 array('thelia-email-template', true),
197 array('tusk-task', true),
198 array('tusk-asset', true),
199 array('typo3-flow-plugin', true),
200 array('typo3-cms-extension', true),
201 array('userfrosting-sprinkle', true),
202 array('vanilla-plugin', true),
203 array('vanilla-theme', true),
204 array('whmcs-gateway', true),
205 array('wolfcms-plugin', true),
206 array('wordpress-plugin', true),
207 array('wordpress-core', false),
208 array('yawik-module', true),
209 array('zend-library', true),
210 array('zikula-module', true),
211 array('zikula-theme', true),
212 array('kodicms-plugin', true),
213 array('kodicms-media', true),
214 array('phifty-bundle', true),
215 array('phifty-library', true),
216 array('phifty-framework', true),
217 array('osclass-plugin', true),
218 array('osclass-theme', true),
219 array('osclass-language', true),
220 );
221 }
222
223 /**
224 * testInstallPath
225 *
226 * @dataProvider dataForTestInstallPath
227 */
228 public function testInstallPath($type, $path, $name, $version = '1.0.0')
229 {
230 $installer = new Installer($this->io, $this->composer);
231 $package = new Package($name, $version, $version);
232
233 $package->setType($type);
234 $result = $installer->getInstallPath($package);
235 $this->assertEquals($path, $result);
236 }
237
238 /**
239 * dataFormTestInstallPath
240 */
241 public function dataForTestInstallPath()
242 {
243 return array(
244 array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),
245 array('aimeos-extension', 'ext/ai-test/', 'author/ai-test'),
246 array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
247 array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
248 array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
249 array('attogram-module', 'modules/my_module/', 'author/my_module'),
250 array('bitrix-module', 'bitrix/modules/my_module/', 'author/my_module'),
251 array('bitrix-component', 'bitrix/components/my_component/', 'author/my_component'),
252 array('bitrix-theme', 'bitrix/templates/my_theme/', 'author/my_theme'),
253 array('bitrix-d7-module', 'bitrix/modules/author.my_module/', 'author/my_module'),
254 array('bitrix-d7-component', 'bitrix/components/author/my_component/', 'author/my_component'),
255 array('bitrix-d7-template', 'bitrix/templates/author_my_template/', 'author/my_template'),
256 array('bonefish-package', 'Packages/bonefish/package/', 'bonefish/package'),
257 array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
258 array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),
259 array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),
260 array('cockpit-module', 'cockpit/modules/addons/My_module/', 'piotr-cz/cockpit-my_module'),
261 array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
262 array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
263 array('concrete5-block', 'application/blocks/concrete5_block/', 'remo/concrete5_block'),
264 array('concrete5-package', 'packages/concrete5_package/', 'remo/concrete5_package'),
265 array('concrete5-theme', 'application/themes/concrete5_theme/', 'remo/concrete5_theme'),
266 array('concrete5-core', 'concrete/', 'concrete5/core'),
267 array('concrete5-update', 'updates/concrete5/', 'concrete5/concrete5'),
268 array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'),
269 array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),
270 array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),
271 array('decibel-app', 'app/someapp/', 'author/someapp'),
272 array('dokuwiki-plugin', 'lib/plugins/someplugin/', 'author/someplugin'),
273 array('dokuwiki-template', 'lib/tpl/sometemplate/', 'author/sometemplate'),
274 array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'),
275 array('drupal-module', 'modules/my_module/', 'shama/my_module'),
276 array('drupal-theme', 'themes/my_module/', 'shama/my_module'),
277 array('drupal-profile', 'profiles/my_module/', 'shama/my_module'),
278 array('drupal-drush', 'drush/my_module/', 'shama/my_module'),
279 array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'),
280 array('eliasis-module', 'modules/my_module/', 'shama/my_module'),
281 array('ee3-addon', 'system/user/addons/ee_theme/', 'author/ee_theme'),
282 array('ee3-theme', 'themes/user/ee_package/', 'author/ee_package'),
283 array('ee2-addon', 'system/expressionengine/third_party/ee_theme/', 'author/ee_theme'),
284 array('ee2-theme', 'themes/third_party/ee_package/', 'author/ee_package'),
285 array('ezplatform-assets', 'web/assets/ezplatform/ezplatform_comp/', 'author/ezplatform_comp'),
286 array('ezplatform-meta-assets', 'web/assets/ezplatform/', 'author/ezplatform_comp'),
287 array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),
288 array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),
289 array('fuel-theme', 'fuel/app/themes/theme/', 'fuel/theme'),
290 array('fuelphp-component', 'components/demo/', 'fuelphp/demo'),
291 array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'),
292 array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'),
293 array('imagecms-template', 'templates/my_template/', 'shama/my_template'),
294 array('imagecms-module', 'application/modules/my_module/', 'shama/my_module'),
295 array('imagecms-library', 'application/libraries/my_library/', 'shama/my_library'),
296 array('itop-extension', 'extensions/my_extension/', 'shama/my_extension'),
297 array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
298 array('kanboard-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
299 array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'),
300 array('kohana-module', 'modules/my_package/', 'shama/my_package'),
301 array('lms-plugin', 'plugins/MyPackage/', 'shama/MyPackage'),
302 array('lms-plugin', 'plugins/MyPackage/', 'shama/my_package'),
303 array('lms-template', 'templates/MyPackage/', 'shama/MyPackage'),
304 array('lms-template', 'templates/MyPackage/', 'shama/my_package'),
305 array('lms-document-template', 'documents/templates/MyPackage/', 'shama/MyPackage'),
306 array('lms-document-template', 'documents/templates/MyPackage/', 'shama/my_package'),
307 array('lms-userpanel-module', 'userpanel/modules/MyPackage/', 'shama/MyPackage'),
308 array('lms-userpanel-module', 'userpanel/modules/MyPackage/', 'shama/my_package'),
309 array('laravel-library', 'libraries/my_package/', 'shama/my_package'),
310 array('lavalite-theme', 'public/themes/my_theme/', 'shama/my_theme'),
311 array('lavalite-package', 'packages/my_group/my_package/', 'my_group/my_package'),
312 array('lithium-library', 'libraries/li3_test/', 'user/li3_test'),
313 array('magento-library', 'lib/foo/', 'test/foo'),
314 array('modxevo-snippet', 'assets/snippets/my_snippet/', 'shama/my_snippet'),
315 array('modxevo-plugin', 'assets/plugins/my_plugin/', 'shama/my_plugin'),
316 array('modxevo-module', 'assets/modules/my_module/', 'shama/my_module'),
317 array('modxevo-template', 'assets/templates/my_template/', 'shama/my_template'),
318 array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'),
319 array('mako-package', 'app/packages/my_package/', 'shama/my_package'),
320 array('mediawiki-extension', 'extensions/APC/', 'author/APC'),
321 array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'),
322 array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'),
323 array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi'),
324 array('mediawiki-skin', 'skins/someskin/', 'author/someskin-skin'),
325 array('mediawiki-skin', 'skins/someskin/', 'author/someskin'),
326 array('microweber-module', 'userfiles/modules/my-thing/', 'author/my-thing-module'),
327 array('modulework-module', 'modules/my_package/', 'shama/my_package'),
328 array('moodle-mod', 'mod/my_package/', 'shama/my_package'),
329 array('october-module', 'modules/my_plugin/', 'shama/my_plugin'),
330 array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
331 array('october-theme', 'themes/my_theme/', 'shama/my_theme'),
332 array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
333 array('prestashop-module', 'modules/a-module/', 'vendor/a-module'),
334 array('prestashop-theme', 'themes/a-theme/', 'vendor/a-theme'),
335 array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
336 array('phpbb-style', 'styles/foo/', 'test/foo'),
337 array('phpbb-language', 'language/foo/', 'test/foo'),
338 array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'),
339 array('plentymarkets-plugin', 'HelloWorld/', 'plugin-hello-world'),
340 array('ppi-module', 'modules/foo/', 'test/foo'),
341 array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'),
342 array('porto-container', 'app/Containers/container-name/', 'test/container-name'),
343 array('radphp-bundle', 'src/Migration/', 'atkrad/migration'),
344 array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'),
345 array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'),
346 array('reindex-theme', 'themes/my_module/', 'author/my_module'),
347 array('reindex-plugin', 'plugins/my_module/', 'author/my_module'),
348 array('roundcube-plugin', 'plugins/base/', 'test/base'),
349 array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'),
350 array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'),
351 array('shopware-core-plugin', 'engine/Shopware/Plugins/Local/Core/ShamaMyCorePlugin/', 'shama/my-core-plugin'),
352 array('shopware-frontend-plugin', 'engine/Shopware/Plugins/Local/Frontend/ShamaMyFrontendPlugin/', 'shama/my-frontend-plugin'),
353 array('shopware-theme', 'templates/my_theme/', 'shama/my-theme'),
354 array('shopware-frontend-theme', 'themes/Frontend/ShamaMyFrontendTheme/', 'shama/my-frontend-theme'),
355 array('shopware-plugin', 'custom/plugins/ShamaMyPlugin/', 'shama/my-plugin'),
356 array('silverstripe-module', 'my_module/', 'shama/my_module'),
357 array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'),
358 array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'),
359 array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),
360 array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),
361 array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
362 array('smf-module', 'Sources/my_module/', 'shama/my_module'),
363 array('smf-theme', 'Themes/my_theme/', 'shama/my_theme'),
364 array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
365 array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
366 array('thelia-module', 'local/modules/my_module/', 'shama/my_module'),
367 array('thelia-frontoffice-template', 'templates/frontOffice/my_template_fo/', 'shama/my_template_fo'),
368 array('thelia-backoffice-template', 'templates/backOffice/my_template_bo/', 'shama/my_template_bo'),
369 array('thelia-email-template', 'templates/email/my_template_email/', 'shama/my_template_email'),
370 array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'),
371 array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),
372 array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),
373 array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),
374 array('userfrosting-sprinkle', 'app/sprinkles/my_sprinkle/', 'shama/my_sprinkle'),
375 array('vanilla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
376 array('vanilla-theme', 'themes/my_theme/', 'shama/my_theme'),
377 array('whmcs-gateway', 'modules/gateways/gateway_name/', 'vendor/gateway_name'),
378 array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'),
379 array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),
380 array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),
381 array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),
382 array('zikula-module', 'modules/my-test_module/', 'my/test_module'),
383 array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'),
384 array('kodicms-media', 'cms/media/vendor/my_media/', 'shama/my_media'),
385 array('kodicms-plugin', 'cms/plugins/my_plugin/', 'shama/my_plugin'),
386 array('phifty-bundle', 'bundles/core/', 'shama/core'),
387 array('phifty-library', 'libraries/my-lib/', 'shama/my-lib'),
388 array('phifty-framework', 'frameworks/my-framework/', 'shama/my-framework'),
389 array('yawik-module', 'module/MyModule/', 'shama/my_module'),
390 array('osclass-plugin', 'oc-content/plugins/sample_plugin/', 'test/sample_plugin'),
391 array('osclass-theme', 'oc-content/themes/sample_theme/', 'test/sample_theme'),
392 array('osclass-language', 'oc-content/languages/sample_lang/', 'test/sample_lang'),
393 );
394 }
395
396 /**
397 * testGetCakePHPInstallPathException
398 *
399 * @return void
400 *
401 * @expectedException \InvalidArgumentException
402 */
403 public function testGetCakePHPInstallPathException()
404 {
405 $installer = new Installer($this->io, $this->composer);
406 $package = new Package('shama/ftp', '1.0.0', '1.0.0');
407
408 $package->setType('cakephp-whoops');
409 $result = $installer->getInstallPath($package);
410 }
411
412 /**
413 * testCustomInstallPath
414 */
415 public function testCustomInstallPath()
416 {
417 $installer = new Installer($this->io, $this->composer);
418 $package = new Package('shama/ftp', '1.0.0', '1.0.0');
419 $package->setType('cakephp-plugin');
420 $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
421 $this->composer->setPackage($consumerPackage);
422 $consumerPackage->setExtra(array(
423 'installer-paths' => array(
424 'my/custom/path/{$name}/' => array(
425 'shama/ftp',
426 'foo/bar',
427 ),
428 ),
429 ));
430 $result = $installer->getInstallPath($package);
431 $this->assertEquals('my/custom/path/Ftp/', $result);
432 }
433
434 /**
435 * testCustomInstallerName
436 */
437 public function testCustomInstallerName()
438 {
439 $installer = new Installer($this->io, $this->composer);
440 $package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0');
441 $package->setType('cakephp-plugin');
442 $package->setExtra(array(
443 'installer-name' => 'FTP',
444 ));
445 $result = $installer->getInstallPath($package);
446 $this->assertEquals('Plugin/FTP/', $result);
447 }
448
449 /**
450 * testCustomTypePath
451 */
452 public function testCustomTypePath()
453 {
454 $installer = new Installer($this->io, $this->composer);
455 $package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0');
456 $package->setType('wordpress-plugin');
457 $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
458 $this->composer->setPackage($consumerPackage);
459 $consumerPackage->setExtra(array(
460 'installer-paths' => array(
461 'my/custom/path/{$name}/' => array(
462 'type:wordpress-plugin'
463 ),
464 ),
465 ));
466 $result = $installer->getInstallPath($package);
467 $this->assertEquals('my/custom/path/my_plugin/', $result);
468 }
469
470 /**
471 * testVendorPath
472 */
473 public function testVendorPath()
474 {
475 $installer = new Installer($this->io, $this->composer);
476 $package = new Package('penyaskito/my_module', '1.0.0', '1.0.0');
477 $package->setType('drupal-module');
478 $consumerPackage = new RootPackage('drupal/drupal', '1.0.0', '1.0.0');
479 $this->composer->setPackage($consumerPackage);
480 $consumerPackage->setExtra(array(
481 'installer-paths' => array(
482 'modules/custom/{$name}/' => array(
483 'vendor:penyaskito'
484 ),
485 ),
486 ));
487 $result = $installer->getInstallPath($package);
488 $this->assertEquals('modules/custom/my_module/', $result);
489 }
490
491 /**
492 * testNoVendorName
493 */
494 public function testNoVendorName()
495 {
496 $installer = new Installer($this->io, $this->composer);
497 $package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0');
498
499 $package->setType('symfony1-plugin');
500 $result = $installer->getInstallPath($package);
501 $this->assertEquals('plugins/sfPhpunitPlugin/', $result);
502 }
503
504 /**
505 * testTypo3Inflection
506 */
507 public function testTypo3Inflection()
508 {
509 $installer = new Installer($this->io, $this->composer);
510 $package = new Package('typo3/fluid', '1.0.0', '1.0.0');
511
512 $package->setAutoload(array(
513 'psr-0' => array(
514 'TYPO3\\Fluid' => 'Classes',
515 ),
516 ));
517
518 $package->setType('typo3-flow-package');
519 $result = $installer->getInstallPath($package);
520 $this->assertEquals('Packages/Application/TYPO3.Fluid/', $result);
521 }
522
523 public function testUninstallAndDeletePackageFromLocalRepo()
524 {
525 $package = new Package('foo', '1.0.0', '1.0.0');
526
527 $installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer));
528 $installer->expects($this->once())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo'));
529
530 $repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
531 $repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true));
532 $repo->expects($this->once())->method('removePackage')->with($package);
533
534 $installer->uninstall($repo, $package);
535 }
536 }