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.
83 lines
3.3 KiB
PHP
83 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Tests\Unit\Form;
|
|
|
|
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterCatalog;
|
|
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
|
|
use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmSettingsValidator;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class UtmSettingsValidatorTest extends TestCase
|
|
{
|
|
private UtmSettingsValidator $validator;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->validator = new UtmSettingsValidator(new UtmParameterCatalog());
|
|
}
|
|
|
|
public function testCustomKeyRegex(): void
|
|
{
|
|
$this->assertSame([], $this->validator->validateCustomKey('partner_id'));
|
|
$this->assertSame([[UtmSettingsValidator::ERROR_KEY_INVALID, ['%key%' => 'Partner']]], $this->validator->validateCustomKey('Partner'));
|
|
$this->assertSame(UtmSettingsValidator::ERROR_KEY_INVALID, $this->validator->validateCustomKey('9lives')[0][0]);
|
|
$this->assertSame(UtmSettingsValidator::ERROR_KEY_INVALID, $this->validator->validateCustomKey('x')[0][0]);
|
|
}
|
|
|
|
public function testCustomKeyCollisions(): void
|
|
{
|
|
foreach (['utm_source', 'gclid', 'ct', 'utm_partner', 'mtc_id'] as $key) {
|
|
$this->assertSame([[UtmSettingsValidator::ERROR_KEY_RESERVED, ['%key%' => $key]]], $this->validator->validateCustomKey($key), $key);
|
|
}
|
|
}
|
|
|
|
public function testCustomKeyUniqueness(): void
|
|
{
|
|
$this->assertSame([], $this->validator->validateKeyIsUnique('ref', ['ref', 'partner']));
|
|
$this->assertSame(
|
|
[[UtmSettingsValidator::ERROR_KEY_DUPLICATE, ['%key%' => 'ref']]],
|
|
$this->validator->validateKeyIsUnique('ref', ['ref', 'partner', 'ref'])
|
|
);
|
|
}
|
|
|
|
public function testEnabledDropdownNeedsValues(): void
|
|
{
|
|
$this->assertSame(
|
|
[[UtmSettingsValidator::ERROR_VALUES_REQUIRED, []]],
|
|
$this->validator->validateValueList(UtmParameterMode::DROPDOWN, true, [])
|
|
);
|
|
$this->assertSame([], $this->validator->validateValueList(UtmParameterMode::DROPDOWN, false, []));
|
|
}
|
|
|
|
public function testDuplicateValuesAreReportedOnce(): void
|
|
{
|
|
$rows = [['value' => 'email'], ['value' => 'email'], ['value' => 'email'], ['value' => 'sms']];
|
|
|
|
$this->assertSame(
|
|
[[UtmSettingsValidator::ERROR_VALUE_DUPLICATE, ['%value%' => 'email']]],
|
|
$this->validator->validateValueList(UtmParameterMode::DROPDOWN, true, $rows)
|
|
);
|
|
}
|
|
|
|
public function testOnlyOneDefault(): void
|
|
{
|
|
$rows = [['value' => 'a', 'is_default' => true], ['value' => 'b', 'is_default' => true]];
|
|
|
|
$this->assertSame(
|
|
[[UtmSettingsValidator::ERROR_DEFAULT_MULTIPLE, []]],
|
|
$this->validator->validateValueList(UtmParameterMode::DROPDOWN, true, $rows)
|
|
);
|
|
}
|
|
|
|
public function testNothingIsCheckedOutsideDropdownMode(): void
|
|
{
|
|
$rows = [['value' => 'a', 'is_default' => true], ['value' => 'a', 'is_default' => true]];
|
|
|
|
$this->assertSame([], $this->validator->validateValueList(UtmParameterMode::FREE, true, $rows));
|
|
$this->assertSame([], $this->validator->validateValueList(UtmParameterMode::DISABLED, true, $rows));
|
|
$this->assertSame([], $this->validator->validateValueList(UtmParameterMode::FREE, true, []));
|
|
}
|
|
}
|