|
| 1 | +<?php |
| 2 | +namespace Composer\Installers\Test; |
| 3 | + |
| 4 | +use Composer\Installers\MauticInstaller; |
| 5 | +use Composer\Package\Package; |
| 6 | +use Composer\Composer; |
| 7 | + |
| 8 | +class MauticInstallerTest extends TestCase |
| 9 | +{ |
| 10 | + /** |
| 11 | + * @var MauticInstaller |
| 12 | + */ |
| 13 | + private $installer; |
| 14 | + |
| 15 | + /** |
| 16 | + * @var \Composer\Composer |
| 17 | + */ |
| 18 | + protected $composer; |
| 19 | + |
| 20 | + public function setUp() |
| 21 | + { |
| 22 | + $this->composer = new Composer(); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * @param string[] $vars |
| 27 | + * @param string[] $expectedVars |
| 28 | + * |
| 29 | + * @covers ::inflectPackageVars |
| 30 | + * |
| 31 | + * @dataProvider provideExpectedInflectionResults |
| 32 | + */ |
| 33 | + final public function testInflectPackageVars($vars, $expectedVars) |
| 34 | + { |
| 35 | + $package = new Package($vars['name'], '1.0.0', '1.0.0'); |
| 36 | + $package->setType($vars['type']); |
| 37 | + if (isset($vars['extra'])) { |
| 38 | + $package->setExtra((array) $vars['extra']); |
| 39 | + } |
| 40 | + |
| 41 | + $installer = new MauticInstaller( |
| 42 | + $package, |
| 43 | + $this->composer |
| 44 | + ); |
| 45 | + |
| 46 | + $actual = $installer->inflectPackageVars($vars); |
| 47 | + $this->assertEquals($actual, $expectedVars); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Provides various parameters for packages and the expected result after |
| 52 | + * inflection |
| 53 | + * |
| 54 | + * @return array |
| 55 | + */ |
| 56 | + final public function provideExpectedInflectionResults() |
| 57 | + { |
| 58 | + return array( |
| 59 | + //check bitrix-dir is correct |
| 60 | + array( |
| 61 | + array( |
| 62 | + 'name' => 'mautic/grapes-js-builder-bundle', |
| 63 | + 'type' => 'mautic-plugin' |
| 64 | + ), |
| 65 | + array( |
| 66 | + 'name' => 'GrapesJsBuilderBundle', |
| 67 | + 'type' => 'mautic-plugin' |
| 68 | + ) |
| 69 | + ), |
| 70 | + // Check if composer renames the name based on the given |
| 71 | + // installation directory |
| 72 | + array( |
| 73 | + array( |
| 74 | + 'name' => 'mautic/grapes-js-builder-bundle', |
| 75 | + 'type' => 'mautic-plugin', |
| 76 | + 'extra' => array( |
| 77 | + 'install-directory-name' => 'GrapesJsBuilderPlugin' |
| 78 | + ) |
| 79 | + ), |
| 80 | + array( |
| 81 | + 'name' => 'GrapesJsBuilderPlugin', |
| 82 | + 'type' => 'mautic-plugin', |
| 83 | + 'extra' => array( |
| 84 | + 'install-directory-name' => 'GrapesJsBuilderPlugin' |
| 85 | + ) |
| 86 | + ) |
| 87 | + ), |
| 88 | + array( |
| 89 | + array( |
| 90 | + 'name' => 'mautic/theme-blank-grapejs', |
| 91 | + 'type' => 'mautic-theme' |
| 92 | + ), |
| 93 | + array( |
| 94 | + 'name' => 'ThemeBlankGrapejs', |
| 95 | + 'type' => 'mautic-theme' |
| 96 | + ) |
| 97 | + ), |
| 98 | + array( |
| 99 | + array( |
| 100 | + 'name' => 'mautic/theme-blank-grapejs', |
| 101 | + 'type' => 'mautic-theme', |
| 102 | + 'extra' => array( |
| 103 | + 'install-directory-name' => 'blank-grapejs' |
| 104 | + ) |
| 105 | + ), |
| 106 | + array( |
| 107 | + 'name' => 'blank-grapejs', |
| 108 | + 'type' => 'mautic-theme', |
| 109 | + 'extra' => array( |
| 110 | + 'install-directory-name' => 'blank-grapejs' |
| 111 | + ) |
| 112 | + ) |
| 113 | + ) |
| 114 | + ); |
| 115 | + } |
| 116 | +} |
0 commit comments