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

added matomo-plugin #514

Merged
merged 1 commit into from Aug 20, 2022
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 @@ -80,6 +80,7 @@ all vendor code in the vendor directory, and not requiring custom installer code
| majima | `majima-plugin`
| Mako | `mako-package`
| MantisBT | `mantisbt-plugin`
| Matomo | `matomo-plugin`
| Mautic | `mautic-core`<br>`mautic-plugin`<br>`mautic-theme`
| Maya | `maya-module`
| MODX | `modx-extra`
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -38,6 +38,7 @@
"majima",
"Mako",
"MantisBT",
"Matomo",
"Mautic",
"Maya",
"MODX",
Expand Down
1 change: 1 addition & 0 deletions src/Composer/Installers/Installer.php
Expand Up @@ -64,6 +64,7 @@ class Installer extends LibraryInstaller
'majima' => 'MajimaInstaller',
'mantisbt' => 'MantisBTInstaller',
'mako' => 'MakoInstaller',
'matomo' => 'MatomoInstaller',
'maya' => 'MayaInstaller',
'mautic' => 'MauticInstaller',
'mediawiki' => 'MediaWikiInstaller',
Expand Down
28 changes: 28 additions & 0 deletions src/Composer/Installers/MatomoInstaller.php
@@ -0,0 +1,28 @@
<?php

namespace Composer\Installers;

/**
* Class MatomoInstaller
*
* @package Composer\Installers
*/
class MatomoInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);

/**
* Format package name to CamelCase
*/
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower($this->pregReplace('/(?<=\\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 @@ -150,6 +150,7 @@ public function supportsProvider(): array
array('magento-library', true),
array('majima-plugin', true),
array('mako-package', true),
array('matomo-plugin', true),
array('mantisbt-plugin', true),
array('miaoxing-plugin', true),
array('modx-extra', true),
Expand Down Expand Up @@ -351,6 +352,7 @@ public function installPathProvider(): array
array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'),
array('mako-package', 'app/packages/my_package/', 'shama/my_package'),
array('mantisbt-plugin', 'plugins/MyPlugin/', 'shama/my_plugin'),
array('matomo-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
array('mediawiki-extension', 'extensions/APC/', 'author/APC'),
array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'),
array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'),
Expand Down
47 changes: 47 additions & 0 deletions tests/Composer/Installers/Test/MatomoInstallerTest.php
@@ -0,0 +1,47 @@
<?php

namespace Composer\Installers\Test;

use Composer\Composer;
use Composer\Installers\MatomoInstaller;
use Composer\Package\Package;
use Composer\Package\PackageInterface;

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

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

public function setUp(): void
{
$this->package = new Package('VisitSummary', '1.0', '1.0');
$this->composer = new Composer();
}

public function testInflectPackageVars(): void
{
$installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO());
$result = $installer->inflectPackageVars(array('name' => 'VisitSummary'));
$this->assertEquals($result, array('name' => 'VisitSummary'));

$installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO());
$result = $installer->inflectPackageVars(array('name' => 'visit-summary'));
$this->assertEquals($result, array('name' => 'VisitSummary'));

$installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO());
$result = $installer->inflectPackageVars(array('name' => 'visit_summary'));
$this->assertEquals($result, array('name' => 'VisitSummary'));
}
}