-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from matomo-org/PG-2343-retain-case-option
Added an option to retain the case of campaign parameter values via SystemSetting, #PG-2343
- Loading branch information
Showing
26 changed files
with
2,975 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* Matomo - free/libre analytics platform | ||
* | ||
* @link https://matomo.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
|
||
namespace Piwik\Plugins\MarketingCampaignsReporting; | ||
|
||
use Piwik\Piwik; | ||
use Piwik\Settings\Setting; | ||
use Piwik\Settings\FieldConfig; | ||
|
||
class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings | ||
{ | ||
/** @var Setting */ | ||
public $doNotChangeCaseOfUtmParameters; | ||
|
||
protected function init() | ||
{ | ||
$this->doNotChangeCaseOfUtmParameters = $this->makeSetting('doNotChangeCaseOfUtmParameters', true, FieldConfig::TYPE_BOOL, function (FieldConfig $field) { | ||
$field->title = Piwik::translate('MarketingCampaignsReporting_DoNotChangeCaseOfUtmParametersTitle'); | ||
$field->description = Piwik::translate('MarketingCampaignsReporting_DoNotChangeCaseOfUtmParametersDescription'); | ||
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* Matomo - free/libre analytics platform | ||
* | ||
* @link https://matomo.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
|
||
namespace Piwik\Plugins\MarketingCampaignsReporting; | ||
|
||
use Piwik\Container\StaticContainer; | ||
use Piwik\Updater; | ||
use Piwik\Updates as PiwikUpdates; | ||
use Piwik\Updater\Migration\Factory as MigrationFactory; | ||
|
||
class Updates_5_1_0 extends PiwikUpdates | ||
{ | ||
/** | ||
* @var MigrationFactory | ||
*/ | ||
private $migration; | ||
|
||
public function __construct(MigrationFactory $factory) | ||
{ | ||
$this->migration = $factory; | ||
} | ||
|
||
public function doUpdate(Updater $updater) | ||
{ | ||
// set the SystemSetting to false for existing installs as it will be true by default | ||
$systemSettings = StaticContainer::get(SystemSettings::class); | ||
$systemSettings->doNotChangeCaseOfUtmParameters->setIsWritableByCurrentUser(true); | ||
$systemSettings->doNotChangeCaseOfUtmParameters->setValue(false); | ||
$systemSettings->save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/** | ||
* Matomo - free/libre analytics platform | ||
* | ||
* @link https://matomo.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
*/ | ||
|
||
namespace Piwik\Plugins\MarketingCampaignsReporting\tests\Integration; | ||
|
||
use Piwik\Tests\Framework\Fixture; | ||
use Piwik\Tests\Framework\TestCase\IntegrationTestCase; | ||
use Piwik\Plugins\MarketingCampaignsReporting\SystemSettings; | ||
|
||
/** | ||
* @group SystemSettings | ||
* @group Plugins | ||
*/ | ||
class SystemSettingsTest extends IntegrationTestCase | ||
{ | ||
/** | ||
* @var SystemSettings | ||
*/ | ||
private $settings; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Fixture::loadAllTranslations(); | ||
|
||
Fixture::createSuperUser(); | ||
Fixture::createWebsite('2014-01-01 00:01:02'); | ||
|
||
$this->settings = new SystemSettings(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
Fixture::resetTranslations(); | ||
} | ||
|
||
public function test_doNotChangeCaseOfUtmParameters_default() | ||
{ | ||
$this->assertTrue($this->settings->doNotChangeCaseOfUtmParameters->getValue()); | ||
} | ||
|
||
public function test_doNotChangeCaseOfUtmParameters_shouldThrowException() | ||
{ | ||
$this->expectException(\Exception::class); | ||
$this->expectExceptionMessage('The value for the "Keep campaign parameter capitalisation" field in the "MarketingCampaignsReporting" plugin is not allowed'); | ||
$this->settings->doNotChangeCaseOfUtmParameters->setValue('aa'); | ||
} | ||
|
||
public function test_doNotChangeCaseOfUtmParameters_updateSuccess() | ||
{ | ||
$this->settings->doNotChangeCaseOfUtmParameters->setValue(true); | ||
$this->settings->save(); | ||
$this->assertTrue($this->settings->doNotChangeCaseOfUtmParameters->getValue()); | ||
|
||
$this->settings->doNotChangeCaseOfUtmParameters->setValue(1); | ||
$this->settings->save(); | ||
$this->assertTrue($this->settings->doNotChangeCaseOfUtmParameters->getValue()); | ||
|
||
$this->settings->doNotChangeCaseOfUtmParameters->setValue(0); | ||
$this->settings->save(); | ||
$this->assertFalse($this->settings->doNotChangeCaseOfUtmParameters->getValue()); | ||
|
||
$this->settings->doNotChangeCaseOfUtmParameters->setValue('1'); | ||
$this->settings->save(); | ||
$this->assertTrue($this->settings->doNotChangeCaseOfUtmParameters->getValue()); | ||
|
||
$this->settings->doNotChangeCaseOfUtmParameters->setValue('0'); | ||
$this->settings->save(); | ||
$this->assertFalse($this->settings->doNotChangeCaseOfUtmParameters->getValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.