From 0ec6e5a572052a95ab43abd937f909ea954e74e4 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Mon, 14 Mar 2016 05:27:40 +0000 Subject: [PATCH] starting to work on Piwik 3 compatibility --- PluginSettings.php | 273 ++++++++++++++++++ Queue/Factory.php | 7 +- Settings.php | 256 ---------------- Settings/NumWorkers.php | 22 +- config/test.php | 2 +- plugin.json | 2 +- tests/Integration/Queue/FactoryTest.php | 4 +- tests/Integration/Settings/NumWorkersTest.php | 6 +- tests/Integration/SettingsTest.php | 6 +- tests/System/TrackerTest.php | 6 +- tests/UI/QueuedTrackingSettings_spec.js | 2 +- 11 files changed, 298 insertions(+), 288 deletions(-) create mode 100644 PluginSettings.php delete mode 100644 Settings.php diff --git a/PluginSettings.php b/PluginSettings.php new file mode 100644 index 0000000..2e8032f --- /dev/null +++ b/PluginSettings.php @@ -0,0 +1,273 @@ +staticStorage = new Storage(new Backend\Null('QueuedTracking')); + + $this->redisHost = $this->createRedisHostSetting(); + $this->redisPort = $this->createRedisPortSetting(); + $this->redisTimeout = $this->createRedisTimeoutSetting(); + $this->redisDatabase = $this->createRedisDatabaseSetting(); + $this->redisPassword = $this->createRedisPasswordSetting(); + $this->queueEnabled = $this->createQueueEnabledSetting(); + $this->numQueueWorkers = $this->createNumberOfQueueWorkerSetting(); + $this->numRequestsToProcess = $this->createNumRequestsToProcessSetting(); + $this->processDuringTrackingRequest = $this->createProcessInTrackingRequestSetting(); + } + + private function createRedisHostSetting() + { + $redisHost = new SettingConfig('redisHost', 'Redis host'); + $redisHost->type = SettingConfig::TYPE_STRING; + $redisHost->uiControlType = SettingConfig::CONTROL_TEXT; + $redisHost->uiControlAttributes = array('size' => 300); + $redisHost->defaultValue = '127.0.0.1'; + $redisHost->inlineHelp = 'Remote host of the Redis server. Max 300 characters are allowed.'; + $redisHost->validate = function ($value) { + if (strlen($value) > 300) { + throw new \Exception('Max 300 characters allowed'); + } + }; + + return $this->makeSystemSetting($redisHost); + } + + private function createRedisPortSetting() + { + $redisPort = new SettingConfig('redisPort', 'Redis port'); + $redisPort->type = SettingConfig::TYPE_INT; + $redisPort->uiControlType = SettingConfig::CONTROL_TEXT; + $redisPort->uiControlAttributes = array('size' => 5); + $redisPort->defaultValue = '6379'; + $redisPort->inlineHelp = 'Port the Redis server is running on. Value should be between 1 and 65535.'; + $redisPort->validate = function ($value) { + if ($value < 1) { + throw new \Exception('Port has to be at least 1'); + } + + if ($value >= 65535) { + throw new \Exception('Port should be max 65535'); + } + }; + + return $this->makeSystemSetting($redisPort); + } + + private function createRedisTimeoutSetting() + { + $redisTimeout = new SettingConfig('redisTimeout', 'Redis timeout'); + $redisTimeout->type = SettingConfig::TYPE_FLOAT; + $redisTimeout->uiControlType = SettingConfig::CONTROL_TEXT; + $redisTimeout->uiControlAttributes = array('size' => 5); + $redisTimeout->inlineHelp = 'Redis connection timeout in seconds. "0.0" meaning unlimited. Can be a float eg "2.5" for a connection timeout of 2.5 seconds.'; + $redisTimeout->defaultValue = 0.0; + $redisTimeout->validate = function ($value) { + + if (!is_numeric($value)) { + throw new \Exception('Timeout should be numeric, eg "0.1"'); + } + + if (strlen($value) > 5) { + throw new \Exception('Max 5 characters allowed'); + } + }; + + $setting = $this->makeSystemSetting($redisTimeout); + // we do not expose this one to the UI currently. That's on purpose + $setting->setIsWritableByCurrentUser(false); + + return $setting; + } + + private function createNumberOfQueueWorkerSetting() + { + $numQueueWorkers = new SettingConfig('numQueueWorkers', 'Number of queue workers'); + $numQueueWorkers->type = SettingConfig::TYPE_INT; + $numQueueWorkers->uiControlType = SettingConfig::CONTROL_TEXT; + $numQueueWorkers->uiControlAttributes = array('size' => 5); + $numQueueWorkers->inlineHelp = 'Number of allowed maximum queue workers. Accepts a number between 1 and 16. Best practice is to set the number of CPUs you want to make available for queue processing. Be aware you need to make sure to start the workers manually. We recommend to not use 9-15 workers, rather use 8 or 16 as the queue might not be distributed evenly into different queues. DO NOT USE more than 1 worker if you make use the UserId feature when tracking see https://github.com/piwik/piwik/issues/7691'; + $numQueueWorkers->defaultValue = 1; + $numQueueWorkers->validate = function ($value) { + + if (!is_numeric($value)) { + throw new \Exception('Number of queue workers should be an integer, eg "6"'); + } + + $value = (int) $value; + if ($value > 16 || $value < 1) { + throw new \Exception('Only 1-16 workers allowed'); + } + }; + + $numQueueWorkers = new NumWorkers($numQueueWorkers, $this->pluginName); + + return $this->addSetting($numQueueWorkers); + } + + private function createRedisPasswordSetting() + { + $redisPassword = new SettingConfig('redisPassword', 'Redis password'); + $redisPassword->type = SettingConfig::TYPE_STRING; + $redisPassword->uiControlType = SettingConfig::CONTROL_PASSWORD; + $redisPassword->uiControlAttributes = array('size' => 100); + $redisPassword->inlineHelp = 'Password set on the Redis server, if any. Redis can be instructed to require a password before allowing clients to execute commands.'; + $redisPassword->defaultValue = ''; + $redisPassword->validate = function ($value) { + if (strlen($value) > 100) { + throw new \Exception('Max 100 characters allowed'); + } + }; + + return $this->makeSystemSetting($redisPassword); + } + + private function createRedisDatabaseSetting() + { + $redisDatabase = new SettingConfig('redisDatabase', 'Redis database'); + $redisDatabase->type = SettingConfig::TYPE_INT; + $redisDatabase->uiControlType = SettingConfig::CONTROL_TEXT; + $redisDatabase->uiControlAttributes = array('size' => 5); + $redisDatabase->defaultValue = 0; + $redisDatabase->inlineHelp = 'In case you are using Redis for caching make sure to use a different database.'; + $redisDatabase->validate = function ($value) { + if (!is_numeric($value) || false !== strpos($value, '.')) { + throw new \Exception('The database has to be an integer'); + } + + if (strlen($value) > 5) { + throw new \Exception('Max 5 digits allowed'); + } + }; + + return $this->makeSystemSetting($redisDatabase); + } + + private function createQueueEnabledSetting() + { + $self = $this; + $queueEnabled = new SettingConfig('queueEnabled', 'Queue enabled'); + $queueEnabled->type = SettingConfig::TYPE_BOOL; + $queueEnabled->uiControlType = SettingConfig::CONTROL_CHECKBOX; + $queueEnabled->inlineHelp = 'If enabled, all tracking requests will be written into a queue instead of the directly into the database. Requires a Redis server and phpredis PHP extension.'; + $queueEnabled->defaultValue = false; + $queueEnabled->validate = function ($value) use ($self) { + $value = (bool) $value; + + if ($value) { + $host = $self->redisHost->getValue(); + $port = $self->redisPort->getValue(); + $timeout = $self->redisTimeout->getValue(); + $password = $self->redisPassword->getValue(); + + $systemCheck = new SystemCheck(); + $systemCheck->checkRedisIsInstalled(); + $systemCheck->checkConnectionDetails($host, $port, $timeout, $password); + } + }; + + return $this->makeSystemSetting($queueEnabled); + } + + private function createNumRequestsToProcessSetting() + { + $numRequestsToProcess = new SettingConfig('numRequestsToProcess', 'Number of requests that are processed in one batch'); + $numRequestsToProcess->type = SettingConfig::TYPE_INT; + $numRequestsToProcess->uiControlType = SettingConfig::CONTROL_TEXT; + $numRequestsToProcess->uiControlAttributes = array('size' => 3); + $numRequestsToProcess->inlineHelp = 'Defines how many requests will be picked out of the queue and processed at once. Enter a number which is >= 1.'; + $numRequestsToProcess->defaultValue = 25; + $numRequestsToProcess->validate = function ($value, $setting) { + + if (!is_numeric($value)) { + throw new \Exception('Value should be a number'); + } + + if ((int) $value < 1) { + throw new \Exception('Number should be 1 or higher'); + } + }; + + return $this->makeSystemSetting($numRequestsToProcess); + } + + private function createProcessInTrackingRequestSetting() + { + $processDuringTrackingRequest = new SettingConfig('processDuringTrackingRequest', 'Process during tracking request'); + $processDuringTrackingRequest->type = SettingConfig::TYPE_BOOL; + $processDuringTrackingRequest->uiControlType = SettingConfig::CONTROL_CHECKBOX; + $processDuringTrackingRequest->inlineHelp = 'If enabled, we will process all requests within a queue during a normal tracking request once there are enough requests in the queue. This will not slow down the tracking request. If disabled, you have to setup a cronjob that executes the "./console queuedtracking:process" console command eg every minute to process the queue.'; + $processDuringTrackingRequest->defaultValue = true; + + return $this->makeSystemSetting($processDuringTrackingRequest); + } + + public function save() + { + parent::save(); + + $oldNumWorkers = $this->numQueueWorkers->getOldValue(); + $newNumWorkers = $this->numQueueWorkers->getValue(); + + if ($newNumWorkers && $oldNumWorkers) { + try { + $manager = Factory::makeQueueManager(Factory::makeBackend()); + $manager->setNumberOfAvailableQueues($newNumWorkers); + $manager->moveSomeQueuesIfNeeded($newNumWorkers, $oldNumWorkers); + } catch (\Exception $e) { + // it is ok if this fails. then it is most likely not enabled etc. + } + } + } + +} diff --git a/Queue/Factory.php b/Queue/Factory.php index f158f9d..af34539 100644 --- a/Queue/Factory.php +++ b/Queue/Factory.php @@ -11,8 +11,7 @@ use Piwik\Container\StaticContainer; use Piwik\Plugins\QueuedTracking\Queue; -use Piwik\Plugins\QueuedTracking\Settings; -use Piwik\Tracker\SettingsStorage; +use Piwik\Plugins\QueuedTracking\PluginSettings; /** * This class represents a page view, tracking URL, page title and generation time. @@ -45,10 +44,10 @@ public static function makeLock(Backend $backend) public static function getSettings() { - return StaticContainer::get('Piwik\Plugins\QueuedTracking\Settings'); + return StaticContainer::get('Piwik\Plugins\QueuedTracking\PluginSettings'); } - private static function makeBackendFromSettings(Settings $settings) + private static function makeBackendFromSettings(PluginSettings $settings) { $host = $settings->redisHost->getValue(); $port = $settings->redisPort->getValue(); diff --git a/Settings.php b/Settings.php deleted file mode 100644 index 09ef8c6..0000000 --- a/Settings.php +++ /dev/null @@ -1,256 +0,0 @@ -staticStorage = new StaticStorage('QueuedTracking'); - - $this->createRedisHostSetting(); - $this->createRedisPortSetting(); - $this->createRedisTimeoutSetting(); - $this->createRedisDatabaseSetting(); - $this->createRedisPasswordSetting(); - $this->createQueueEnabledSetting(); - $this->createNumberOfQueueWorkerSetting(); - $this->createNumRequestsToProcessSetting(); - $this->createProcessInTrackingRequestSetting(); - } - - private function createRedisHostSetting() - { - $this->redisHost = new SystemSetting('redisHost', 'Redis host'); - $this->redisHost->readableByCurrentUser = true; - $this->redisHost->type = static::TYPE_STRING; - $this->redisHost->uiControlType = static::CONTROL_TEXT; - $this->redisHost->uiControlAttributes = array('size' => 300); - $this->redisHost->defaultValue = '127.0.0.1'; - $this->redisHost->inlineHelp = 'Remote host of the Redis server. Max 300 characters are allowed.'; - $this->redisHost->validate = function ($value) { - if (strlen($value) > 300) { - throw new \Exception('Max 300 characters allowed'); - } - }; - - $this->addSetting($this->redisHost); - } - - private function createRedisPortSetting() - { - $this->redisPort = new SystemSetting('redisPort', 'Redis port'); - $this->redisPort->readableByCurrentUser = true; - $this->redisPort->type = static::TYPE_INT; - $this->redisPort->uiControlType = static::CONTROL_TEXT; - $this->redisPort->uiControlAttributes = array('size' => 5); - $this->redisPort->defaultValue = '6379'; - $this->redisPort->inlineHelp = 'Port the Redis server is running on. Value should be between 1 and 65535.'; - $this->redisPort->validate = function ($value) { - if ($value < 1) { - throw new \Exception('Port has to be at least 1'); - } - - if ($value >= 65535) { - throw new \Exception('Port should be max 65535'); - } - }; - - $this->addSetting($this->redisPort); - } - - private function createRedisTimeoutSetting() - { - $this->redisTimeout = new SystemSetting('redisTimeout', 'Redis timeout'); - $this->redisTimeout->readableByCurrentUser = true; - $this->redisTimeout->type = static::TYPE_FLOAT; - $this->redisTimeout->uiControlType = static::CONTROL_TEXT; - $this->redisTimeout->uiControlAttributes = array('size' => 5); - $this->redisTimeout->inlineHelp = 'Redis connection timeout in seconds. "0.0" meaning unlimited. Can be a float eg "2.5" for a connection timeout of 2.5 seconds.'; - $this->redisTimeout->defaultValue = 0.0; - $this->redisTimeout->validate = function ($value) { - - if (!is_numeric($value)) { - throw new \Exception('Timeout should be numeric, eg "0.1"'); - } - - if (strlen($value) > 5) { - throw new \Exception('Max 5 characters allowed'); - } - }; - - // we do not expose this one to the UI currently. That's on purpose - $this->redisTimeout->setStorage($this->staticStorage); - } - - private function createNumberOfQueueWorkerSetting() - { - $this->numQueueWorkers = new NumWorkers('numQueueWorkers', 'Number of queue workers'); - $this->numQueueWorkers->readableByCurrentUser = true; - $this->numQueueWorkers->type = static::TYPE_INT; - $this->numQueueWorkers->uiControlType = static::CONTROL_TEXT; - $this->numQueueWorkers->uiControlAttributes = array('size' => 5); - $this->numQueueWorkers->inlineHelp = 'Number of allowed maximum queue workers. Accepts a number between 1 and 16. Best practice is to set the number of CPUs you want to make available for queue processing. Be aware you need to make sure to start the workers manually. We recommend to not use 9-15 workers, rather use 8 or 16 as the queue might not be distributed evenly into different queues. DO NOT USE more than 1 worker if you make use the UserId feature when tracking see https://github.com/piwik/piwik/issues/7691'; - $this->numQueueWorkers->defaultValue = 1; - $this->numQueueWorkers->validate = function ($value) { - - if (!is_numeric($value)) { - throw new \Exception('Number of queue workers should be an integer, eg "6"'); - } - - $value = (int) $value; - if ($value > 16 || $value < 1) { - throw new \Exception('Only 1-16 workers allowed'); - } - }; - - $this->addSetting($this->numQueueWorkers); - } - - private function createRedisPasswordSetting() - { - $this->redisPassword = new SystemSetting('redisPassword', 'Redis password'); - $this->redisPassword->readableByCurrentUser = true; - $this->redisPassword->type = static::TYPE_STRING; - $this->redisPassword->uiControlType = static::CONTROL_PASSWORD; - $this->redisPassword->uiControlAttributes = array('size' => 100); - $this->redisPassword->inlineHelp = 'Password set on the Redis server, if any. Redis can be instructed to require a password before allowing clients to execute commands.'; - $this->redisPassword->defaultValue = ''; - $this->redisPassword->validate = function ($value) { - if (strlen($value) > 100) { - throw new \Exception('Max 100 characters allowed'); - } - }; - - $this->addSetting($this->redisPassword); - } - - private function createRedisDatabaseSetting() - { - $this->redisDatabase = new SystemSetting('redisDatabase', 'Redis database'); - $this->redisDatabase->readableByCurrentUser = true; - $this->redisDatabase->type = static::TYPE_INT; - $this->redisDatabase->uiControlType = static::CONTROL_TEXT; - $this->redisDatabase->uiControlAttributes = array('size' => 5); - $this->redisDatabase->defaultValue = 0; - $this->redisDatabase->inlineHelp = 'In case you are using Redis for caching make sure to use a different database.'; - $this->redisDatabase->validate = function ($value) { - if (!is_numeric($value) || false !== strpos($value, '.')) { - throw new \Exception('The database has to be an integer'); - } - - if (strlen($value) > 5) { - throw new \Exception('Max 5 digits allowed'); - } - }; - - $this->addSetting($this->redisDatabase); - } - - private function createQueueEnabledSetting() - { - $self = $this; - $this->queueEnabled = new SystemSetting('queueEnabled', 'Queue enabled'); - $this->queueEnabled->readableByCurrentUser = true; - $this->queueEnabled->type = static::TYPE_BOOL; - $this->queueEnabled->uiControlType = static::CONTROL_CHECKBOX; - $this->queueEnabled->inlineHelp = 'If enabled, all tracking requests will be written into a queue instead of the directly into the database. Requires a Redis server and phpredis PHP extension.'; - $this->queueEnabled->defaultValue = false; - $this->queueEnabled->validate = function ($value) use ($self) { - $value = (bool) $value; - - if ($value) { - $host = $self->redisHost->getValue(); - $port = $self->redisPort->getValue(); - $timeout = $self->redisTimeout->getValue(); - $password = $self->redisPassword->getValue(); - - $systemCheck = new SystemCheck(); - $systemCheck->checkRedisIsInstalled(); - $systemCheck->checkConnectionDetails($host, $port, $timeout, $password); - } - }; - - $this->addSetting($this->queueEnabled); - } - - private function createNumRequestsToProcessSetting() - { - $this->numRequestsToProcess = new SystemSetting('numRequestsToProcess', 'Number of requests that are processed in one batch'); - $this->numRequestsToProcess->readableByCurrentUser = true; - $this->numRequestsToProcess->type = static::TYPE_INT; - $this->numRequestsToProcess->uiControlType = static::CONTROL_TEXT; - $this->numRequestsToProcess->uiControlAttributes = array('size' => 3); - $this->numRequestsToProcess->inlineHelp = 'Defines how many requests will be picked out of the queue and processed at once. Enter a number which is >= 1.'; - $this->numRequestsToProcess->defaultValue = 25; - $this->numRequestsToProcess->validate = function ($value, $setting) { - - if (!is_numeric($value)) { - throw new \Exception('Value should be a number'); - } - - if ((int) $value < 1) { - throw new \Exception('Number should be 1 or higher'); - } - }; - - $this->addSetting($this->numRequestsToProcess); - } - - private function createProcessInTrackingRequestSetting() - { - $this->processDuringTrackingRequest = new SystemSetting('processDuringTrackingRequest', 'Process during tracking request'); - $this->processDuringTrackingRequest->readableByCurrentUser = true; - $this->processDuringTrackingRequest->type = static::TYPE_BOOL; - $this->processDuringTrackingRequest->uiControlType = static::CONTROL_CHECKBOX; - $this->processDuringTrackingRequest->inlineHelp = 'If enabled, we will process all requests within a queue during a normal tracking request once there are enough requests in the queue. This will not slow down the tracking request. If disabled, you have to setup a cronjob that executes the "./console queuedtracking:process" console command eg every minute to process the queue.'; - $this->processDuringTrackingRequest->defaultValue = true; - - $this->addSetting($this->processDuringTrackingRequest); - } - -} diff --git a/Settings/NumWorkers.php b/Settings/NumWorkers.php index 097f51e..76806af 100644 --- a/Settings/NumWorkers.php +++ b/Settings/NumWorkers.php @@ -10,30 +10,24 @@ use Piwik\Cache; use Piwik\Config; -use Piwik\Plugins\QueuedTracking\Queue\Factory; -use Piwik\Settings\SystemSetting; +use Piwik\Settings\Plugin\SystemSetting; /** * Defines Settings for QueuedTracking. */ class NumWorkers extends SystemSetting { + private $oldValue; + + public function getOldValue() + { + return $this->oldValue; + } public function setValue($value) { - $newNumWorkers = $value; - $oldNumWorkers = $this->getValue(); + $this->oldValue = $this->getValue(); parent::setValue($value); - - if ($newNumWorkers && $oldNumWorkers) { - try { - $manager = Factory::makeQueueManager(Factory::makeBackend()); - $manager->setNumberOfAvailableQueues($newNumWorkers); - $manager->moveSomeQueuesIfNeeded($newNumWorkers, $oldNumWorkers); - } catch (\Exception $e) { - // it is ok if this fails. then it is most likely not enabled etc. - } - } } } diff --git a/config/test.php b/config/test.php index 9689722..e4123d9 100644 --- a/config/test.php +++ b/config/test.php @@ -2,7 +2,7 @@ return array( - 'Piwik\Plugins\QueuedTracking\Settings' => DI\decorate(function (\Piwik\Plugins\QueuedTracking\Settings $settings) { + 'Piwik\Plugins\QueuedTracking\PluginSettings' => DI\decorate(function (\Piwik\Plugins\QueuedTracking\PluginSettings $settings) { if ($settings->redisHost->isWritableByCurrentUser()) { $settings->redisHost->setValue('127.0.0.1'); $settings->redisPort->setValue(6379); diff --git a/plugin.json b/plugin.json index 755885a..92e939e 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "name": "QueuedTracking", - "version": "0.2.5", + "version": "0.2.6", "description": "Scale your large traffic Piwik service by queuing tracking requests in Redis for better performance. ", "theme": false, "keywords": ["tracker", "tracking", "queue", "redis"], diff --git a/tests/Integration/Queue/FactoryTest.php b/tests/Integration/Queue/FactoryTest.php index 0211ad0..d9a44d5 100644 --- a/tests/Integration/Queue/FactoryTest.php +++ b/tests/Integration/Queue/FactoryTest.php @@ -10,7 +10,7 @@ use Piwik\Plugins\QueuedTracking\Queue; use Piwik\Plugins\QueuedTracking\Queue\Factory; -use Piwik\Plugins\QueuedTracking\Settings; +use Piwik\Plugins\QueuedTracking\PluginSettings; use Piwik\Plugins\QueuedTracking\tests\Framework\TestCase\IntegrationTestCase; /** @@ -65,7 +65,7 @@ public function test_makeBackend_shouldConfigureRedis() public function test_getSettings_shouldReturnARedisInstance() { $settings = Factory::getSettings(); - $this->assertTrue($settings instanceof Settings); + $this->assertTrue($settings instanceof PluginSettings); } public function test_getSettings_shouldReturnASingleton() diff --git a/tests/Integration/Settings/NumWorkersTest.php b/tests/Integration/Settings/NumWorkersTest.php index dc730c3..d6f1ae9 100644 --- a/tests/Integration/Settings/NumWorkersTest.php +++ b/tests/Integration/Settings/NumWorkersTest.php @@ -10,7 +10,7 @@ use Piwik\Container\StaticContainer; use Piwik\Plugins\QueuedTracking\Queue\Factory; -use Piwik\Plugins\QueuedTracking\Settings; +use Piwik\Plugins\QueuedTracking\PluginSettings; use Piwik\Plugins\QueuedTracking\tests\Framework\TestCase\IntegrationTestCase; use Piwik\Tracker\RequestSet; @@ -23,7 +23,7 @@ class NumWorkersTest extends IntegrationTestCase { /** - * @var Settings + * @var PluginSettings */ private $settings; @@ -32,7 +32,7 @@ public function setUp() parent::setUp(); $this->clearRedisDb(); - $this->settings = self::$fixture->piwikEnvironment->getContainer()->get('Piwik\Plugins\QueuedTracking\Settings'); + $this->settings = self::$fixture->piwikEnvironment->getContainer()->get('Piwik\Plugins\QueuedTracking\PluginSettings'); } public function tearDown() diff --git a/tests/Integration/SettingsTest.php b/tests/Integration/SettingsTest.php index e9da111..a69c7c2 100644 --- a/tests/Integration/SettingsTest.php +++ b/tests/Integration/SettingsTest.php @@ -8,7 +8,7 @@ namespace Piwik\Plugins\QueuedTracking\tests\Integration; -use Piwik\Plugins\QueuedTracking\Settings; +use Piwik\Plugins\QueuedTracking\PluginSettings; use Piwik\Plugins\QueuedTracking\tests\Framework\TestCase\IntegrationTestCase; /** @@ -20,7 +20,7 @@ class SettingsTest extends IntegrationTestCase { /** - * @var Settings + * @var PluginSettings */ private $settings; @@ -28,7 +28,7 @@ public function setUp() { parent::setUp(); - $this->settings = new Settings(); + $this->settings = new PluginSettings(); } public function tearDown() diff --git a/tests/System/TrackerTest.php b/tests/System/TrackerTest.php index 159a0ce..7ac330f 100644 --- a/tests/System/TrackerTest.php +++ b/tests/System/TrackerTest.php @@ -12,7 +12,7 @@ use Piwik\Db; use Piwik\Plugins\QueuedTracking\Queue; use Piwik\Plugins\QueuedTracking\QueuedTracking; -use Piwik\Plugins\QueuedTracking\Settings; +use Piwik\Plugins\QueuedTracking\PluginSettings; use Piwik\Plugins\QueuedTracking\tests\Framework\TestCase\IntegrationTestCase; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\SystemTestCase; @@ -170,7 +170,7 @@ private function doTrackNumberOfRequests($numRequests, $inBulk = true) protected function enableQueue() { - $settings = new Settings(); + $settings = new PluginSettings(); $settings->queueEnabled->setValue(true); $settings->numRequestsToProcess->setValue($this->requestProcessLimit); $settings->save(); @@ -178,7 +178,7 @@ protected function enableQueue() protected function disableQueue() { - $settings = new Settings(); + $settings = new PluginSettings(); $settings->queueEnabled->setValue(false); $settings->save(); } diff --git a/tests/UI/QueuedTrackingSettings_spec.js b/tests/UI/QueuedTrackingSettings_spec.js index ac0de25..fab58f3 100644 --- a/tests/UI/QueuedTrackingSettings_spec.js +++ b/tests/UI/QueuedTrackingSettings_spec.js @@ -12,7 +12,7 @@ describe("QueuedTrackingSettings", function () { var selector = '#QueuedTracking,#QueuedTracking + .pluginIntroduction,#QueuedTracking + .pluginIntroduction + .adminTable' + ',#pluginSettings[data-pluginname=QueuedTracking]'; - var url = "?module=CoreAdminHome&action=adminPluginSettings&idSite=1&period=day&date=yesterday"; + var url = "?module=CorePluginsAdmin&action=adminPluginSettings&idSite=1&period=day&date=yesterday"; it("should display the settings page", function (done) { expect.screenshot('settings_page').to.be.captureSelector(selector, function (page) {