diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2016-03-10 00:55:45 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2016-04-11 05:11:33 +0300 |
commit | b52ae4e7e488e0474d67c54578e1d6c1aa066bff (patch) | |
tree | f94b02f774cbc24faaa18f29ee1e19fef8b338af /tests/PHPUnit/Framework/Mock | |
parent | 6ba622a68a26792af8cc22131f488f7ff5189d2c (diff) |
refs #7983 let plugins add or remove fields to websites and better settings api
Diffstat (limited to 'tests/PHPUnit/Framework/Mock')
4 files changed, 141 insertions, 0 deletions
diff --git a/tests/PHPUnit/Framework/Mock/Settings/FakeBackend.php b/tests/PHPUnit/Framework/Mock/Settings/FakeBackend.php new file mode 100644 index 0000000000..f57a90d159 --- /dev/null +++ b/tests/PHPUnit/Framework/Mock/Settings/FakeBackend.php @@ -0,0 +1,43 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Tests\Framework\Mock\Settings; + +use Piwik\Settings\Storage\Backend\BackendInterface; + +class FakeBackend implements BackendInterface +{ + private $storageId; + + private $data = array('field1' => 'value1', 'field2' => 'value2'); + + public function __construct($storageId) + { + $this->storageId = $storageId; + } + + public function load() + { + return $this->data; + } + + public function getStorageId() + { + return $this->storageId; + } + + public function delete() + { + $this->data = array(); + } + + public function save($values) + { + $this->data = $values; + } +} diff --git a/tests/PHPUnit/Framework/Mock/Settings/FakeMeasurableSettings.php b/tests/PHPUnit/Framework/Mock/Settings/FakeMeasurableSettings.php new file mode 100644 index 0000000000..4fb569b9d8 --- /dev/null +++ b/tests/PHPUnit/Framework/Mock/Settings/FakeMeasurableSettings.php @@ -0,0 +1,36 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Tests\Framework\Mock\Settings; + +use Piwik\Settings\Setting; + +class FakeMeasurableSettings extends \Piwik\Plugins\ExampleSettingsPlugin\MeasurableSettings { + protected $pluginName = 'ExampleSettingsPlugin'; + + public function init() + { + + } + + public function makeSetting($name, $defaultValue, $type, $fieldConfigCallback) + { + return parent::makeSetting($name, $defaultValue, $type, $fieldConfigCallback); + } + + public function makeProperty($name, $defaultValue, $type, $configureCallback) + { + return parent::makeProperty($name, $defaultValue, $type, $configureCallback); + } + + public function addSetting(Setting $setting) + { + parent::addSetting($setting); + } +} + diff --git a/tests/PHPUnit/Framework/Mock/Settings/FakeSystemSettings.php b/tests/PHPUnit/Framework/Mock/Settings/FakeSystemSettings.php new file mode 100644 index 0000000000..b7c77def9e --- /dev/null +++ b/tests/PHPUnit/Framework/Mock/Settings/FakeSystemSettings.php @@ -0,0 +1,31 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Tests\Framework\Mock\Settings; + +use Piwik\Settings\Setting; + +class FakeSystemSettings extends \Piwik\Plugins\ExampleSettingsPlugin\SystemSettings { + protected $pluginName = 'ExampleSettingsPlugin'; + + public function init() + { + + } + + public function makeSetting($name, $defaultValue, $type, $configureCallback) + { + return parent::makeSetting($name, $defaultValue, $type, $configureCallback); + } + + public function addSetting(Setting $setting) + { + parent::addSetting($setting); + } +} + diff --git a/tests/PHPUnit/Framework/Mock/Settings/FakeUserSettings.php b/tests/PHPUnit/Framework/Mock/Settings/FakeUserSettings.php new file mode 100644 index 0000000000..9d4bb5fdb1 --- /dev/null +++ b/tests/PHPUnit/Framework/Mock/Settings/FakeUserSettings.php @@ -0,0 +1,31 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Tests\Framework\Mock\Settings; + +use Piwik\Settings\Setting; + +class FakeUserSettings extends \Piwik\Plugins\ExampleSettingsPlugin\UserSettings { + protected $pluginName = 'ExampleSettingsPlugin'; + + public function init() + { + + } + + public function makeSetting($name, $defaultValue, $type, $configureCallback) + { + return parent::makeSetting($name, $defaultValue, $type, $configureCallback); + } + + public function addSetting(Setting $setting) + { + parent::addSetting($setting); + } +} + |