Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalise vendor directory containing hyphen #397

Merged
merged 1 commit into from Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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