PluginProbe ʕ •ᴥ•ʔ
Nested Pages / 3.2.15
Nested Pages v3.2.15
3.3.1 3.2.15 3.2.14 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / vendor / composer / installers / tests / Composer / Installers / Test / InstallerTest.php
wp-nested-pages / vendor / composer / installers / tests / Composer / Installers / Test Last commit date
CakePHPInstallerTest.php 11 years ago InstallerTest.php 11 years ago TestCase.php 11 years ago
InstallerTest.php
310 lines
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('annotatecms-module', true),
89 array('annotatecms-component', true),
90 array('annotatecms-service', true),
91 array('cakephp', false),
92 array('cakephp-', false),
93 array('cakephp-app', false),
94 array('cakephp-plugin', true),
95 array('codeigniter-app', false),
96 array('codeigniter-library', true),
97 array('codeigniter-third-party', true),
98 array('codeigniter-module', true),
99 array('croogo-plugin', true),
100 array('croogo-theme', true),
101 array('drupal-module', true),
102 array('fuel-module', true),
103 array('fuel-package', true),
104 array('joomla-library', true),
105 array('kohana-module', true),
106 array('laravel-library', true),
107 array('lithium-library', true),
108 array('magento-library', true),
109 array('mako-package', true),
110 array('mediawiki-extension', true),
111 array('modulework-module', true),
112 array('phpbb-extension', true),
113 array('ppi-module', true),
114 array('silverstripe-module', true),
115 array('silverstripe-theme', true),
116 array('symfony1-plugin', true),
117 array('typo3-flow-plugin', true),
118 array('typo3-cms-extension', true),
119 array('wordpress-plugin', true),
120 array('wordpress-core', false),
121 array('zend-library', true),
122 );
123 }
124
125 /**
126 * testInstallPath
127 *
128 * @dataProvider dataForTestInstallPath
129 */
130 public function testInstallPath($type, $path, $name, $version = '1.0.0')
131 {
132 $installer = new Installer($this->io, $this->composer);
133 $package = new Package($name, $version, $version);
134
135 $package->setType($type);
136 $result = $installer->getInstallPath($package);
137 $this->assertEquals($path, $result);
138 }
139
140 /**
141 * dataFormTestInstallPath
142 */
143 public function dataForTestInstallPath()
144 {
145 return array(
146 array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),
147 array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
148 array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
149 array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
150 array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
151 array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
152 array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
153 array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),
154 array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),
155 array('drupal-module', 'modules/my_module/', 'shama/my_module'),
156 array('drupal-theme', 'themes/my_module/', 'shama/my_module'),
157 array('drupal-profile', 'profiles/my_module/', 'shama/my_module'),
158 array('drupal-drush', 'drush/my_module/', 'shama/my_module'),
159 array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),
160 array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),
161 array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
162 array('kohana-module', 'modules/my_package/', 'shama/my_package'),
163 array('laravel-library', 'libraries/my_package/', 'shama/my_package'),
164 array('lithium-library', 'libraries/li3_test/', 'user/li3_test'),
165 array('magento-library', 'lib/foo/', 'test/foo'),
166 array('mako-package', 'app/packages/my_package/', 'shama/my_package'),
167 array('mediawiki-extension', 'extensions/APC/', 'author/APC' ),
168 array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard' ),
169 array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi' ),
170 array('modulework-module', 'modules/my_package/', 'shama/my_package'),
171 array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
172 array('phpbb-style', 'styles/foo/', 'test/foo'),
173 array('phpbb-language', 'language/foo/', 'test/foo'),
174 array('ppi-module', 'modules/foo/', 'test/foo'),
175 array('silverstripe-module', 'my_module/', 'shama/my_module'),
176 array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'),
177 array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'),
178 array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),
179 array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),
180 array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
181 array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
182 array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
183 array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),
184 array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),
185 array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),
186 array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),
187 array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),
188 array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),
189 );
190 }
191
192 /**
193 * testGetCakePHPInstallPathException
194 *
195 * @return void
196 *
197 * @expectedException \InvalidArgumentException
198 */
199 public function testGetCakePHPInstallPathException()
200 {
201 $installer = new Installer($this->io, $this->composer);
202 $package = new Package('shama/ftp', '1.0.0', '1.0.0');
203
204 $package->setType('cakephp-whoops');
205 $result = $installer->getInstallPath($package);
206 }
207
208 /**
209 * testCustomInstallPath
210 */
211 public function testCustomInstallPath()
212 {
213 $installer = new Installer($this->io, $this->composer);
214 $package = new Package('shama/ftp', '1.0.0', '1.0.0');
215 $package->setType('cakephp-plugin');
216 $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
217 $this->composer->setPackage($consumerPackage);
218 $consumerPackage->setExtra(array(
219 'installer-paths' => array(
220 'my/custom/path/{$name}/' => array(
221 'shama/ftp',
222 'foo/bar',
223 ),
224 ),
225 ));
226 $result = $installer->getInstallPath($package);
227 $this->assertEquals('my/custom/path/Ftp/', $result);
228 }
229
230 /**
231 * testCustomInstallerName
232 */
233 public function testCustomInstallerName() {
234 $installer = new Installer($this->io, $this->composer);
235 $package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0');
236 $package->setType('cakephp-plugin');
237 $package->setExtra(array(
238 'installer-name' => 'FTP',
239 ));
240 $result = $installer->getInstallPath($package);
241 $this->assertEquals('Plugin/FTP/', $result);
242 }
243
244 /**
245 * testCustomTypePath
246 */
247 public function testCustomTypePath() {
248 $installer = new Installer($this->io, $this->composer);
249 $package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0');
250 $package->setType('wordpress-plugin');
251 $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
252 $this->composer->setPackage($consumerPackage);
253 $consumerPackage->setExtra(array(
254 'installer-paths' => array(
255 'my/custom/path/{$name}/' => array(
256 'type:wordpress-plugin'
257 ),
258 ),
259 ));
260 $result = $installer->getInstallPath($package);
261 $this->assertEquals('my/custom/path/my_plugin/', $result);
262 }
263
264 /**
265 * testNoVendorName
266 */
267 public function testNoVendorName()
268 {
269 $installer = new Installer($this->io, $this->composer);
270 $package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0');
271
272 $package->setType('symfony1-plugin');
273 $result = $installer->getInstallPath($package);
274 $this->assertEquals('plugins/sfPhpunitPlugin/', $result);
275 }
276
277 /**
278 * testTypo3Inflection
279 */
280 public function testTypo3Inflection()
281 {
282 $installer = new Installer($this->io, $this->composer);
283 $package = new Package('typo3/fluid', '1.0.0', '1.0.0');
284
285 $package->setAutoload(array(
286 'psr-0' => array(
287 'TYPO3\\Fluid' => 'Classes',
288 ),
289 ));
290
291 $package->setType('typo3-flow-package');
292 $result = $installer->getInstallPath($package);
293 $this->assertEquals('Packages/Application/TYPO3.Fluid/', $result);
294 }
295
296 public function testUninstallAndDeletePackageFromLocalRepo()
297 {
298 $package = new Package('foo', '1.0.0', '1.0.0');
299
300 $installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer));
301 $installer->expects($this->once())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo'));
302
303 $repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
304 $repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true));
305 $repo->expects($this->once())->method('removePackage')->with($package);
306
307 $installer->uninstall($repo, $package);
308 }
309 }
310