ComposerInstallersTestInstallerTest

The Google Analytics by MonsterInsights Composer Installers Test InstallerTest class.

Defined (1)

The class is defined in the following location(s).

/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php  
  1. class InstallerTest extends TestCase 
  2. private $composer; 
  3. private $config; 
  4. private $vendorDir; 
  5. private $binDir; 
  6. private $dm; 
  7. private $repository; 
  8. private $io; 
  9. private $fs; 
  10.  
  11. /** 
  12. * setUp 
  13. * @return void 
  14. */ 
  15. public function setUp() 
  16. $this->fs = new Filesystem; 
  17.  
  18. $this->composer = new Composer(); 
  19. $this->config = new Config(); 
  20. $this->composer->setConfig($this->config); 
  21.  
  22. $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor'; 
  23. $this->ensureDirectoryExistsAndClear($this->vendorDir); 
  24.  
  25. $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin'; 
  26. $this->ensureDirectoryExistsAndClear($this->binDir); 
  27.  
  28. $this->config->merge(array( 
  29. 'config' => array( 
  30. 'vendor-dir' => $this->vendorDir,  
  31. 'bin-dir' => $this->binDir,  
  32. ),  
  33. )); 
  34.  
  35. $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager') 
  36. ->disableOriginalConstructor() 
  37. ->getMock(); 
  38. $this->composer->setDownloadManager($this->dm); 
  39.  
  40. $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); 
  41. $this->io = $this->getMock('Composer\IO\IOInterface'); 
  42.  
  43. /** 
  44. * tearDown 
  45. * @return void 
  46. */ 
  47. public function tearDown() 
  48. $this->fs->removeDirectory($this->vendorDir); 
  49. $this->fs->removeDirectory($this->binDir); 
  50.  
  51. /** 
  52. * testSupports 
  53. * @return void 
  54. * @dataProvider dataForTestSupport 
  55. */ 
  56. public function testSupports($type, $expected) 
  57. $installer = new Installer($this->io, $this->composer); 
  58. $this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type)); 
  59.  
  60. /** 
  61. * dataForTestSupport 
  62. */ 
  63. public function dataForTestSupport() 
  64. return array( 
  65. array('agl-module', true),  
  66. array('aimeos-extension', true),  
  67. array('annotatecms-module', true),  
  68. array('annotatecms-component', true),  
  69. array('annotatecms-service', true),  
  70. array('bitrix-module', true),  
  71. array('bitrix-component', true),  
  72. array('bitrix-theme', true),  
  73. array('cakephp', false),  
  74. array('cakephp-', false),  
  75. array('cakephp-app', false),  
  76. array('cakephp-plugin', true),  
  77. array('chef-cookbook', true),  
  78. array('chef-role', true),  
  79. array('codeigniter-app', false),  
  80. array('codeigniter-library', true),  
  81. array('codeigniter-third-party', true),  
  82. array('codeigniter-module', true),  
  83. array('concrete5-block', true),  
  84. array('concrete5-package', true),  
  85. array('concrete5-theme', true),  
  86. array('concrete5-update', true),  
  87. array('craft-plugin', true),  
  88. array('croogo-plugin', true),  
  89. array('croogo-theme', true),  
  90. array('dokuwiki-plugin', true),  
  91. array('dokuwiki-template', true),  
  92. array('drupal-module', true),  
  93. array('dolibarr-module', true),  
  94. array('elgg-plugin', true),  
  95. array('fuel-module', true),  
  96. array('fuel-package', true),  
  97. array('fuel-theme', true),  
  98. array('fuelphp-component', true),  
  99. array('hurad-plugin', true),  
  100. array('hurad-theme', true),  
  101. array('joomla-library', true),  
  102. array('kirby-plugin', true),  
  103. array('kohana-module', true),  
  104. array('laravel-library', true),  
  105. array('lithium-library', true),  
  106. array('magento-library', true),  
  107. array('mako-package', true),  
  108. array('modxevo-snippet', true),  
  109. array('modxevo-plugin', true),  
  110. array('modxevo-module', true),  
  111. array('modxevo-template', true),  
  112. array('modxevo-lib', true),  
  113. array('mediawiki-extension', true),  
  114. array('mediawiki-skin', true),  
  115. array('microweber-module', true),  
  116. array('modulework-module', true),  
  117. array('moodle-mod', true),  
  118. array('october-module', true),  
  119. array('october-plugin', true),  
  120. array('piwik-plugin', true),  
  121. array('phpbb-extension', true),  
  122. array('pimcore-plugin', true),  
  123. array('ppi-module', true),  
  124. array('prestashop-module', true),  
  125. array('prestashop-theme', true),  
  126. array('puppet-module', true),  
  127. array('redaxo-addon', true),  
  128. array('redaxo-bestyle-plugin', true),  
  129. array('roundcube-plugin', true),  
  130. array('shopware-backend-plugin', true),  
  131. array('shopware-core-plugin', true),  
  132. array('shopware-frontend-plugin', true),  
  133. array('shopware-theme', true),  
  134. array('silverstripe-module', true),  
  135. array('silverstripe-theme', true),  
  136. array('smf-module', true),  
  137. array('smf-theme', true),  
  138. array('symfony1-plugin', true),  
  139. array('thelia-module', true),  
  140. array('thelia-frontoffice-template', true),  
  141. array('thelia-backoffice-template', true),  
  142. array('thelia-email-template', true),  
  143. array('tusk-task', true),  
  144. array('tusk-asset', true),  
  145. array('typo3-flow-plugin', true),  
  146. array('typo3-cms-extension', true),  
  147. array('whmcs-gateway', true),  
  148. array('wolfcms-plugin', true),  
  149. array('wordpress-plugin', true),  
  150. array('wordpress-core', false),  
  151. array('zend-library', true),  
  152. array('zikula-module', true),  
  153. array('zikula-theme', true),  
  154. ); 
  155.  
  156. /** 
  157. * testInstallPath 
  158. * @dataProvider dataForTestInstallPath 
  159. */ 
  160. public function testInstallPath($type, $path, $name, $version = '1.0.0') 
  161. $installer = new Installer($this->io, $this->composer); 
  162. $package = new Package($name, $version, $version); 
  163.  
  164. $package->setType($type); 
  165. $result = $installer->getInstallPath($package); 
  166. $this->assertEquals($path, $result); 
  167.  
  168. /** 
  169. * dataFormTestInstallPath 
  170. */ 
  171. public function dataForTestInstallPath() 
  172. return array( 
  173. array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),  
  174. array('aimeos-extension', 'ext/ai-test/', 'author/ai-test'),  
  175. array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),  
  176. array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),  
  177. array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),  
  178. array('bitrix-module', 'local/modules/my_module/', 'author/my_module'),  
  179. array('bitrix-component', 'local/components/my_component/', 'author/my_component'),  
  180. array('bitrix-theme', 'local/templates/my_theme/', 'author/my_theme'),  
  181. array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),  
  182. array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),  
  183. array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),  
  184. array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),  
  185. array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),  
  186. array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'),  
  187. array('concrete5-package', 'packages/concrete5_package/', 'remo/concrete5_package'),  
  188. array('concrete5-theme', 'themes/concrete5_theme/', 'remo/concrete5_theme'),  
  189. array('concrete5-update', 'updates/concrete5/', 'concrete5/concrete5'),  
  190. array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'),  
  191. array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),  
  192. array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),  
  193. array('dokuwiki-plugin', 'lib/plugins/someplugin/', 'author/someplugin'),  
  194. array('dokuwiki-template', 'lib/tpl/sometemplate/', 'author/sometemplate'),  
  195. array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'),  
  196. array('drupal-module', 'modules/my_module/', 'shama/my_module'),  
  197. array('drupal-theme', 'themes/my_module/', 'shama/my_module'),  
  198. array('drupal-profile', 'profiles/my_module/', 'shama/my_module'),  
  199. array('drupal-drush', 'drush/my_module/', 'shama/my_module'),  
  200. array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'),  
  201. array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),  
  202. array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),  
  203. array('fuel-theme', 'fuel/app/themes/theme/', 'fuel/theme'),  
  204. array('fuelphp-component', 'components/demo/', 'fuelphp/demo'),  
  205. array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'),  
  206. array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'),  
  207. array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),  
  208. array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'),  
  209. array('kohana-module', 'modules/my_package/', 'shama/my_package'),  
  210. array('laravel-library', 'libraries/my_package/', 'shama/my_package'),  
  211. array('lithium-library', 'libraries/li3_test/', 'user/li3_test'),  
  212. array('magento-library', 'lib/foo/', 'test/foo'),  
  213. array('modxevo-snippet', 'assets/snippets/my_snippet/', 'shama/my_snippet'),  
  214. array('modxevo-plugin', 'assets/plugins/my_plugin/', 'shama/my_plugin'),  
  215. array('modxevo-module', 'assets/modules/my_module/', 'shama/my_module'),  
  216. array('modxevo-template', 'assets/templates/my_template/', 'shama/my_template'),  
  217. array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'),  
  218. array('mako-package', 'app/packages/my_package/', 'shama/my_package'),  
  219. array('mediawiki-extension', 'extensions/APC/', 'author/APC'),  
  220. array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'),  
  221. array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'),  
  222. array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi'),  
  223. array('mediawiki-skin', 'skins/someskin/', 'author/someskin-skin'),  
  224. array('mediawiki-skin', 'skins/someskin/', 'author/someskin'),  
  225. array('microweber-module', 'userfiles/modules/my-thing/', 'author/my-thing-module'),  
  226. array('modulework-module', 'modules/my_package/', 'shama/my_package'),  
  227. array('moodle-mod', 'mod/my_package/', 'shama/my_package'),  
  228. array('october-module', 'modules/my_plugin/', 'shama/my_plugin'),  
  229. array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),  
  230. array('october-theme', 'themes/my_theme/', 'shama/my_theme'),  
  231. array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),  
  232. array('prestashop-module', 'modules/a-module/', 'vendor/a-module'),  
  233. array('prestashop-theme', 'themes/a-theme/', 'vendor/a-theme'),  
  234. array('phpbb-extension', 'ext/test/foo/', 'test/foo'),  
  235. array('phpbb-style', 'styles/foo/', 'test/foo'),  
  236. array('phpbb-language', 'language/foo/', 'test/foo'),  
  237. array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'),  
  238. array('ppi-module', 'modules/foo/', 'test/foo'),  
  239. array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'),  
  240. array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'),  
  241. array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'),  
  242. array('roundcube-plugin', 'plugins/base/', 'test/base'),  
  243. array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'),  
  244. array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'),  
  245. array('shopware-core-plugin', 'engine/Shopware/Plugins/Local/Core/ShamaMyCorePlugin/', 'shama/my-core-plugin'),  
  246. array('shopware-frontend-plugin', 'engine/Shopware/Plugins/Local/Frontend/ShamaMyFrontendPlugin/', 'shama/my-frontend-plugin'),  
  247. array('shopware-theme', 'templates/my_theme/', 'shama/my-theme'),  
  248. array('silverstripe-module', 'my_module/', 'shama/my_module'),  
  249. array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'),  
  250. array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'),  
  251. array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),  
  252. array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),  
  253. array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),  
  254. array('smf-module', 'Sources/my_module/', 'shama/my_module'),  
  255. array('smf-theme', 'Themes/my_theme/', 'shama/my_theme'),  
  256. array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),  
  257. array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),  
  258. array('thelia-module', 'local/modules/my_module/', 'shama/my_module'),  
  259. array('thelia-frontoffice-template', 'templates/frontOffice/my_template_fo/', 'shama/my_template_fo'),  
  260. array('thelia-backoffice-template', 'templates/backOffice/my_template_bo/', 'shama/my_template_bo'),  
  261. array('thelia-email-template', 'templates/email/my_template_email/', 'shama/my_template_email'),  
  262. array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'),  
  263. array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),  
  264. array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),  
  265. array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),  
  266. array('whmcs-gateway', 'modules/gateways/gateway_name/', 'vendor/gateway_name'),  
  267. array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'),  
  268. array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),  
  269. array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),  
  270. array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),  
  271. array('zikula-module', 'modules/my-test_module/', 'my/test_module'),  
  272. array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'),  
  273. ); 
  274.  
  275. /** 
  276. * testGetCakePHPInstallPathException 
  277. * @return void 
  278. * @expectedException \InvalidArgumentException 
  279. */ 
  280. public function testGetCakePHPInstallPathException() 
  281. $installer = new Installer($this->io, $this->composer); 
  282. $package = new Package('shama/ftp', '1.0.0', '1.0.0'); 
  283.  
  284. $package->setType('cakephp-whoops'); 
  285. $result = $installer->getInstallPath($package); 
  286.  
  287. /** 
  288. * testCustomInstallPath 
  289. */ 
  290. public function testCustomInstallPath() 
  291. $installer = new Installer($this->io, $this->composer); 
  292. $package = new Package('shama/ftp', '1.0.0', '1.0.0'); 
  293. $package->setType('cakephp-plugin'); 
  294. $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0'); 
  295. $this->composer->setPackage($consumerPackage); 
  296. $consumerPackage->setExtra(array( 
  297. 'installer-paths' => array( 
  298. 'my/custom/path/{$name}/' => array( 
  299. 'shama/ftp',  
  300. 'foo/bar',  
  301. ),  
  302. ),  
  303. )); 
  304. $result = $installer->getInstallPath($package); 
  305. $this->assertEquals('my/custom/path/Ftp/', $result); 
  306.  
  307. /** 
  308. * testCustomInstallerName 
  309. */ 
  310. public function testCustomInstallerName() 
  311. $installer = new Installer($this->io, $this->composer); 
  312. $package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0'); 
  313. $package->setType('cakephp-plugin'); 
  314. $package->setExtra(array( 
  315. 'installer-name' => 'FTP',  
  316. )); 
  317. $result = $installer->getInstallPath($package); 
  318. $this->assertEquals('Plugin/FTP/', $result); 
  319.  
  320. /** 
  321. * testCustomTypePath 
  322. */ 
  323. public function testCustomTypePath() 
  324. $installer = new Installer($this->io, $this->composer); 
  325. $package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0'); 
  326. $package->setType('wordpress-plugin'); 
  327. $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0'); 
  328. $this->composer->setPackage($consumerPackage); 
  329. $consumerPackage->setExtra(array( 
  330. 'installer-paths' => array( 
  331. 'my/custom/path/{$name}/' => array( 
  332. 'type:wordpress-plugin' 
  333. ),  
  334. ),  
  335. )); 
  336. $result = $installer->getInstallPath($package); 
  337. $this->assertEquals('my/custom/path/my_plugin/', $result); 
  338.  
  339. /** 
  340. * testNoVendorName 
  341. */ 
  342. public function testNoVendorName() 
  343. $installer = new Installer($this->io, $this->composer); 
  344. $package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0'); 
  345.  
  346. $package->setType('symfony1-plugin'); 
  347. $result = $installer->getInstallPath($package); 
  348. $this->assertEquals('plugins/sfPhpunitPlugin/', $result); 
  349.  
  350. /** 
  351. * testTypo3Inflection 
  352. */ 
  353. public function testTypo3Inflection() 
  354. $installer = new Installer($this->io, $this->composer); 
  355. $package = new Package('typo3/fluid', '1.0.0', '1.0.0'); 
  356.  
  357. $package->setAutoload(array( 
  358. 'psr-0' => array( 
  359. 'TYPO3\\Fluid' => 'Classes',  
  360. ),  
  361. )); 
  362.  
  363. $package->setType('typo3-flow-package'); 
  364. $result = $installer->getInstallPath($package); 
  365. $this->assertEquals('Packages/Application/TYPO3.Fluid/', $result); 
  366.  
  367. public function testUninstallAndDeletePackageFromLocalRepo() 
  368. $package = new Package('foo', '1.0.0', '1.0.0'); 
  369.  
  370. $installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer)); 
  371. $installer->expects($this->once())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo')); 
  372.  
  373. $repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); 
  374. $repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true)); 
  375. $repo->expects($this->once())->method('removePackage')->with($package); 
  376.  
  377. $installer->uninstall($repo, $package);