Skip to content

Commit

Permalink
Merge branch 'features' into refactor-deprecated-setMethod-phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzmany committed May 14, 2021
2 parents 48b9014 + 17d47fc commit e394f39
Show file tree
Hide file tree
Showing 163 changed files with 28,678 additions and 6,556 deletions.
19 changes: 19 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@
"contributions": [
"userTesting"
]
},
{
"login": "npracht",
"name": "Norman Pracht - Webmecanik",
"avatar_url": "https://avatars.githubusercontent.com/u/14075239?v=4",
"profile": "https://www.webmecanik.com",
"contributions": [
"userTesting"
]
},
{
"login": "kuzmany",
"name": "Zdeno Kuzmany",
"avatar_url": "https://avatars.githubusercontent.com/u/462477?v=4",
"profile": "https://webmecanik.com",
"contributions": [
"userTesting",
"review"
]
}
],
"contributorsPerLine": 7,
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
!/media/images/.htaccess

/plugins/*
!/plugins/GrapesJsBuilderBundle
!/plugins/MauticCitrixBundle
!/plugins/MauticClearbitBundle
!/plugins/MauticCloudStorageBundle
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
[![codecov](https://codecov.io/gh/mautic/mautic/branch/features/graph/badge.svg)](https://codecov.io/gh/mautic/mautic)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![codecov](https://codecov.io/gh/mautic/mautic/branch/features/graph/badge.svg)](https://codecov.io/gh/mautic/mautic)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->


About Mautic
============
Mautic is the world’s largest open source marketing automation project. With over 200,000 organisations using Mautic and over 1,000 community volunteers, we empower businesses by making it easy to manage their marketing across a range of channels. Stay up to date about initiatives, releases and strategy via our [blog][mautic-blog].
Expand Down Expand Up @@ -85,6 +79,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://twitter.com/dennisameling"><img src="https://avatars.githubusercontent.com/u/17739158?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dennis Ameling</b></sub></a><br /><a href="https://github.com/mautic/mautic/commits?author=dennisameling" title="Code">💻</a> <a href="#userTesting-dennisameling" title="User Testing">📓</a></td>
<td align="center"><a href="https://steercampaign.com"><img src="https://avatars.githubusercontent.com/u/12627658?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mohammad Abu Musa</b></sub></a><br /><a href="https://github.com/mautic/mautic/commits?author=mabumusa1" title="Code">💻</a></td>
<td align="center"><a href="http://johnlinhart.com"><img src="https://avatars.githubusercontent.com/u/1235442?v=4?s=100" width="100px;" alt=""/><br /><sub><b>John Linhart</b></sub></a><br /><a href="#userTesting-escopecz" title="User Testing">📓</a></td>
<td align="center"><a href="https://www.webmecanik.com"><img src="https://avatars.githubusercontent.com/u/14075239?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Norman Pracht - Webmecanik</b></sub></a><br /><a href="#userTesting-npracht" title="User Testing">📓</a></td>
<td align="center"><a href="https://webmecanik.com"><img src="https://avatars.githubusercontent.com/u/462477?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zdeno Kuzmany</b></sub></a><br /><a href="#userTesting-kuzmany" title="User Testing">📓</a> <a href="https://github.com/mautic/mautic/pulls?q=is%3Apr+reviewed-by%3Akuzmany" title="Reviewed Pull Requests">👀</a></td>
</tr>
</table>

Expand Down
7 changes: 6 additions & 1 deletion UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Symfony 4
* Symfony deprecations were removed or refactored [https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.0.md](https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.0.md)
* Services are now private by default in Symfony 4. Mautic has a "hack" to register its own services as public but dependency injection should be preferred for Commands, Controllers, and services. Some Symfony services may no longer be available to the Controller via the Container.
* \Mautic\CoreBundle\Form\Type\YesNoButtonGroupType now uses false/true values which Symfony 4 will convert to empty values for No in the UI. This shouldn't cause issues for most unless the field is using a NotBlank constraint, which is no longer valid, or submitting a form via a functional test with 0 as the value of a YesNoButtonGroupType field.
* Packages removed
* debril/rss-atom-bundle removed
* egeloen/ordered-form-bundle removed
Expand Down Expand Up @@ -59,6 +60,8 @@
```

* `mautic.http.connector` has been removed in favor of `mautic.http.client`. See the example above on how to use it in your class constructors.
* IntegrationsBundle
* The `IntegrationEvents::INTEGRATION_CONFIG_BEFORE_SAVE` event was moved to a slightly later point in time. Thanks to this change, plugin developers can actually get the updated values that were submitted by the user. This way, listeners can modify values before persisting them to the database. This brings the functionality in line with `ConfigEvents::CONFIG_PRE_SAVE`.

* PluginBundle
* If you extend `AbstractIntegration` and use the method `makeRequest`, including `$options['return_raw']`, you will now get `\Psr\Http\Message\ResponseInterface` as the response type (was `\Joomla\CMS\Http\Response`)
Expand All @@ -69,5 +72,7 @@
* \Mautic\WebhookBundle\Entity\Webhook::addQueues() removed and there is no replacement
* \Mautic\WebhookBundle\Entity\Webhook::addQueue() removed and there is no replacement
* \Mautic\WebhookBundle\Entity\Webhook::removeQueue() removed and there is no replacement
* Support for unique fields for companies
* Mautic never use unique fields for companies and use hard coded algorithm to match duplicate companies. Mautic 4 add support with Company Name as default unique field. You can configure any other fields and also expression between fields (AND/OR) in Configuration.



6 changes: 6 additions & 0 deletions app/bundles/AssetBundle/EventListener/ReportSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ public function onReportBuilder(ReportBuilderEvent $event)
$prefix = 'a.';
$columns = [
$prefix.'download_count' => [
'alias' => 'download_count',
'label' => 'mautic.asset.report.download_count',
'type' => 'int',
],
$prefix.'unique_download_count' => [
'alias' => 'unique_download_count',
'label' => 'mautic.asset.report.unique_download_count',
'type' => 'int',
],
Expand Down Expand Up @@ -102,6 +104,10 @@ public function onReportBuilder(ReportBuilderEvent $event)
);

if ($event->checkContext([self::CONTEXT_ASSET_DOWNLOAD])) {
// asset downloads calculate this columns
$columns[$prefix.'download_count']['formula'] = 'COUNT(ad.id)';
$columns[$prefix.'unique_download_count']['formula'] = 'COUNT(DISTINCT ad.lead_id)';

// Downloads
$downloadPrefix = 'ad.';
$downloadColumns = [
Expand Down
144 changes: 144 additions & 0 deletions app/bundles/AssetBundle/Tests/EventListener/ReportSubscriberTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?php

declare(strict_types=1);

namespace Mautic\AssetBundle\Tests\EventListener;

use Mautic\AssetBundle\Entity\DownloadRepository;
use Mautic\AssetBundle\EventListener\ReportSubscriber;
use Mautic\ChannelBundle\Helper\ChannelListHelper;
use Mautic\LeadBundle\Model\CompanyReportData;
use Mautic\ReportBundle\Event\ReportBuilderEvent;
use Mautic\ReportBundle\Helper\ReportHelper;
use PHPUnit\Framework\Assert;
use Symfony\Component\Translation\TranslatorInterface;

class ReportSubscriberTest extends \PHPUnit\Framework\TestCase
{
public function testOnReportBuilderWithUnknownContext(): void
{
$companyReportData = new class() extends CompanyReportData {
public function __construct()
{
}
};

$downloadRepository = new class() extends DownloadRepository {
public function __construct()
{
}
};

$event = new class() extends ReportBuilderEvent {
public function __construct()
{
$this->context = 'unicorn';
}
};

$reportSubscriber = new ReportSubscriber($companyReportData, $downloadRepository);

$reportSubscriber->onReportBuilder($event);

Assert::assertSame([], $event->getTables());
}

public function testOnReportBuilderWithAssetDownloadContext(): void
{
$companyReportData = new class() extends CompanyReportData {
public function __construct()
{
}

public function getCompanyData()
{
return [];
}
};

$downloadRepository = new class() extends DownloadRepository {
public function __construct()
{
}
};

$channelListHelper = new class() extends ChannelListHelper {
public function __construct()
{
}
};

$reportHelper = new class() extends ReportHelper {
public function __construct()
{
}
};

$event = new ReportBuilderEvent($this->createTranslatorMock(), $channelListHelper, ReportSubscriber::CONTEXT_ASSET_DOWNLOAD, [], $reportHelper);

$reportSubscriber = new ReportSubscriber($companyReportData, $downloadRepository);

$reportSubscriber->onReportBuilder($event);

Assert::assertSame(
[
'alias' => 'download_count',
'label' => '[trans]mautic.asset.report.download_count[/trans]',
'type' => 'int',
],
$event->getTables()['assets']['columns']['a.download_count']
);

Assert::assertSame(
[
'alias' => 'unique_download_count',
'label' => '[trans]mautic.asset.report.unique_download_count[/trans]',
'type' => 'int',
],
$event->getTables()['assets']['columns']['a.unique_download_count']
);

Assert::assertSame(
[
'alias' => 'download_count',
'label' => '[trans]mautic.asset.report.download_count[/trans]',
'type' => 'int',
'formula' => 'COUNT(ad.id)',
],
$event->getTables()['asset.downloads']['columns']['a.download_count']
);

Assert::assertSame(
[
'alias' => 'unique_download_count',
'label' => '[trans]mautic.asset.report.unique_download_count[/trans]',
'type' => 'int',
'formula' => 'COUNT(DISTINCT ad.lead_id)',
],
$event->getTables()['asset.downloads']['columns']['a.unique_download_count']
);
}

private function createTranslatorMock(): TranslatorInterface
{
return new class() implements TranslatorInterface {
public function trans($id, array $parameters = [], $domain = null, $locale = null)
{
return '[trans]'.$id.'[/trans]';
}

public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
{
return '[trans]'.$id.'[/trans]';
}

public function setLocale($locale)
{
}

public function getLocale()
{
}
};
}
}
10 changes: 8 additions & 2 deletions app/bundles/CampaignBundle/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ protected function cancelScheduledCampaignEventAction(Request $request)
$log->setIsScheduled(false);

/** @var EventLogModel $logModel */
$logModel = $this->getModel('campaign.event_log');
$logModel->saveEntity($log);
$logModel = $this->getModel('campaign.event_log');
$metadata = $log->getMetadata();
$metadata['errors'] = $this->translator->trans(
'mautic.campaign.event.cancelled.time',
['%date%' => $log->getTriggerDate()->format('Y-m-d H:i:s')]
);
$log->setMetadata($metadata);
$logModel->getRepository()->saveEntity($log);

$dataArray = ['success' => 1];
}
Expand Down

0 comments on commit e394f39

Please sign in to comment.