-
-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add installer for Processwire module (#472)
* Add ProcessWire installer * Inflect package names to CamelCase * Add tests * Add readme
- Loading branch information
Showing
6 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ | |
"PPI", | ||
"Puppet", | ||
"Porto", | ||
"ProcessWire", | ||
"RadPHP", | ||
"ReIndex", | ||
"Roundcube", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Composer\Installers; | ||
|
||
class ProcessWireInstaller extends BaseInstaller | ||
{ | ||
protected $locations = array( | ||
'module' => 'site/modules/{$name}/', | ||
); | ||
|
||
/** | ||
* Format package name to CamelCase | ||
*/ | ||
public function inflectPackageVars($vars) | ||
{ | ||
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); | ||
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); | ||
$vars['name'] = str_replace(' ', '', ucwords($vars['name'])); | ||
|
||
return $vars; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/Composer/Installers/Test/ProcessWireInstallerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
namespace Composer\Installers\Test; | ||
|
||
use Composer\Installers\ProcessWireInstaller; | ||
use Composer\Package\Package; | ||
use Composer\Composer; | ||
|
||
class ProcessWireInstallerTest extends TestCase | ||
{ | ||
private $composer; | ||
private $io; | ||
private $package; | ||
|
||
/** | ||
* setUp | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->package = new Package('CamelCased', '1.0', '1.0'); | ||
$this->composer = new Composer(); | ||
} | ||
|
||
/** | ||
* testInflectPackageVars | ||
* | ||
* @return void | ||
*/ | ||
public function testInflectPackageVars() | ||
{ | ||
$installer = new ProcessWireInstaller($this->package, $this->composer); | ||
$result = $installer->inflectPackageVars(array('name' => 'CamelCased')); | ||
$this->assertEquals($result, array('name' => 'CamelCased')); | ||
|
||
$installer = new ProcessWireInstaller($this->package, $this->composer); | ||
$result = $installer->inflectPackageVars(array('name' => 'with-dash')); | ||
$this->assertEquals($result, array('name' => 'WithDash')); | ||
|
||
$installer = new ProcessWireInstaller($this->package, $this->composer); | ||
$result = $installer->inflectPackageVars(array('name' => 'with_underscore')); | ||
$this->assertEquals($result, array('name' => 'WithUnderscore')); | ||
} | ||
} |