style: fix indentation, alignment, and docblock annotations

- Correct getChoices() docblock to reflect translated label => enum
  backing value order instead of value => label
- Re-indent Smart Links menu config to match actual array nesting
- Align assignment operators in RefreshStatsCommand
- Add missing newline at end of RefreshStatsCommand.php
This commit is contained in:
Alexandre Gain committed 2026-11-21 11:23:33 +01:00
1 parent 07773acb8d
commit b138056e43
90 files changed
+622 -272

No files matched your search

@@ -26,8 +26,8 @@ final class SmartlinksSettingsTypeTest extends TypeTestCase
{
protected function getExtensions(): array
{
$catalog = new UtmParameterCatalog();
$translator = new IdentityTranslator();
$catalog = new UtmParameterCatalog();
$translator = new IdentityTranslator();
$transformer = new UtmSettingsTransformer(new UtmConfigurationNormalizer($catalog), $catalog, $translator);
return [
@@ -57,7 +57,7 @@ final class SmartlinksSettingsTypeTest extends TypeTestCase
public function testValuesSubmittedForAFreeParameterAreIgnored(): void
{
$submission = $this->defaultSubmission();
$submission = $this->defaultSubmission();
$submission['parameters']['utm_source']['mode'] = 'free';
$submission['parameters']['utm_source']['values'] = [
['value' => 'NOT VALID', 'label' => ''],
@@ -72,7 +72,7 @@ final class SmartlinksSettingsTypeTest extends TypeTestCase
public function testEnabledDropdownWithoutValuesIsRejected(): void
{
$submission = $this->defaultSubmission();
$submission = $this->defaultSubmission();
$submission['parameters']['utm_source']['enabled'] = '1';
$form = $this->submit($submission);
@@ -85,7 +85,7 @@ final class SmartlinksSettingsTypeTest extends TypeTestCase
public function testDropdownValuesAreStoredInOrderWithTheirDefault(): void
{
$submission = $this->defaultSubmission();
$submission = $this->defaultSubmission();
$submission['parameters']['utm_source']['enabled'] = '1';
$submission['parameters']['utm_source']['values'] = [
['value' => 'newsletter', 'label' => 'Newsletter'],
@@ -109,7 +109,7 @@ final class SmartlinksSettingsTypeTest extends TypeTestCase
public function testDuplicateAndInvalidValuesAreRejected(): void
{
$submission = $this->defaultSubmission();
$submission = $this->defaultSubmission();
$submission['parameters']['utm_medium']['enabled'] = '1';
$submission['parameters']['utm_medium']['values'] = [
['value' => 'email', 'label' => 'Email', 'is_default' => '1'],
@@ -176,7 +176,7 @@ final class SmartlinksSettingsTypeTest extends TypeTestCase
public function testLabelCannotContainPercent(): void
{
$submission = $this->defaultSubmission();
$submission['parameters']['utm_campaign']['label'] = '50% off';
$submission['parameters']['utm_campaign']['label'] = '50% off';
$form = $this->submit($submission);
@@ -26,7 +26,7 @@ final class SmartLinkValidatorTest extends TestCase
'parameters' => [
'utm_source' => [
'enabled' => '1', 'label' => 'Source', 'mode' => 'dropdown',
'values' => [
'values' => [
['value' => 'newsletter', 'label' => 'Newsletter'],
['value' => 'linkedin', 'label' => 'LinkedIn'],
],
@@ -35,6 +35,9 @@ final class SmartLinkValidatorTest extends TestCase
],
];
/**
* @param array<string, mixed> $raw
*/
private function createValidator(array $raw = self::RAW_CONFIG): SmartLinkValidator
{
$parameters = $this->createMock(CoreParametersHelper::class);
@@ -55,6 +58,9 @@ final class SmartLinkValidatorTest extends TestCase
return new SmartLinkValidator($this->createMock(SmartLinkModel::class), $provider);
}
/**
* @param array<string, mixed> $parameters
*/
private function createTaxonomy(array $parameters): UtmTaxonomy
{
$taxonomy = new UtmTaxonomy();
@@ -152,4 +158,4 @@ final class SmartLinkValidatorTest extends TestCase
$validator->validateUtmParameters(['utm_source' => 'facebook'])
);
}
}
}
+6 -3
View File
@@ -14,7 +14,6 @@ use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationNormalizer;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
@@ -26,6 +25,8 @@ final class SmartLinkModelTest extends TestCase
{
/**
* A real provider with the given raw configuration, served through the normalizer.
*
* @param array<string, mixed> $raw
*/
private function createProvider(array $raw): UtmConfigurationProvider
{
@@ -47,6 +48,8 @@ final class SmartLinkModelTest extends TestCase
/**
* The model with mocked core dependencies; the UTM configuration is real.
*
* @param array<string, mixed> $raw
*/
private function createModel(array $raw, ?PageModel $pageModel = null, ?UrlGeneratorInterface $router = null): SmartLinkModel
{
@@ -207,7 +210,7 @@ final class SmartLinkModelTest extends TestCase
$pageModel = $this->createMock(PageModel::class);
$pageModel->method('generateUrl')->willReturn('https://mautic.example.com/landing');
$link = new \MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink();
$link = new \MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink();
$reflection = new \ReflectionClass(\MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink::class);
$reflection->getProperty('page')->setValue($link, $this->createMock(\Mautic\PageBundle\Entity\Page::class));
@@ -224,7 +227,7 @@ final class SmartLinkModelTest extends TestCase
$form = $this->createMock(\Mautic\FormBundle\Entity\Form::class);
$form->method('getId')->willReturn(7);
$link = new \MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink();
$link = new \MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink();
$reflection = new \ReflectionClass(\MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink::class);
$reflection->getProperty('form')->setValue($link, $form);
+1 -1
View File
@@ -64,4 +64,4 @@ final class UtmTaxonomyModelTest extends TestCase
'gclid' => [],
]));
}
}
}
@@ -171,15 +171,18 @@ final class UtmConfigurationProviderTest extends TestCase
);
}
/**
* @param array<string, mixed>|null $legacy
*/
private function createProvider(mixed $stored, ?array $legacy = null): UtmConfigurationProvider
{
$parameters = $this->createMock(CoreParametersHelper::class);
$parameters->method('get')
->willReturnCallback(
fn (string $name, mixed $default = null): mixed => match (true) {
UtmConfigurationProvider::CONFIG_PARAMETER === $name => $stored,
UtmConfigurationProvider::CONFIG_PARAMETER === $name => $stored,
UtmConfigurationProvider::LEGACY_CONFIG_PARAMETER === $name && null !== $legacy => $legacy,
default => $default,
default => $default,
}
);