Merge the Smartlinks plugin (SmartlinksBundle 0.6.0) into the bundle as the Smart Links domain (0.18.0)
Two domains, one MT3S bundle: Marketing Programs (unchanged) and the
imported Smart Links (smart links + UTM taxonomies), each keeping its
own menu, tables, routes and translations.
- Code moved from MauticPlugin\SmartlinksBundle\ to
MauticPlugin\MT3SMarketingProgramBundle\; template namespace
@Smartlinks/ -> @MT3SMarketingProgram/; smartlinks.js ->
Assets/js/mt3s-mp-smartlinks.js; icon -> Assets/img/smartlinks-icon.svg.
- Incoming migrations renamed Version_0_X_0_SmartLinks.php to avoid
the class-name collision; schema untouched, data intact.
- Permissions folded into MT3SMarketingProgramPermissions:
smart_links + taxonomies under the mt3smarketingprogram: base
(roles that had the old smartlinks: grants must be re-granted).
- config.php: Smart Links routes + menu group, public /l/{slug},
SmartlinksIntegration services, smartlinks_* parameters (legacy
utm_manager_* keys still readable), version 0.18.0. The 0.17.0
placeholder /s/marketing-program-utm-taxonomies is replaced by the
real /s/utm-taxonomies.
- Translations merged (en_US) and added (fr_FR); Tests/ + phpunit moved
in; readme documents both domains and the 0.18.0 merge history.
Verified live: menus, both config tabs, both lists + forms, program
pages, public redirect with taxonomy UTM values, host + unknown-slug
404s, 90/90 unit tests, full php -l, all ini catalogs parse.
This commit is contained in:
1 parent
debce4ba4a
commit
dce849610c
69 files changed
+8225
-43
No files matched your search
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Tests\Unit\Catalog;
|
||||
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterCatalog;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterDefinition;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class UtmParameterCatalogTest extends TestCase
|
||||
{
|
||||
private const STANDARD_MODES = [
|
||||
'utm_source' => UtmParameterMode::DROPDOWN,
|
||||
'utm_medium' => UtmParameterMode::DROPDOWN,
|
||||
'utm_campaign' => UtmParameterMode::FREE,
|
||||
'utm_term' => UtmParameterMode::FREE,
|
||||
'utm_content' => UtmParameterMode::FREE,
|
||||
'utm_id' => UtmParameterMode::FREE,
|
||||
'utm_source_platform' => UtmParameterMode::DROPDOWN,
|
||||
'utm_creative_format' => UtmParameterMode::DROPDOWN,
|
||||
'utm_marketing_tactic' => UtmParameterMode::DROPDOWN,
|
||||
];
|
||||
|
||||
private const PLATFORM_KEYS = ['gclid', 'gbraid', 'wbraid', 'dclid', 'fbclid', 'msclkid', 'ttclid', 'li_fat_id', 'twclid', 'epik'];
|
||||
|
||||
private UtmParameterCatalog $catalog;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->catalog = new UtmParameterCatalog();
|
||||
}
|
||||
|
||||
public function testCatalogContainsExactlyTheExpectedKeysInOrder(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
array_merge(array_keys(self::STANDARD_MODES), self::PLATFORM_KEYS),
|
||||
array_keys($this->catalog->all())
|
||||
);
|
||||
}
|
||||
|
||||
public function testStandardParameters(): void
|
||||
{
|
||||
$standard = $this->catalog->getByGroup(UtmParameterCatalog::GROUP_STANDARD);
|
||||
$this->assertSame(array_keys(self::STANDARD_MODES), array_keys($standard));
|
||||
|
||||
foreach (self::STANDARD_MODES as $key => $mode) {
|
||||
$definition = $standard[$key];
|
||||
$this->assertSame($mode, $definition->defaultMode, $key);
|
||||
$this->assertFalse($definition->autoGenerated, $key);
|
||||
$this->assertSame(UtmParameterMode::ALL, $definition->getAllowedModes(), $key);
|
||||
$this->assertSame('mautic.smartlinks.config.parameter.'.$key.'.label', $definition->getLabelKey());
|
||||
$this->assertSame('mautic.smartlinks.config.parameter.'.$key.'.description', $definition->getDescriptionKey());
|
||||
}
|
||||
}
|
||||
|
||||
public function testPlatformParametersAreAutoGeneratedDisabledAndCannotBeDropdowns(): void
|
||||
{
|
||||
$platform = $this->catalog->getByGroup(UtmParameterCatalog::GROUP_PLATFORM);
|
||||
$this->assertSame(self::PLATFORM_KEYS, array_keys($platform));
|
||||
|
||||
foreach ($platform as $key => $definition) {
|
||||
$this->assertTrue($definition->autoGenerated, $key);
|
||||
$this->assertSame(UtmParameterMode::DISABLED, $definition->defaultMode, $key);
|
||||
$this->assertSame([UtmParameterMode::FREE, UtmParameterMode::DISABLED], $definition->getAllowedModes(), $key);
|
||||
$this->assertFalse($definition->isModeAllowed(UtmParameterMode::DROPDOWN), $key);
|
||||
$this->assertSame([], $definition->suggestions, $key);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSuggestionsOnlyForDropdownParameters(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
['newsletter', 'linkedin', 'facebook', 'instagram', 'google', 'youtube', 'x', 'tiktok', 'partner', 'direct'],
|
||||
$this->catalog->get('utm_source')?->suggestions
|
||||
);
|
||||
$this->assertSame(
|
||||
['email', 'cpc', 'social', 'social_paid', 'display', 'affiliate', 'referral', 'qr', 'sms', 'print', 'event'],
|
||||
$this->catalog->get('utm_medium')?->suggestions
|
||||
);
|
||||
$this->assertSame(['google_ads', 'meta_ads', 'linkedin_ads', 'microsoft_ads', 'tiktok_ads'], $this->catalog->get('utm_source_platform')?->suggestions);
|
||||
$this->assertSame(['banner', 'video', 'carousel', 'text', 'native'], $this->catalog->get('utm_creative_format')?->suggestions);
|
||||
$this->assertSame(['prospecting', 'remarketing', 'retargeting', 'brand', 'nurturing'], $this->catalog->get('utm_marketing_tactic')?->suggestions);
|
||||
|
||||
foreach ($this->catalog->all() as $key => $definition) {
|
||||
if (UtmParameterMode::DROPDOWN !== $definition->defaultMode) {
|
||||
$this->assertSame([], $definition->suggestions, $key);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertSame('mautic.smartlinks.config.suggestion.google_ads', UtmParameterDefinition::getSuggestionLabelKey('google_ads'));
|
||||
}
|
||||
|
||||
public function testGetAndHas(): void
|
||||
{
|
||||
$this->assertTrue($this->catalog->has('utm_source'));
|
||||
$this->assertInstanceOf(UtmParameterDefinition::class, $this->catalog->get('gclid'));
|
||||
$this->assertFalse($this->catalog->has('my_param'));
|
||||
$this->assertNull($this->catalog->get('my_param'));
|
||||
}
|
||||
|
||||
#[DataProvider('reservedKeys')]
|
||||
public function testReservedKeys(string $key): void
|
||||
{
|
||||
$this->assertTrue($this->catalog->isReservedKey($key));
|
||||
$this->assertFalse($this->catalog->isValidCustomKey($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable<string, array{string}>
|
||||
*/
|
||||
public static function reservedKeys(): iterable
|
||||
{
|
||||
yield 'catalog key' => ['utm_source'];
|
||||
yield 'click id' => ['gclid'];
|
||||
yield 'mautic click tracking' => ['ct'];
|
||||
yield 'utm prefix' => ['utm_custom'];
|
||||
yield 'utm prefix without underscore' => ['utmx'];
|
||||
yield 'mtc prefix' => ['mtc_id'];
|
||||
}
|
||||
|
||||
#[DataProvider('customKeys')]
|
||||
public function testCustomKeyFormat(string $key, bool $valid): void
|
||||
{
|
||||
$this->assertSame($valid, $this->catalog->isValidCustomKey($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable<string, array{string, bool}>
|
||||
*/
|
||||
public static function customKeys(): iterable
|
||||
{
|
||||
yield 'simple' => ['ref', true];
|
||||
yield 'with digits and underscore' => ['partner_id2', true];
|
||||
yield 'two characters' => ['ab', true];
|
||||
yield 'max 41 characters' => ['a'.str_repeat('b', 40), true];
|
||||
yield 'one character' => ['a', false];
|
||||
yield 'too long' => ['a'.str_repeat('b', 41), false];
|
||||
yield 'starts with digit' => ['1abc', false];
|
||||
yield 'starts with underscore' => ['_abc', false];
|
||||
yield 'uppercase' => ['Abc', false];
|
||||
yield 'hyphen' => ['my-param', false];
|
||||
yield 'empty' => ['', false];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user