Skip to content

Commit 83744b1

Browse files
authored
Merge pull request roots#1 from roots/allow-overwrite
Allow overwriting wordpress-core type packages
2 parents c33fd84 + 66dfe62 commit 83744b1

File tree

6 files changed

+55
-13
lines changed

6 files changed

+55
-13
lines changed

.editorconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
# WordPress Coding Standards
5+
# https://make.wordpress.org/core/handbook/coding-standards/
6+
7+
root = true
8+
9+
[*]
10+
charset = utf-8
11+
end_of_line = lf
12+
insert_final_newline = true
13+
trim_trailing_whitespace = true
14+
indent_style = tab
15+
16+
[*.yml]
17+
indent_style = space
18+
indent_size = 2
19+
20+
[*.md]
21+
trim_trailing_whitespace = false
22+
23+
[{*.txt,wp-config-sample.php}]
24+
end_of_line = crlf

composer.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
}
2020
],
2121
"autoload": {
22-
"psr-0": {
23-
"johnpbloch\\Composer\\": "src/"
22+
"psr-4": {
23+
"Roots\\Composer\\": "src/"
2424
}
2525
},
2626
"autoload-dev": {
2727
"psr-4": {
28-
"Tests\\JohnPBloch\\Composer\\": "tests/"
28+
"Tests\\Roots\\Composer\\": "tests/"
2929
}
3030
},
3131
"extra": {
32-
"class": "johnpbloch\\Composer\\WordPressCorePlugin"
32+
"class": "Roots\\Composer\\WordPressCorePlugin"
3333
},
3434
"require": {
3535
"composer-plugin-api": "^1.0"
@@ -41,6 +41,9 @@
4141
"conflict": {
4242
"composer/installers": "<1.0.6"
4343
},
44+
"replace": {
45+
"johnpbloch/wordpress-core-installer":"*"
46+
},
4447
"scripts": {
4548
"test:phpunit": "phpunit",
4649
"test": [

src/johnpbloch/Composer/WordPressCoreInstaller.php renamed to src/WordPressCoreInstaller.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020
*/
2121

22-
namespace johnpbloch\Composer;
22+
namespace Roots\Composer;
2323

2424
use Composer\Config;
2525
use Composer\Installer\LibraryInstaller;
@@ -67,7 +67,8 @@ public function getInstallPath( PackageInterface $package ) {
6767
}
6868
if (
6969
! empty( self::$_installedPaths[ $installationDir ] ) &&
70-
$prettyName !== self::$_installedPaths[ $installationDir ]
70+
$prettyName !== self::$_installedPaths[ $installationDir ] &&
71+
$package->getType() !== self::TYPE
7172
) {
7273
$conflict_message = $this->getConflictMessage( $prettyName, self::$_installedPaths[ $installationDir ] );
7374
throw new \InvalidArgumentException( $conflict_message );

src/johnpbloch/Composer/WordPressCorePlugin.php renamed to src/WordPressCorePlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020
*/
2121

22-
namespace johnpbloch\Composer;
22+
namespace Roots\Composer;
2323

2424
use Composer\Composer;
2525
use Composer\IO\IOInterface;

tests/phpunit/WordPressCoreInstallerTest.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020
*/
2121

22-
namespace Tests\JohnPBloch\Composer\phpunit;
22+
namespace Tests\Roots\Composer\phpunit;
2323

2424
use Composer\Composer;
2525
use Composer\Config;
2626
use Composer\IO\NullIO;
2727
use Composer\Package\Package;
2828
use Composer\Package\RootPackage;
29-
use johnpbloch\Composer\WordPressCoreInstaller;
29+
use Roots\Composer\WordPressCoreInstaller;
3030
use PHPUnit\Framework\TestCase;
3131

3232
class WordPressCoreInstallerTest extends TestCase {
@@ -136,6 +136,20 @@ public function testTwoPackagesCannotShareDirectory() {
136136
$installer->getInstallPath( $package1 );
137137
$installer->getInstallPath( $package2 );
138138
}
139+
140+
public function testTwoPackagesCannotShareDirectoryUnlessWpCoreType() {
141+
$composer = $this->createComposer();
142+
$installer = new WordPressCoreInstaller( new NullIO(), $composer );
143+
$package1 = new Package( 'johnpbloch/wordpress', '4.9.8', '4.9.8' );
144+
$package1->setType('wordpress-core');
145+
$package2 = new Package( 'roots/wordpress', '5.0', '5.0' );
146+
$package2->setType('wordpress-core');
147+
148+
$installer->getInstallPath( $package1 );
149+
$installer->getInstallPath( $package2 );
150+
151+
$this->assertTrue(true); // no exceptions thrown
152+
}
139153

140154
/**
141155
* @dataProvider dataProviderSensitiveDirectories
@@ -158,7 +172,7 @@ public function dataProviderSensitiveDirectories() {
158172
}
159173

160174
private function resetInstallPaths() {
161-
$prop = new \ReflectionProperty( '\johnpbloch\Composer\WordPressCoreInstaller', '_installedPaths' );
175+
$prop = new \ReflectionProperty( '\Roots\Composer\WordPressCoreInstaller', '_installedPaths' );
162176
$prop->setAccessible( true );
163177
$prop->setValue( array() );
164178
}

tests/phpunit/WordPressCorePluginTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020
*/
2121

22-
namespace Tests\JohnPBloch\Composer\phpunit;
22+
namespace Tests\Roots\Composer\phpunit;
2323

2424
use Composer\Composer;
2525
use Composer\Config;
2626
use Composer\Installer\InstallationManager;
2727
use Composer\IO\NullIO;
28-
use johnpbloch\Composer\WordPressCorePlugin;
28+
use Roots\Composer\WordPressCorePlugin;
2929
use PHPUnit\Framework\TestCase;
3030

3131
class WordPressCorePluginTest extends TestCase {
@@ -41,7 +41,7 @@ public function testActivate() {
4141

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

44-
$this->assertInstanceOf( '\johnpbloch\Composer\WordPressCoreInstaller', $installer );
44+
$this->assertInstanceOf( '\Roots\Composer\WordPressCoreInstaller', $installer );
4545
}
4646

4747
}

0 commit comments

Comments
 (0)