Skip to content

Commit

Permalink
Merge pull request #514 from codymorgan/main
Browse files Browse the repository at this point in the history
added matomo-plugin
  • Loading branch information
Seldaek authored Aug 20, 2022
2 parents af93ba6 + 722a5e3 commit c29dc4b
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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'));
}
}

0 comments on commit c29dc4b

Please sign in to comment.