- 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
68 lines
2.4 KiB
PHP
68 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Tests\Unit\Model;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Mautic\CoreBundle\Helper\CoreParametersHelper;
|
|
use Mautic\CoreBundle\Helper\UserHelper;
|
|
use Mautic\CoreBundle\Security\Permissions\CorePermissions;
|
|
use MauticPlugin\MT3SMarketingProgramBundle\Model\UtmTaxonomyModel;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psr\Log\LoggerInterface;
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
final class UtmTaxonomyModelTest extends TestCase
|
|
{
|
|
private function createModel(): UtmTaxonomyModel
|
|
{
|
|
return new UtmTaxonomyModel(
|
|
$this->createMock(EntityManagerInterface::class),
|
|
$this->createMock(CorePermissions::class),
|
|
$this->createMock(EventDispatcherInterface::class),
|
|
$this->createMock(UrlGeneratorInterface::class),
|
|
$this->createMock(TranslatorInterface::class),
|
|
$this->createMock(UserHelper::class),
|
|
$this->createMock(LoggerInterface::class),
|
|
$this->createMock(CoreParametersHelper::class)
|
|
);
|
|
}
|
|
|
|
public function testNormalizeParametersTrimsDeduplicatesSortsAndFallsBackToTheValueAsLabel(): void
|
|
{
|
|
$clean = $this->createModel()->normalizeParameters([
|
|
'utm_source' => [
|
|
['value' => ' newsletter ', 'label' => 'Newsletter'],
|
|
['value' => 'newsletter', 'label' => 'Duplicate value, dropped'],
|
|
['value' => '', 'label' => 'Empty value, dropped'],
|
|
'not-an-array',
|
|
],
|
|
'utm_campaign' => [
|
|
['value' => 'spring', 'label' => ''],
|
|
],
|
|
' ' => [['value' => 'x', 'label' => 'X']],
|
|
'not-an-array' => 'nope',
|
|
]);
|
|
|
|
$this->assertSame([
|
|
'utm_campaign' => [
|
|
['value' => 'spring', 'label' => 'spring'],
|
|
],
|
|
'utm_source' => [
|
|
['value' => 'newsletter', 'label' => 'Newsletter'],
|
|
],
|
|
], $clean);
|
|
}
|
|
|
|
public function testNormalizeParametersDropsParametersWithoutValues(): void
|
|
{
|
|
$this->assertSame([], $this->createModel()->normalizeParameters([
|
|
'utm_source' => [['value' => '', 'label' => 'Empty']],
|
|
'gclid' => [],
|
|
]));
|
|
}
|
|
}
|