Skip to content

Commit cfcca6b

Browse files
authored
Merge pull request #397 from harmenjanssen/normalize-october-plugin
Normalise vendor directory containing hyphen
2 parents 5d15e4e + 8da283a commit cfcca6b

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/Composer/Installers/OctoberInstaller.php

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function inflectPackageVars($vars)
3333
protected function inflectPluginVars($vars)
3434
{
3535
$vars['name'] = preg_replace('/^oc-|-plugin$/', '', $vars['name']);
36+
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);
3637

3738
return $vars;
3839
}

tests/Composer/Installers/Test/OctoberInstallerTest.php

+25-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ public function setUp()
2424
/**
2525
* @dataProvider packageNameInflectionProvider
2626
*/
27-
public function testInflectPackageVars($type, $name, $expected)
27+
public function testInflectPackageVars($type, $vendor, $name, $expectedVendor, $expectedName)
2828
{
2929
$this->assertEquals(
30-
$this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)),
31-
array('name' => $expected, 'type' => $type)
30+
$this->installer->inflectPackageVars(array(
31+
'vendor' => $vendor,
32+
'name' => $name,
33+
'type' => $type
34+
)),
35+
array('vendor' => $expectedVendor, 'name' => $expectedName, 'type' => $type)
3236
);
3337
}
3438

@@ -37,29 +41,47 @@ public function packageNameInflectionProvider()
3741
return array(
3842
array(
3943
'october-plugin',
44+
'acme',
4045
'subpagelist',
46+
'acme',
4147
'subpagelist',
4248
),
4349
array(
4450
'october-plugin',
51+
'acme',
4552
'subpagelist-plugin',
53+
'acme',
4654
'subpagelist',
4755
),
4856
array(
4957
'october-plugin',
58+
'acme',
5059
'semanticoctober',
60+
'acme',
5161
'semanticoctober',
5262
),
63+
// tests vendor name containing a hyphen
64+
array(
65+
'october-plugin',
66+
'foo-bar-co',
67+
'blog',
68+
'foobarco',
69+
'blog'
70+
),
5371
// tests that exactly one '-theme' is cut off
5472
array(
5573
'october-theme',
74+
'acme',
5675
'some-theme-theme',
76+
'acme',
5777
'some-theme',
5878
),
5979
// tests that names without '-theme' suffix stay valid
6080
array(
6181
'october-theme',
82+
'acme',
6283
'someothertheme',
84+
'acme',
6385
'someothertheme',
6486
),
6587
);

0 commit comments

Comments
 (0)