Skip to content

Commit

Permalink
Merge branch 'master' into composer2
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpbloch authored Apr 16, 2020
2 parents 12a8074 + bb894f3 commit 7410911
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 20 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
language: php
matrix:
include:
- php: 5.3
dist: precise
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
before_script:
- composer update
script: composer test
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ To set up a custom WordPress build package to use this as a custom installer, ad
```json
"type": "wordpress-core",
"require": {
"johnpbloch/wordpress-core-installer": "^1.0"
"johnpbloch/wordpress-core-installer": "^2.0"
}
```

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.

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:

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

### License
This is licensed under the GPL version 2 or later.

### Changelog

##### 2.0.0
- Added support for Composer v2. Special thanks to @Ayesh for the original pull request to add this support.
- 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.
- Other various fixes and improvements to README, tests, etc.

##### 1.0.0
- Initial stable release
- Added tests and CI
- Support added for custom vendor directories
- Added sanity check for overwriting sensitive directories
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
"class": "johnpbloch\\Composer\\WordPressCorePlugin"
},
"require": {
"composer-plugin-api": "^1.0 || ^2.0"
"composer-plugin-api": "^1.0 || ^2.0",
"php": ">=5.6.0"
},
"require-dev": {
"composer/composer": "^1.0 || ^2.0",
"phpunit/phpunit": ">=4.8.35"
"phpunit/phpunit": ">=5.7.27"
},
"conflict": {
"composer/installers": "<1.0.6"
Expand Down
18 changes: 10 additions & 8 deletions tests/phpunit/WordPressCoreInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,17 @@ private function createComposer() {
}

private function jpbExpectException( $class, $message = '', $isRegExp = false ) {
if ( method_exists( $this, 'expectException' ) ) {
$this->expectException($class);
if ( $message ) {
$isRegExp || $this->expectExceptionMessage( $message );
$isRegExp && $this->expectExceptionMessageRegExp( $message );
$this->expectException($class);
if ( $message ) {
if ( $isRegExp ) {
if ( method_exists( $this, 'expectExceptionMessageRegExp' ) ) {
$this->expectExceptionMessageRegExp( $message );
} else {
$this->expectExceptionMessageMatches( $message );
}
} else {
$this->expectExceptionMessage( $message );
}
} else {
$isRegExp || $this->setExpectedException( $class, $message );
$isRegExp && $this->setExpectedExceptionRegExp( $class, $message );
}
}

Expand Down
36 changes: 33 additions & 3 deletions tests/phpunit/WordPressCorePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,54 @@
use Composer\Composer;
use Composer\Config;
use Composer\Installer\InstallationManager;
use Composer\IO\IOInterface;
use Composer\IO\NullIO;
use Composer\Plugin\PluginInterface;
use Composer\Test\Mock\HttpDownloaderMock;
use Composer\Util\HttpDownloader;
use Composer\Util\Loop;
use johnpbloch\Composer\WordPressCorePlugin;
use PHPUnit\Framework\TestCase;

class WordPressCorePluginTest extends TestCase {

public function testActivate() {
$composer = new Composer();
$installationManager = new InstallationManager();
$composer = new Composer();
$composer->setConfig( new Config() );
$nullIO = new NullIO();
$installationManager = $this->getInstallationManager( $composer, $nullIO );
$composer->setInstallationManager( $installationManager );
$composer->setConfig( new Config() );

$plugin = new WordPressCorePlugin();
$plugin->activate( $composer, new NullIO() );
$plugin->activate( $composer, $nullIO );

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

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

/**
* @param Composer $composer
* @param IOInterface $io
*
* @return InstallationManager
*/
private function getInstallationManager( $composer, $io ) {
$installationManager = null;
switch ( explode( '.', PluginInterface::PLUGIN_API_VERSION )[0] ) {
case '1':
$installationManager = new InstallationManager();
break;
case '2':
default:
$http = new HttpDownloader( $io, $composer->getConfig() );
$loop = new Loop( $http );
$installationManager = new InstallationManager( $loop, $io );
break;
}

return $installationManager;
}

}

0 comments on commit 7410911

Please sign in to comment.