../../plugins/*/tests
diff --git a/tests/PHPUnit/proxy/includes.php b/tests/PHPUnit/proxy/includes.php
index 2b3407f5d54..c6f301623c7 100644
--- a/tests/PHPUnit/proxy/includes.php
+++ b/tests/PHPUnit/proxy/includes.php
@@ -10,6 +10,13 @@
define('PIWIK_TEST_MODE', true);
}
+$GLOBALS['MATOMO_PLUGIN_DIRS'] = array(
+ array(
+ 'pluginsPathAbsolute' => realpath(PIWIK_INCLUDE_PATH . 'tests/resources/custompluginsdir'),
+ 'webrootDirRelativeToMatomo' => '../../resources/custompluginsdir'
+ ),
+);
+
require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php';
Piwik\SettingsServer::setMaxExecutionTime(0);
diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_admin_settings_general.png b/tests/UI/expected-screenshots/UIIntegrationTest_admin_settings_general.png
index d692196c24a..065a48ac190 100644
--- a/tests/UI/expected-screenshots/UIIntegrationTest_admin_settings_general.png
+++ b/tests/UI/expected-screenshots/UIIntegrationTest_admin_settings_general.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:f3b6c8c65e4aa9a62b618825e4cde3839f119ca28b839fbf607c788f2f0c3846
-size 1071976
+oid sha256:0766ddf41affb5c22ad653a4bd364dc374ba0b70421fdad8622393d7025cd590
+size 1085586
diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_customdirplugin.png b/tests/UI/expected-screenshots/UIIntegrationTest_customdirplugin.png
new file mode 100644
index 00000000000..7809e57f214
--- /dev/null
+++ b/tests/UI/expected-screenshots/UIIntegrationTest_customdirplugin.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4e5cf38c4abbfc04c5d1de2903bc4a242db8e9a6a8c7be2bf2fd99d24f89808e
+size 66157
diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_fatal_error_safemode.png b/tests/UI/expected-screenshots/UIIntegrationTest_fatal_error_safemode.png
index aacf0c3d473..c3779e6ac18 100644
--- a/tests/UI/expected-screenshots/UIIntegrationTest_fatal_error_safemode.png
+++ b/tests/UI/expected-screenshots/UIIntegrationTest_fatal_error_safemode.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:68503ef9dafa19792aba12552ab81872b25247b619851d0ba1b743b31a51c919
-size 203273
+oid sha256:204573e81aa9a39a5cffdacc90e49b6f71735fdd1dec9bc6fa20a77b68525edd
+size 208738
diff --git a/tests/UI/specs/UIIntegration_spec.js b/tests/UI/specs/UIIntegration_spec.js
index 55729cce0a8..f63d3dc8142 100644
--- a/tests/UI/specs/UIIntegration_spec.js
+++ b/tests/UI/specs/UIIntegration_spec.js
@@ -27,6 +27,9 @@ describe("UIIntegrationTest", function () { // TODO: Rename to Piwik?
testEnvironment.save();
testEnvironment.callApi("SitesManager.setSiteAliasUrls", {idSite: 3, urls: []}, done);
+
+ testEnvironment.pluginsToLoad = ['CustomDirPlugin'];
+ testEnvironment.save();
});
beforeEach(function () {
@@ -83,6 +86,11 @@ describe("UIIntegrationTest", function () { // TODO: Rename to Piwik?
}, done);
});
+ it("should load the page of a plugin located in a custom directory", function (done) {
+ expect.screenshot("customdirplugin").to.be.captureSelector('.pageWrap', function (page) {
+ page.load("?module=CustomDirPlugin&action=index&idSite=1&period=day&date=yesterday");
+ }, done);
+ });
// shortcuts help
it("should show shortcut help", function (done) {
expect.screenshot("shortcuts").to.be.captureSelector('.modal.open', function (page) {
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/.gitignore b/tests/resources/custompluginsdir/CustomDirPlugin/.gitignore
new file mode 100644
index 00000000000..c8c9480010d
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/.gitignore
@@ -0,0 +1 @@
+tests/System/processed/*xml
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/API.php b/tests/resources/custompluginsdir/CustomDirPlugin/API.php
new file mode 100644
index 00000000000..08a0a957c55
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/API.php
@@ -0,0 +1,22 @@
+renderTemplate('index', array(
+ 'answerToLife' => 42,
+ 'diTest' => StaticContainer::get('customDirPluginTest')
+ ));
+ }
+}
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/CustomClass.php b/tests/resources/custompluginsdir/CustomDirPlugin/CustomClass.php
new file mode 100644
index 00000000000..01d3fe9c494
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/CustomClass.php
@@ -0,0 +1,15 @@
+ 'getStylesheetFiles',
+ 'AssetManager.getJavaScriptFiles' => 'getJsFiles',
+ );
+ }
+
+ public function getStylesheetFiles(&$stylesheets)
+ {
+ $stylesheets[] = "plugins/CustomDirPlugin/stylesheets/test.less";
+ }
+
+ public function getJsFiles(&$jsFiles)
+ {
+ $jsFiles[] = "tests/resources/custompluginsdir/javascripts/test.js";
+ }
+
+ public function postLoad()
+ {
+ // we make sure auto loading works for these directories
+ return new CustomClass();
+ }
+
+ public function isTrackerPlugin()
+ {
+ return true;
+ }
+}
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/SystemSettings.php b/tests/resources/custompluginsdir/CustomDirPlugin/SystemSettings.php
new file mode 100644
index 00000000000..d219451fa93
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/SystemSettings.php
@@ -0,0 +1,34 @@
+custom = $this->createMetricSetting();
+ }
+
+ private function createMetricSetting()
+ {
+ return $this->makeSetting('custom', $default = '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
+ $field->title = 'Custom setting';
+ $field->uiControl = FieldConfig::UI_CONTROL_TEXT;
+ $field->description = 'Enter some custom text here';
+ $field->validators[] = new NotEmpty();
+ });
+ }
+}
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/config/config.php b/tests/resources/custompluginsdir/CustomDirPlugin/config/config.php
new file mode 100644
index 00000000000..d546932d914
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/config/config.php
@@ -0,0 +1,4 @@
+ 'hello world!'
+);
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/images/ok.png b/tests/resources/custompluginsdir/CustomDirPlugin/images/ok.png
new file mode 100644
index 00000000000..148319419d5
Binary files /dev/null and b/tests/resources/custompluginsdir/CustomDirPlugin/images/ok.png differ
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/lang/en.json b/tests/resources/custompluginsdir/CustomDirPlugin/lang/en.json
new file mode 100644
index 00000000000..20927d76ef6
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/lang/en.json
@@ -0,0 +1,5 @@
+{
+ "CustomDirPlugin": {
+ "CustomName": "Custom Name"
+ }
+}
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/plugin.json b/tests/resources/custompluginsdir/CustomDirPlugin/plugin.json
new file mode 100644
index 00000000000..2d4b3c19a29
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/plugin.json
@@ -0,0 +1,29 @@
+{
+ "name": "CustomDirPlugin",
+ "description": "Custom Plugin located in different directory",
+ "version": "0.1.0",
+ "theme": false,
+ "require": {
+ "piwik": ">=3.8.1-stable,<4.0.0-b1"
+ },
+ "authors": [
+ {
+ "name": "Matomo",
+ "email": "",
+ "homepage": "https://matomo.org"
+ }
+ ],
+ "support": {
+ "email": "",
+ "issues": "",
+ "forum": "",
+ "irc": "",
+ "wiki": "",
+ "source": "",
+ "docs": "",
+ "rss": ""
+ },
+ "homepage": "https://matomo.org",
+ "license": "GPL v3+",
+ "keywords": []
+}
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/stylesheets/import.less b/tests/resources/custompluginsdir/CustomDirPlugin/stylesheets/import.less
new file mode 100644
index 00000000000..707bfa8e944
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/stylesheets/import.less
@@ -0,0 +1,3 @@
+.customPluginDirImportTest {
+ color: green;
+}
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/stylesheets/test.less b/tests/resources/custompluginsdir/CustomDirPlugin/stylesheets/test.less
new file mode 100644
index 00000000000..d2885913bc0
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/stylesheets/test.less
@@ -0,0 +1,15 @@
+.fooBarBazCustom {
+ font-weight: bold;
+ color: red;
+}
+
+@import "import.less";
+
+.customPluginDirBackgroundTestRelative {
+ background: url('../images/ok.png');
+ min-height: 30px;
+}
+.customPluginDirBackgroundTestPluginRelative {
+ background: url('plugins/CustomDirPlugin/images/ok.png');
+ min-height: 30px;
+}
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/templates/index.twig b/tests/resources/custompluginsdir/CustomDirPlugin/templates/index.twig
new file mode 100644
index 00000000000..24bce30dca0
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/templates/index.twig
@@ -0,0 +1,27 @@
+{% extends 'dashboard.twig' %}
+
+{% block content %}
+ This is our custom plugin!
+
+
+ The answer to life is {{ answerToLife }}
+
+
+ Translation test
+ This should be translated: {{ 'CustomDirPlugin_CustomName'|translate }}
+
+ image test
+ You should see an image showing a check here:
+
+ CSS import test
+ this text should appear green!
+
+ CSS background images test
+ This should have a background image relative
+
+ This should have a background image relative to plugins
+
+ Dependency Injection Test
+ You should now see hello world: {{ diTest }}
+
+{% endblock %}
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php
new file mode 100644
index 00000000000..f5d58969d09
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php
@@ -0,0 +1,35 @@
+setUpWebsite();
+ }
+
+ public function tearDown()
+ {
+ // empty
+ }
+
+ private function setUpWebsite()
+ {
+ if (!self::siteCreated($this->idSite)) {
+ $idSite = self::createWebsite($this->dateTime, $ecommerce = 1);
+ $this->assertSame($this->idSite, $idSite);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Integration/SystemSettingsTest.php b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Integration/SystemSettingsTest.php
new file mode 100644
index 00000000000..a9dd935a1e3
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Integration/SystemSettingsTest.php
@@ -0,0 +1,49 @@
+settings = new SystemSettings();
+ }
+
+ public function test_get_pluginName()
+ {
+ $this->assertSame('CustomDirPlugin', $this->settings->getPluginName());
+ }
+
+ public function test_get_default()
+ {
+ $this->assertSame('', $this->settings->custom->getValue());
+ }
+
+ public function test_set_value()
+ {
+ $this->settings->custom->setValue('%');
+ $this->assertSame('%', $this->settings->custom->getValue());
+ }
+
+}
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/APITest.php b/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/APITest.php
new file mode 100644
index 00000000000..11fd73a4f59
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/APITest.php
@@ -0,0 +1,44 @@
+assertEquals(42, Request::processRequest('CustomDirPlugin.getCustomAnswerToLive'));
+ }
+
+ public static function getOutputPrefix()
+ {
+ return '';
+ }
+
+ public static function getPathToTestDirectory()
+ {
+ return dirname(__FILE__);
+ }
+
+}
+
+APITest::$fixture = new SimpleFixtureTrackFewVisits();
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/expected/test___API.get_day.xml b/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/expected/test___API.get_day.xml
new file mode 100644
index 00000000000..213b91b66a8
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/expected/test___API.get_day.xml
@@ -0,0 +1,44 @@
+
+
+ 2
+ 2
+ 0
+ 4
+ 2
+ 0
+ 1264
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0%
+ 0
+ 0
+ 1
+ 1
+ 2541
+ 50%
+ 1
+ 1
+ 2541
+ 50%
+ 0
+ 0
+ 0
+ 0%
+ 0
+ 0
+ 0
+ 3
+ 3
+ 0
+ 0
+ 0
+ 0
+ 1
+ 1
+ 0%
+ 2
+ 632
+
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/expected/test___Goals.getItemsSku_day.xml b/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/expected/test___Goals.getItemsSku_day.xml
new file mode 100644
index 00000000000..ba820ed6498
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/System/expected/test___Goals.getItemsSku_day.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ 25641
+ 33
+ 1
+ 777
+ 33
+ 0%
+
+
\ No newline at end of file
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Unit/CustomClassTest.php b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Unit/CustomClassTest.php
new file mode 100644
index 00000000000..0018108c66c
--- /dev/null
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Unit/CustomClassTest.php
@@ -0,0 +1,35 @@
+assertTrue($customClass instanceof CustomClass);
+ }
+
+}
diff --git a/tests/resources/custompluginsdir/javascripts/test.js b/tests/resources/custompluginsdir/javascripts/test.js
new file mode 100644
index 00000000000..1b98ac75de1
--- /dev/null
+++ b/tests/resources/custompluginsdir/javascripts/test.js
@@ -0,0 +1 @@
+window.fooBarBazBarFoo = 'fooBarBaz';
\ No newline at end of file