75b402b640f11940c9bcbf20cfd688e7e665170a
[yaffs-website] / vendor / composer / installers / tests / Composer / Installers / Test / InstallerTest.php
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-component', true),
127             array('eliasis-module', true),
128             array('eliasis-plugin', true),
129             array('eliasis-template', true),
130             array('ezplatform-assets', true),
131             array('ezplatform-meta-assets', true),
132             array('fuel-module', true),
133             array('fuel-package', true),
134             array('fuel-theme', true),
135             array('fuelphp-component', true),
136             array('hurad-plugin', true),
137             array('hurad-theme', true),
138             array('imagecms-template', true),
139             array('imagecms-module', true),
140             array('imagecms-library', true),
141             array('itop-extension', true),
142             array('joomla-library', true),
143             array('kanboard-plugin', true),
144             array('kirby-plugin', true),
145             array('kohana-module', true),
146             array('lms-plugin', true),
147             array('lms-template', true),
148             array('lms-document-template', true),
149             array('lms-userpanel-module', true),
150             array('laravel-library', true),
151             array('lavalite-theme', true),
152             array('lavalite-package', true),
153             array('lithium-library', true),
154             array('magento-library', true),
155             array('majima-plugin', true),
156             array('mako-package', true),
157             array('modx-extra', true),
158             array('modxevo-snippet', true),
159             array('modxevo-plugin', true),
160             array('modxevo-module', true),
161             array('modxevo-template', true),
162             array('modxevo-lib', true),
163             array('mediawiki-extension', true),
164             array('mediawiki-skin', true),
165             array('microweber-module', true),
166             array('modulework-module', true),
167             array('moodle-mod', true),
168             array('october-module', true),
169             array('october-plugin', true),
170             array('piwik-plugin', true),
171             array('pxcms-module', true),
172             array('pxcms-theme', true),
173             array('phpbb-extension', true),
174             array('pimcore-plugin', true),
175             array('plentymarkets-plugin', true),
176             array('ppi-module', true),
177             array('prestashop-module', true),
178             array('prestashop-theme', true),
179             array('puppet-module', true),
180             array('porto-container', true),
181             array('radphp-bundle', true),
182             array('redaxo-addon', true),
183             array('redaxo-bestyle-plugin', true),
184             array('reindex-theme', true),
185             array('reindex-plugin', true),
186             array('roundcube-plugin', true),
187             array('shopware-backend-plugin', true),
188             array('shopware-core-plugin', true),
189             array('shopware-frontend-plugin', true),
190             array('shopware-theme', true),
191             array('shopware-plugin', true),
192             array('shopware-frontend-theme', true),
193             array('silverstripe-module', true),
194             array('silverstripe-theme', true),
195             array('smf-module', true),
196             array('smf-theme', true),
197             array('sydes-module', true),
198             array('sydes-theme', true),
199             array('symfony1-plugin', true),
200             array('thelia-module', true),
201             array('thelia-frontoffice-template', true),
202             array('thelia-backoffice-template', true),
203             array('thelia-email-template', true),
204             array('tusk-task', true),
205             array('tusk-asset', true),
206             array('typo3-flow-plugin', true),
207             array('typo3-cms-extension', true),
208             array('userfrosting-sprinkle', true),
209             array('vanilla-plugin', true),
210             array('vanilla-theme', true),
211             array('whmcs-gateway', true),
212             array('wolfcms-plugin', true),
213             array('wordpress-plugin', true),
214             array('wordpress-core', false),
215             array('yawik-module', true),
216             array('zend-library', true),
217             array('zikula-module', true),
218             array('zikula-theme', true),
219             array('kodicms-plugin', true),
220             array('kodicms-media', true),
221             array('phifty-bundle', true),
222             array('phifty-library', true),
223             array('phifty-framework', true),
224             array('osclass-plugin', true),
225             array('osclass-theme', true),
226             array('osclass-language', true),
227         );
228     }
229
230     /**
231      * testInstallPath
232      *
233      * @dataProvider dataForTestInstallPath
234      */
235     public function testInstallPath($type, $path, $name, $version = '1.0.0')
236     {
237         $installer = new Installer($this->io, $this->composer);
238         $package = new Package($name, $version, $version);
239
240         $package->setType($type);
241         $result = $installer->getInstallPath($package);
242         $this->assertEquals($path, $result);
243     }
244
245     /**
246      * dataFormTestInstallPath
247      */
248     public function dataForTestInstallPath()
249     {
250         return array(
251             array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),
252             array('aimeos-extension', 'ext/ai-test/', 'author/ai-test'),
253             array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
254             array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
255             array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
256             array('attogram-module', 'modules/my_module/', 'author/my_module'),
257             array('bitrix-module', 'bitrix/modules/my_module/', 'author/my_module'),
258             array('bitrix-component', 'bitrix/components/my_component/', 'author/my_component'),
259             array('bitrix-theme', 'bitrix/templates/my_theme/', 'author/my_theme'),
260             array('bitrix-d7-module', 'bitrix/modules/author.my_module/', 'author/my_module'),
261             array('bitrix-d7-component', 'bitrix/components/author/my_component/', 'author/my_component'),
262             array('bitrix-d7-template', 'bitrix/templates/author_my_template/', 'author/my_template'),
263             array('bonefish-package', 'Packages/bonefish/package/', 'bonefish/package'),
264             array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
265             array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),
266             array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),
267             array('cockpit-module', 'cockpit/modules/addons/My_module/', 'piotr-cz/cockpit-my_module'),
268             array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
269             array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
270             array('concrete5-block', 'application/blocks/concrete5_block/', 'remo/concrete5_block'),
271             array('concrete5-package', 'packages/concrete5_package/', 'remo/concrete5_package'),
272             array('concrete5-theme', 'application/themes/concrete5_theme/', 'remo/concrete5_theme'),
273             array('concrete5-core', 'concrete/', 'concrete5/core'),
274             array('concrete5-update', 'updates/concrete5/', 'concrete5/concrete5'),
275             array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'),
276             array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),
277             array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),
278             array('decibel-app', 'app/someapp/', 'author/someapp'),
279             array('dokuwiki-plugin', 'lib/plugins/someplugin/', 'author/someplugin'),
280             array('dokuwiki-template', 'lib/tpl/sometemplate/', 'author/sometemplate'),
281             array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'),
282             array('drupal-module', 'modules/my_module/', 'shama/my_module'),
283             array('drupal-theme', 'themes/my_module/', 'shama/my_module'),
284             array('drupal-profile', 'profiles/my_module/', 'shama/my_module'),
285             array('drupal-drush', 'drush/my_module/', 'shama/my_module'),
286             array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'),
287             array('eliasis-component', 'components/my_component/', 'shama/my_component'),
288             array('eliasis-module', 'modules/my_module/', 'shama/my_module'),
289             array('eliasis-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
290             array('eliasis-template', 'templates/my_template/', 'shama/my_template'),
291             array('ee3-addon', 'system/user/addons/ee_theme/', 'author/ee_theme'),
292             array('ee3-theme', 'themes/user/ee_package/', 'author/ee_package'),
293             array('ee2-addon', 'system/expressionengine/third_party/ee_theme/', 'author/ee_theme'),
294             array('ee2-theme', 'themes/third_party/ee_package/', 'author/ee_package'),
295             array('ezplatform-assets', 'web/assets/ezplatform/ezplatform_comp/', 'author/ezplatform_comp'),
296             array('ezplatform-meta-assets', 'web/assets/ezplatform/', 'author/ezplatform_comp'),
297             array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),
298             array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),
299             array('fuel-theme', 'fuel/app/themes/theme/', 'fuel/theme'),
300             array('fuelphp-component', 'components/demo/', 'fuelphp/demo'),
301             array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'),
302             array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'),
303             array('imagecms-template', 'templates/my_template/', 'shama/my_template'),
304             array('imagecms-module', 'application/modules/my_module/', 'shama/my_module'),
305             array('imagecms-library', 'application/libraries/my_library/', 'shama/my_library'),
306             array('itop-extension', 'extensions/my_extension/', 'shama/my_extension'),
307             array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
308             array('kanboard-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
309             array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'),
310             array('kohana-module', 'modules/my_package/', 'shama/my_package'),
311             array('lms-plugin', 'plugins/MyPackage/', 'shama/MyPackage'),
312             array('lms-plugin', 'plugins/MyPackage/', 'shama/my_package'),
313             array('lms-template', 'templates/MyPackage/', 'shama/MyPackage'),
314             array('lms-template', 'templates/MyPackage/', 'shama/my_package'),
315             array('lms-document-template', 'documents/templates/MyPackage/', 'shama/MyPackage'),
316             array('lms-document-template', 'documents/templates/MyPackage/', 'shama/my_package'),
317             array('lms-userpanel-module', 'userpanel/modules/MyPackage/', 'shama/MyPackage'),
318             array('lms-userpanel-module', 'userpanel/modules/MyPackage/', 'shama/my_package'),
319             array('laravel-library', 'libraries/my_package/', 'shama/my_package'),
320             array('lavalite-theme', 'public/themes/my_theme/', 'shama/my_theme'),
321             array('lavalite-package', 'packages/my_group/my_package/', 'my_group/my_package'),
322             array('lithium-library', 'libraries/li3_test/', 'user/li3_test'),
323             array('magento-library', 'lib/foo/', 'test/foo'),
324             array('majima-plugin', 'plugins/MyPlugin/', 'shama/my-plugin'),
325             array('modx-extra', 'core/packages/extra/', 'vendor/extra'),
326             array('modxevo-snippet', 'assets/snippets/my_snippet/', 'shama/my_snippet'),
327             array('modxevo-plugin', 'assets/plugins/my_plugin/', 'shama/my_plugin'),
328             array('modxevo-module', 'assets/modules/my_module/', 'shama/my_module'),
329             array('modxevo-template', 'assets/templates/my_template/', 'shama/my_template'),
330             array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'),
331             array('mako-package', 'app/packages/my_package/', 'shama/my_package'),
332             array('mediawiki-extension', 'extensions/APC/', 'author/APC'),
333             array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'),
334             array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'),
335             array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi'),
336             array('mediawiki-skin', 'skins/someskin/', 'author/someskin-skin'),
337             array('mediawiki-skin', 'skins/someskin/', 'author/someskin'),
338             array('microweber-module', 'userfiles/modules/my-thing/', 'author/my-thing-module'),
339             array('modulework-module', 'modules/my_package/', 'shama/my_package'),
340             array('moodle-mod', 'mod/my_package/', 'shama/my_package'),
341             array('october-module', 'modules/my_plugin/', 'shama/my_plugin'),
342             array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
343             array('october-theme', 'themes/my_theme/', 'shama/my_theme'),
344             array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
345             array('prestashop-module', 'modules/a-module/', 'vendor/a-module'),
346             array('prestashop-theme', 'themes/a-theme/', 'vendor/a-theme'),
347             array('pxcms-module', 'app/Modules/Foo/', 'vendor/module-foo'),
348             array('pxcms-module', 'app/Modules/Foo/', 'vendor/pxcms-foo'),
349             array('pxcms-theme', 'themes/Foo/', 'vendor/theme-foo'),
350             array('pxcms-theme', 'themes/Foo/', 'vendor/pxcms-foo'),
351             array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
352             array('phpbb-style', 'styles/foo/', 'test/foo'),
353             array('phpbb-language', 'language/foo/', 'test/foo'),
354             array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'),
355             array('plentymarkets-plugin', 'HelloWorld/', 'plugin-hello-world'),
356             array('ppi-module', 'modules/foo/', 'test/foo'),
357             array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'),
358             array('porto-container', 'app/Containers/container-name/', 'test/container-name'),
359             array('radphp-bundle', 'src/Migration/', 'atkrad/migration'),
360             array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'),
361             array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'),
362             array('reindex-theme', 'themes/my_module/', 'author/my_module'),
363             array('reindex-plugin', 'plugins/my_module/', 'author/my_module'),
364             array('roundcube-plugin', 'plugins/base/', 'test/base'),
365             array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'),
366             array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'),
367             array('shopware-core-plugin', 'engine/Shopware/Plugins/Local/Core/ShamaMyCorePlugin/', 'shama/my-core-plugin'),
368             array('shopware-frontend-plugin', 'engine/Shopware/Plugins/Local/Frontend/ShamaMyFrontendPlugin/', 'shama/my-frontend-plugin'),
369             array('shopware-theme', 'templates/my_theme/', 'shama/my-theme'),
370             array('shopware-frontend-theme', 'themes/Frontend/ShamaMyFrontendTheme/', 'shama/my-frontend-theme'),
371             array('shopware-plugin', 'custom/plugins/ShamaMyPlugin/', 'shama/my-plugin'),
372             array('silverstripe-module', 'my_module/', 'shama/my_module'),
373             array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'),
374             array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'),
375             array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),
376             array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),
377             array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
378             array('smf-module', 'Sources/my_module/', 'shama/my_module'),
379             array('smf-theme', 'Themes/my_theme/', 'shama/my_theme'),
380             array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
381             array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
382             array('thelia-module', 'local/modules/my_module/', 'shama/my_module'),
383             array('thelia-frontoffice-template', 'templates/frontOffice/my_template_fo/', 'shama/my_template_fo'),
384             array('thelia-backoffice-template', 'templates/backOffice/my_template_bo/', 'shama/my_template_bo'),
385             array('thelia-email-template', 'templates/email/my_template_email/', 'shama/my_template_email'),
386             array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'),
387             array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),
388             array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),
389             array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),
390             array('userfrosting-sprinkle', 'app/sprinkles/my_sprinkle/', 'shama/my_sprinkle'),
391             array('vanilla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
392             array('vanilla-theme', 'themes/my_theme/', 'shama/my_theme'),
393             array('whmcs-gateway', 'modules/gateways/gateway_name/', 'vendor/gateway_name'),
394             array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'),
395             array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),
396             array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),
397             array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),
398             array('zikula-module', 'modules/my-test_module/', 'my/test_module'),
399             array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'),
400             array('kodicms-media', 'cms/media/vendor/my_media/', 'shama/my_media'),
401             array('kodicms-plugin', 'cms/plugins/my_plugin/', 'shama/my_plugin'),
402             array('phifty-bundle', 'bundles/core/', 'shama/core'),
403             array('phifty-library', 'libraries/my-lib/', 'shama/my-lib'),
404             array('phifty-framework', 'frameworks/my-framework/', 'shama/my-framework'),
405             array('yawik-module', 'module/MyModule/', 'shama/my_module'),
406             array('osclass-plugin', 'oc-content/plugins/sample_plugin/', 'test/sample_plugin'),
407             array('osclass-theme', 'oc-content/themes/sample_theme/', 'test/sample_theme'),
408             array('osclass-language', 'oc-content/languages/sample_lang/', 'test/sample_lang'),
409         );
410     }
411
412     /**
413      * testGetCakePHPInstallPathException
414      *
415      * @return void
416      *
417      * @expectedException \InvalidArgumentException
418      */
419     public function testGetCakePHPInstallPathException()
420     {
421         $installer = new Installer($this->io, $this->composer);
422         $package = new Package('shama/ftp', '1.0.0', '1.0.0');
423
424         $package->setType('cakephp-whoops');
425         $result = $installer->getInstallPath($package);
426     }
427
428     /**
429      * testCustomInstallPath
430      */
431     public function testCustomInstallPath()
432     {
433         $installer = new Installer($this->io, $this->composer);
434         $package = new Package('shama/ftp', '1.0.0', '1.0.0');
435         $package->setType('cakephp-plugin');
436         $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
437         $this->composer->setPackage($consumerPackage);
438         $consumerPackage->setExtra(array(
439             'installer-paths' => array(
440                 'my/custom/path/{$name}/' => array(
441                     'shama/ftp',
442                     'foo/bar',
443                 ),
444             ),
445         ));
446         $result = $installer->getInstallPath($package);
447         $this->assertEquals('my/custom/path/Ftp/', $result);
448     }
449
450     /**
451      * testCustomInstallerName
452      */
453     public function testCustomInstallerName()
454     {
455         $installer = new Installer($this->io, $this->composer);
456         $package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0');
457         $package->setType('cakephp-plugin');
458         $package->setExtra(array(
459             'installer-name' => 'FTP',
460         ));
461         $result = $installer->getInstallPath($package);
462         $this->assertEquals('Plugin/FTP/', $result);
463     }
464
465     /**
466      * testCustomTypePath
467      */
468     public function testCustomTypePath()
469     {
470         $installer = new Installer($this->io, $this->composer);
471         $package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0');
472         $package->setType('wordpress-plugin');
473         $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
474         $this->composer->setPackage($consumerPackage);
475         $consumerPackage->setExtra(array(
476             'installer-paths' => array(
477                 'my/custom/path/{$name}/' => array(
478                     'type:wordpress-plugin'
479                 ),
480             ),
481         ));
482         $result = $installer->getInstallPath($package);
483         $this->assertEquals('my/custom/path/my_plugin/', $result);
484     }
485
486     /**
487      * testVendorPath
488      */
489     public function testVendorPath()
490     {
491         $installer = new Installer($this->io, $this->composer);
492         $package = new Package('penyaskito/my_module', '1.0.0', '1.0.0');
493         $package->setType('drupal-module');
494         $consumerPackage = new RootPackage('drupal/drupal', '1.0.0', '1.0.0');
495         $this->composer->setPackage($consumerPackage);
496         $consumerPackage->setExtra(array(
497           'installer-paths' => array(
498             'modules/custom/{$name}/' => array(
499               'vendor:penyaskito'
500             ),
501           ),
502         ));
503         $result = $installer->getInstallPath($package);
504         $this->assertEquals('modules/custom/my_module/', $result);
505     }
506
507     /**
508      * testNoVendorName
509      */
510     public function testNoVendorName()
511     {
512         $installer = new Installer($this->io, $this->composer);
513         $package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0');
514
515         $package->setType('symfony1-plugin');
516         $result = $installer->getInstallPath($package);
517         $this->assertEquals('plugins/sfPhpunitPlugin/', $result);
518     }
519
520     /**
521      * testTypo3Inflection
522      */
523     public function testTypo3Inflection()
524     {
525         $installer = new Installer($this->io, $this->composer);
526         $package = new Package('typo3/fluid', '1.0.0', '1.0.0');
527
528         $package->setAutoload(array(
529             'psr-0' => array(
530                 'TYPO3\\Fluid' => 'Classes',
531             ),
532         ));
533
534         $package->setType('typo3-flow-package');
535         $result = $installer->getInstallPath($package);
536         $this->assertEquals('Packages/Application/TYPO3.Fluid/', $result);
537     }
538
539     public function testUninstallAndDeletePackageFromLocalRepo()
540     {
541         $package = new Package('foo', '1.0.0', '1.0.0');
542
543         $installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer));
544         $installer->expects($this->atLeastOnce())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo'));
545
546         $repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
547         $repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true));
548         $repo->expects($this->once())->method('removePackage')->with($package);
549
550         $installer->uninstall($repo, $package);
551     }
552 }