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

adds the package type "yawik-module" #320

Merged
merged 1 commit into from Aug 8, 2016
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 README.md
Expand Up @@ -92,6 +92,7 @@ is not needed to install packages with these frameworks:
| TYPO3 CMS | `typo3-cms-extension` (Deprecated in this package, use the [TYPO3 CMS Installers](https://packagist.org/packages/typo3/cms-composer-installers) instead)
| Wolf CMS | `wolfcms-plugin`
| WordPress | <b>`wordpress-plugin`<br>`wordpress-theme`</b><br>`wordpress-muplugin`
| YAWIK | `yawik-module`
| Zend | `zend-library`<br>`zend-extra`<br>`zend-module`
| Zikula | `zikula-module`<br>`zikula-theme`
| Prestashop | `prestashop-module`<br>`prestashop-theme`
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -53,6 +53,7 @@
"TYPO3",
"WolfCMS",
"WordPress",
"YAWIK",
"Zend",
"Zikula"
],
Expand Down Expand Up @@ -87,4 +88,4 @@
"scripts": {
"test": "phpunit"
}
}
}
1 change: 1 addition & 0 deletions src/Composer/Installers/Installer.php
Expand Up @@ -78,6 +78,7 @@ class Installer extends LibraryInstaller
'whmcs' => 'WHMCSInstaller',
'wolfcms' => 'WolfCMSInstaller',
'wordpress' => 'WordPressInstaller',
'yawik' => 'YawikInstaller',
'zend' => 'ZendInstaller',
'zikula' => 'ZikulaInstaller',
'prestashop' => 'PrestashopInstaller'
Expand Down
32 changes: 32 additions & 0 deletions src/Composer/Installers/YawikInstaller.php
@@ -0,0 +1,32 @@
<?php
/**
* Created by PhpStorm.
* User: cbleek
* Date: 25.03.16
* Time: 20:55
*/

namespace Composer\Installers;


class YawikInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'module/{$name}/',
);

/**
* Format package name to CamelCase
* @param array $vars
*
* @return array
*/
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;
}
}
2 changes: 2 additions & 0 deletions tests/Composer/Installers/Test/InstallerTest.php
Expand Up @@ -184,6 +184,7 @@ public function dataForTestSupport()
array('wolfcms-plugin', true),
array('wordpress-plugin', true),
array('wordpress-core', false),
array('yawik-module', true),
array('zend-library', true),
array('zikula-module', true),
array('zikula-theme', true),
Expand Down Expand Up @@ -338,6 +339,7 @@ public function dataForTestInstallPath()
array('phifty-bundle', 'bundles/core/', 'shama/core'),
array('phifty-library', 'libraries/my-lib/', 'shama/my-lib'),
array('phifty-framework', 'frameworks/my-framework/', 'shama/my-framework'),
array('yawik-module', 'module/MyModule/', 'shama/my_module'),
);
}

Expand Down
64 changes: 64 additions & 0 deletions tests/Composer/Installers/Test/YawikInstallerTest.php
@@ -0,0 +1,64 @@
<?php
namespace Composer\Installers\Test;

use Composer\Composer;
use Composer\Installers\YawikInstaller;
use Composer\Package\Package;
use Composer\Package\PackageInterface;

/**
* Class YawikInstallerTest
*
* @package Composer\Installers\Test
*/
class YawikInstallerTest extends TestCase
{
/**
* @varComposer
*/
private $composer;

/**
* @var PackageInterface
*/
private $io;

/**
* @var Package
*/
private $package;

/**
* setUp
*
* @return void
*/
public function setUp()
{
$this->package = new Package('YawikCompanyRegistration', '1.0', '1.0');
$this->io = $this->getMock('Composer\IO\PackageInterface');
$this->composer = new Composer();
}

/**
* testInflectPackageVars
*
* @dataProvider packageNameProvider
* @return void
*/
public function testInflectPackageVars($input)
{
$installer = new YawikInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => $input));
$this->assertEquals($result, array('name' => 'YawikCompanyRegistration'));
}

public function packageNameProvider()
{
return array(
array('yawik-company-registration'),
array('yawik_company_registration'),
array('YawikCompanyRegistration')
);
}
}