Skip to content

Commit 7410911

Browse files
authored
Merge branch 'master' into composer2
2 parents 12a8074 + bb894f3 commit 7410911

File tree

5 files changed

+63
-20
lines changed

5 files changed

+63
-20
lines changed

.travis.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
language: php
2-
matrix:
3-
include:
4-
- php: 5.3
5-
dist: precise
62
php:
7-
- '5.4'
8-
- '5.5'
93
- '5.6'
104
- '7.0'
115
- '7.1'
126
- '7.2'
137
- '7.3'
8+
- '7.4'
149
before_script:
1510
- composer update
1611
script: composer test

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ To set up a custom WordPress build package to use this as a custom installer, ad
1818
```json
1919
"type": "wordpress-core",
2020
"require": {
21-
"johnpbloch/wordpress-core-installer": "^1.0"
21+
"johnpbloch/wordpress-core-installer": "^2.0"
2222
}
2323
```
2424

25+
If you need to maintain support for PHP versions lower than 5.6 (not recommended!), use `^1.0` as your version constraint in the above.
26+
2527
By default, this package will install a `wordpress-core` type package in the `wordpress` directory. To change this you can add the following to either your custom WordPress core type package or the root composer package:
2628

2729
```json
@@ -43,3 +45,16 @@ The root composer package can also declare custom paths as an object keyed by pa
4345

4446
### License
4547
This is licensed under the GPL version 2 or later.
48+
49+
### Changelog
50+
51+
##### 2.0.0
52+
- Added support for Composer v2. Special thanks to @Ayesh for the original pull request to add this support.
53+
- Bumped minimum required PHP version to 5.6 (same as WP). If you need to stick with an older PHP version, you're probably ok with also sticking with an older version of Composer and can continue to use `^1.0` as your version constraint.
54+
- Other various fixes and improvements to README, tests, etc.
55+
56+
##### 1.0.0
57+
- Initial stable release
58+
- Added tests and CI
59+
- Support added for custom vendor directories
60+
- Added sanity check for overwriting sensitive directories

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
"class": "johnpbloch\\Composer\\WordPressCorePlugin"
2929
},
3030
"require": {
31-
"composer-plugin-api": "^1.0 || ^2.0"
31+
"composer-plugin-api": "^1.0 || ^2.0",
32+
"php": ">=5.6.0"
3233
},
3334
"require-dev": {
3435
"composer/composer": "^1.0 || ^2.0",
35-
"phpunit/phpunit": ">=4.8.35"
36+
"phpunit/phpunit": ">=5.7.27"
3637
},
3738
"conflict": {
3839
"composer/installers": "<1.0.6"

tests/phpunit/WordPressCoreInstallerTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,17 @@ private function createComposer() {
173173
}
174174

175175
private function jpbExpectException( $class, $message = '', $isRegExp = false ) {
176-
if ( method_exists( $this, 'expectException' ) ) {
177-
$this->expectException($class);
178-
if ( $message ) {
179-
$isRegExp || $this->expectExceptionMessage( $message );
180-
$isRegExp && $this->expectExceptionMessageRegExp( $message );
176+
$this->expectException($class);
177+
if ( $message ) {
178+
if ( $isRegExp ) {
179+
if ( method_exists( $this, 'expectExceptionMessageRegExp' ) ) {
180+
$this->expectExceptionMessageRegExp( $message );
181+
} else {
182+
$this->expectExceptionMessageMatches( $message );
183+
}
184+
} else {
185+
$this->expectExceptionMessage( $message );
181186
}
182-
} else {
183-
$isRegExp || $this->setExpectedException( $class, $message );
184-
$isRegExp && $this->setExpectedExceptionRegExp( $class, $message );
185187
}
186188
}
187189

tests/phpunit/WordPressCorePluginTest.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,54 @@
2424
use Composer\Composer;
2525
use Composer\Config;
2626
use Composer\Installer\InstallationManager;
27+
use Composer\IO\IOInterface;
2728
use Composer\IO\NullIO;
29+
use Composer\Plugin\PluginInterface;
30+
use Composer\Test\Mock\HttpDownloaderMock;
31+
use Composer\Util\HttpDownloader;
32+
use Composer\Util\Loop;
2833
use johnpbloch\Composer\WordPressCorePlugin;
2934
use PHPUnit\Framework\TestCase;
3035

3136
class WordPressCorePluginTest extends TestCase {
3237

3338
public function testActivate() {
34-
$composer = new Composer();
35-
$installationManager = new InstallationManager();
39+
$composer = new Composer();
40+
$composer->setConfig( new Config() );
41+
$nullIO = new NullIO();
42+
$installationManager = $this->getInstallationManager( $composer, $nullIO );
3643
$composer->setInstallationManager( $installationManager );
3744
$composer->setConfig( new Config() );
3845

3946
$plugin = new WordPressCorePlugin();
40-
$plugin->activate( $composer, new NullIO() );
47+
$plugin->activate( $composer, $nullIO );
4148

4249
$installer = $installationManager->getInstaller( 'wordpress-core' );
4350

4451
$this->assertInstanceOf( '\johnpbloch\Composer\WordPressCoreInstaller', $installer );
4552
}
4653

54+
/**
55+
* @param Composer $composer
56+
* @param IOInterface $io
57+
*
58+
* @return InstallationManager
59+
*/
60+
private function getInstallationManager( $composer, $io ) {
61+
$installationManager = null;
62+
switch ( explode( '.', PluginInterface::PLUGIN_API_VERSION )[0] ) {
63+
case '1':
64+
$installationManager = new InstallationManager();
65+
break;
66+
case '2':
67+
default:
68+
$http = new HttpDownloader( $io, $composer->getConfig() );
69+
$loop = new Loop( $http );
70+
$installationManager = new InstallationManager( $loop, $io );
71+
break;
72+
}
73+
74+
return $installationManager;
75+
}
76+
4777
}

0 commit comments

Comments
 (0)