Skip to content

Commit

Permalink
Merge pull request #397 from harmenjanssen/normalize-october-plugin
Browse files Browse the repository at this point in the history
Normalise vendor directory containing hyphen
  • Loading branch information
alcohol committed Aug 27, 2018
2 parents 5d15e4e + 8da283a commit cfcca6b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Composer/Installers/OctoberInstaller.php
Expand Up @@ -33,6 +33,7 @@ public function inflectPackageVars($vars)
protected function inflectPluginVars($vars)
{
$vars['name'] = preg_replace('/^oc-|-plugin$/', '', $vars['name']);
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);

return $vars;
}
Expand Down
28 changes: 25 additions & 3 deletions tests/Composer/Installers/Test/OctoberInstallerTest.php
Expand Up @@ -24,11 +24,15 @@ public function setUp()
/**
* @dataProvider packageNameInflectionProvider
*/
public function testInflectPackageVars($type, $name, $expected)
public function testInflectPackageVars($type, $vendor, $name, $expectedVendor, $expectedName)
{
$this->assertEquals(
$this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)),
array('name' => $expected, 'type' => $type)
$this->installer->inflectPackageVars(array(
'vendor' => $vendor,
'name' => $name,
'type' => $type
)),
array('vendor' => $expectedVendor, 'name' => $expectedName, 'type' => $type)
);
}

Expand All @@ -37,29 +41,47 @@ public function packageNameInflectionProvider()
return array(
array(
'october-plugin',
'acme',
'subpagelist',
'acme',
'subpagelist',
),
array(
'october-plugin',
'acme',
'subpagelist-plugin',
'acme',
'subpagelist',
),
array(
'october-plugin',
'acme',
'semanticoctober',
'acme',
'semanticoctober',
),
// tests vendor name containing a hyphen
array(
'october-plugin',
'foo-bar-co',
'blog',
'foobarco',
'blog'
),
// tests that exactly one '-theme' is cut off
array(
'october-theme',
'acme',
'some-theme-theme',
'acme',
'some-theme',
),
// tests that names without '-theme' suffix stay valid
array(
'october-theme',
'acme',
'someothertheme',
'acme',
'someothertheme',
),
);
Expand Down

0 comments on commit cfcca6b

Please sign in to comment.