Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsgiehl <stefangiehl@gmail.com>2012-10-19 21:47:37 +0400
committersgiehl <stefangiehl@gmail.com>2012-10-19 21:47:37 +0400
commit5762ad9e177d844593032133c99881417f56de5b (patch)
tree81bc88f1f37699f828bf38a15e66e7d3f9f9aa14
parent389c28f97b53cd37d0719366aaa3ada479d7c053 (diff)
refs #3227 removing plugin simple tests
git-svn-id: http://dev.piwik.org/svn/trunk@7240 59fd770c-687e-43c8-a1e3-f5a4ff64c105
-rw-r--r--plugins/Actions/tests/Actions.test.php120
-rw-r--r--plugins/AnonymizeIP/tests/AnonymizeIP.test.php58
-rw-r--r--plugins/ExampleAPI/tests/Integration.test.php37
-rw-r--r--plugins/ExampleAPI/tests/compareExpectedAndProcessedFiles.WinMerge12
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.csvbin18 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.html12
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.tsvbin18 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.xml2
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.csvbin150 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.html21
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.tsvbin150 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.xml12
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.csvbin138 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.html24
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.tsvbin138 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.xml8
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.csvbin184 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.html12
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.tsvbin180 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.xml2
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.csv21
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.html21
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.tsv21
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml22
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.csv2
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.html1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.tsv1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.xml4
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.csv1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.html1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.tsv1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.xml4
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.csvbin16 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.html12
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.tsvbin16 -> 0 bytes
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.xml2
-rw-r--r--plugins/ExamplePlugin/tests/ExamplePlugin.test.php73
-rw-r--r--plugins/LanguagesManager/tests/LanguagesManager.test.php259
-rw-r--r--plugins/Login/tests/Login.test.php231
-rw-r--r--plugins/PDFReports/tests/PDFReports.test.php241
-rwxr-xr-xplugins/PrivacyManager/tests/PrivacyManager.test.php850
-rw-r--r--plugins/Proxy/tests/Proxy.test.php36
-rw-r--r--plugins/Referers/tests/Referers.test.php120
-rw-r--r--plugins/SEO/tests/SEO.test.php43
-rw-r--r--plugins/SitesManager/tests/SitesManager.test.php930
-rw-r--r--plugins/UserCountry/tests/UserCountry.test.php57
-rw-r--r--plugins/UserSettings/tests/UserSettings.test.php971
-rw-r--r--plugins/UsersManager/tests/UsersManager.test.php985
64 files changed, 0 insertions, 5246 deletions
diff --git a/plugins/Actions/tests/Actions.test.php b/plugins/Actions/tests/Actions.test.php
deleted file mode 100644
index 43919f4a69..0000000000
--- a/plugins/Actions/tests/Actions.test.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-require_once 'Actions/Actions.php';
-require_once 'Tracker/Action.php';
-
-class Test_Piwik_Actions extends UnitTestCase
-{
-
- function setUp()
- {
- $userFile = PIWIK_INCLUDE_PATH . '/tests/resources/plugins/Actions/Actions.config.ini.php';
- Piwik::createConfigObject($userFile);
- Piwik_Translate::getInstance()->loadEnglishTranslation();
- Piwik_Config::getInstance()->setTestEnvironment();
- }
-
- function tearDown()
- {
- Piwik::createConfigObject();
- Piwik_Config::getInstance()->setTestEnvironment();
- }
-
- function test_getActionExplodedNames()
- {
- $action = new Test_Piwik_Actions_getActionExplodedNames();
-
- $tests = array(
- array(
- 'params' => array( 'name' => 'http://example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => null ),
- 'expected' => array('/index' ),
- ),
- array(
- 'params' => array( 'name' => 'example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 1 ),
- 'expected' => array('/index' ),
- ),
- array(
- 'params' => array( 'name' => 'example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 2 ),
- 'expected' => array('/index' ),
- ),
- array(
- 'params' => array( 'name' => 'example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 3 ),
- 'expected' => array('/index' ),
- ),
- array(
- 'params' => array( 'name' => 'example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 4 ),
- 'expected' => array('/index' ),
- ),
- array(
- 'params' => array( 'name' => 'example.org/path/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 4 ),
- 'expected' => array( 'path', '/index' ),
- ),
- array(
- 'params' => array( 'name' => 'example.org/test/path', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 1 ),
- 'expected' => array( 'test', '/path' ),
- ),
- array(
- 'params' => array( 'name' => 'Test / Path', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL),
- 'expected' => array( 'Test', '/Path' ),
- ),
- array(
- 'params' => array( 'name' => ' Test trim ', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL),
- 'expected' => array( '/Test trim' ),
- ),
- array(
- 'params' => array( 'name' => 'Category / Subcategory', 'type' => Piwik_Tracker_Action::TYPE_ACTION_NAME),
- 'expected' => array( 'Category', ' Subcategory' ),
- ),
- array(
- 'params' => array( 'name' => '/path/index.php?var=test', 'type' => Piwik_Tracker_Action::TYPE_ACTION_NAME),
- 'expected' => array( 'path', ' index.php?var=test' ),
- ),
- array(
- 'params' => array( 'name' => 'http://example.org/path/Default.aspx#anchor', 'type' => Piwik_Tracker_Action::TYPE_ACTION_NAME),
- 'expected' => array( 'path', ' Default.aspx' ),
- ),
- array(
- 'params' => array( 'name' => '', 'type' => Piwik_Tracker_Action::TYPE_ACTION_NAME),
- 'expected' => array( 'Page Name not defined' ),
- ),
- array(
- 'params' => array( 'name' => '', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL),
- 'expected' => array( 'Page URL not defined' ),
- ),
- array(
- 'params' => array( 'name' => 'http://example.org/download.zip', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD),
- 'expected' => array( 'example.org', '/download.zip' ),
- ),
- array(
- 'params' => array( 'name' => 'http://example.org/download/1/', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD),
- 'expected' => array( 'example.org', '/download/1/' ),
- ),
- array(
- 'params' => array( 'name' => 'http://example.org/link', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK),
- 'expected' => array( 'example.org', '/link' ),
- ),
- array(
- 'params' => array( 'name' => 'http://example.org/some/path/', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK),
- 'expected' => array( 'example.org', '/some/path/' ),
- ),
-
- );
- foreach($tests as $test) {
- $params = $test['params'];
- $expected = $test['expected'];
- $processed = $action->public_getActionExplodedNames($params['name'],$params['type'],isset($params['urlPrefix'])?$params['urlPrefix']:null);
- $this->assertEqual($processed, $expected, "Processed: ".var_export($processed, true) . " | Expected: ". var_export($expected, true));
- }
- }
-}
-
-class Test_Piwik_Actions_getActionExplodedNames extends Piwik_Actions {
- public function public_getActionExplodedNames($name, $type, $urlPrefix)
- {
- return self::getActionExplodedNames($name, $type, $urlPrefix);
- }
-}
diff --git a/plugins/AnonymizeIP/tests/AnonymizeIP.test.php b/plugins/AnonymizeIP/tests/AnonymizeIP.test.php
deleted file mode 100644
index 84de5d5ba0..0000000000
--- a/plugins/AnonymizeIP/tests/AnonymizeIP.test.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-if(!class_exists('Piwik_AnonymizeIP', false))
-{
- require_once dirname(__FILE__) . '/../AnonymizeIP.php';
-}
-
-class Test_Piwik_AnonymizeIP extends UnitTestCase
-{
- // IPv4 addresses and expected results
- protected $ipv4Addresses = array(
- // ip => array( expected0, expected1, expected2, expected3, expected4 ),
- '0.0.0.0' => array( "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.0.1' => array( "\x00\x00\x00\x01", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.0.255' => array( "\x00\x00\x00\xff", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.1.0' => array( "\x00\x00\x01\x00", "\x00\x00\x01\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.1.1' => array( "\x00\x00\x01\x01", "\x00\x00\x01\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.255.255' => array( "\x00\x00\xff\xff", "\x00\x00\xff\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.1.0.0' => array( "\x00\x01\x00\x00", "\x00\x01\x00\x00", "\x00\x01\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.1.1.1' => array( "\x00\x01\x01\x01", "\x00\x01\x01\x00", "\x00\x01\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.255.255.255' => array( "\x00\xff\xff\xff", "\x00\xff\xff\x00", "\x00\xff\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '1.0.0.0' => array( "\x01\x00\x00\x00", "\x01\x00\x00\x00", "\x01\x00\x00\x00", "\x01\x00\x00\x00", "\x00\x00\x00\x00" ),
- '127.255.255.255' => array( "\x7f\xff\xff\xff", "\x7f\xff\xff\x00", "\x7f\xff\x00\x00", "\x7f\x00\x00\x00", "\x00\x00\x00\x00" ),
- '128.0.0.0' => array( "\x80\x00\x00\x00", "\x80\x00\x00\x00", "\x80\x00\x00\x00", "\x80\x00\x00\x00", "\x00\x00\x00\x00" ),
- '255.255.255.255' => array( "\xff\xff\xff\xff", "\xff\xff\xff\x00", "\xff\xff\x00\x00", "\xff\x00\x00\x00", "\x00\x00\x00\x00" ),
- );
-
- public function test_applyIPMask()
- {
- foreach($this->ipv4Addresses as $ip => $expected)
- {
- // each IP is tested with 0 to 4 octets masked
- for($maskLength = 0; $maskLength <= 4; $maskLength++)
- {
- $res = Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N($ip), $maskLength);
- $this->assertEqual( $res, $expected[$maskLength], "Got ".bin2hex($res).", Expected " . bin2hex($expected[$maskLength]) );
- }
-
- // edge case (bounds check)
- $this->assertEqual( Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N($ip), 5), "\x00\x00\x00\x00", $ip );
-
- // mask IPv4 mapped addresses
- for($maskLength = 0; $maskLength <= 4; $maskLength++)
- {
- $res = Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N('::ffff:'.$ip), $maskLength);
- $this->assertEqual( $res, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff".$expected[$maskLength], "Got ".bin2hex($res).", Expected " . bin2hex($expected[$maskLength]) );
- }
- $this->assertEqual( Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N('::ffff:'.$ip), 5), "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00", $ip );
-
- // edge case (bounds check)
- $this->assertEqual( Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N('2001::ffff:'.$ip), 17), "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", $ip );
- }
- }
-}
diff --git a/plugins/ExampleAPI/tests/Integration.test.php b/plugins/ExampleAPI/tests/Integration.test.php
deleted file mode 100644
index 7bf7e1d8dd..0000000000
--- a/plugins/ExampleAPI/tests/Integration.test.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-require_once PIWIK_INCLUDE_PATH . '/tests/integration/Integration.php';
-
-/**
- * This test is a simple example of how to use the Integration test Base class
- * in order to easily build an integration test of a given plugin.
- *
- * You can for example easily generate Tracking pages and visits, and then query all API
- * to compare the output XML.
- *
- * Check out this example and more in tests/integration/*
- */
-class Test_Piwik_Integration_ExampleAPI extends Test_Integration
-{
- public function getPathToTestDirectory()
- {
- return PIWIK_INCLUDE_PATH . '/plugins/ExampleAPI/tests';
- }
-
- function test_allGetMethods()
- {
- // Executes all API methods get* and check for output
- // In this plugin, output is static and manually set in the API.php, but in other scripts,
- // one could generate fake inputs, and check that ouputs are processed as expected
- // @see tests/integration/ for more info
- $this->setApiToCall( 'ExampleAPI' );
- // Ignore the getPiwikVersion call which would otherwise fail at every new release
- $this->setApiNotToCall( 'ExampleAPI.getPiwikVersion');
- $renderers = Piwik_DataTable_Renderer::getRenderers();
- $this->callGetApiCompareOutput(__FUNCTION__, $renderers);
- }
-}
diff --git a/plugins/ExampleAPI/tests/compareExpectedAndProcessedFiles.WinMerge b/plugins/ExampleAPI/tests/compareExpectedAndProcessedFiles.WinMerge
deleted file mode 100644
index e45988ed3c..0000000000
--- a/plugins/ExampleAPI/tests/compareExpectedAndProcessedFiles.WinMerge
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-
-<project>
- <paths>
- <left>expected\</left>
- <right>processed\</right>
- <filter>*</filter>
- <subfolders>0</subfolders>
- <left-readonly>0</left-readonly>
- <right-readonly>0</right-readonly>
- </paths>
-</project>
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.csv
deleted file mode 100644
index 818221bae8..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.csv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.html
deleted file mode 100644
index fe98977c10..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<table id="ExampleAPI_getAnswerToLife" border="1">
-<thead>
- <tr>
- <th>value</th>
- </tr>
-</thead>
-<tbody>
- <tr>
- <td>42</td>
- </tr>
-</tbody>
-</table>
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.json
deleted file mode 100644
index 861b99d7da..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.json
+++ /dev/null
@@ -1 +0,0 @@
-{"value":42} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.php
deleted file mode 100644
index cabd0e3f55..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.php
+++ /dev/null
@@ -1 +0,0 @@
-i:42; \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.tsv
deleted file mode 100644
index 818221bae8..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.tsv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.xml
deleted file mode 100644
index 36a787c47a..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getAnswerToLife.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<result>42</result> \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.csv
deleted file mode 100644
index e9fa1f701d..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.csv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.html
deleted file mode 100644
index f6bf56e74d..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<table id="ExampleAPI_getCompetitionDatatable" border="1">
-<thead>
- <tr>
- <th>name</th>
- <th>license</th>
- <th>_metadata</th>
- </tr>
-</thead>
-<tbody>
- <tr>
- <td>piwik</td>
- <td>GPL</td>
- <td>'logo' =&gt; 'logo.png'</td>
- </tr>
- <tr>
- <td>google analytics</td>
- <td>commercial</td>
- <td>-</td>
- </tr>
-</tbody>
-</table>
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.json
deleted file mode 100644
index ffb42eda93..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"name":"piwik","license":"GPL","logo":"logo.png"},{"name":"google analytics","license":"commercial"}] \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.php
deleted file mode 100644
index 1c91da4ecc..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.php
+++ /dev/null
@@ -1 +0,0 @@
-a:2:{i:0;a:3:{s:4:"name";s:5:"piwik";s:7:"license";s:3:"GPL";s:4:"logo";s:8:"logo.png";}i:1;a:2:{s:4:"name";s:16:"google analytics";s:7:"license";s:10:"commercial";}} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.tsv
deleted file mode 100644
index 2a7083d16f..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.tsv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.xml
deleted file mode 100644
index 3940117f9d..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getCompetitionDatatable.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<result>
- <row>
- <name>piwik</name>
- <license>GPL</license>
- <logo>logo.png</logo>
- </row>
- <row>
- <name>google analytics</name>
- <license>commercial</license>
- </row>
-</result> \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.csv
deleted file mode 100644
index b9706fdbf4..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.csv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.html
deleted file mode 100644
index b0ed075106..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<table id="ExampleAPI_getDescriptionArray" border="1">
-<thead>
- <tr>
- <th>value</th>
- </tr>
-</thead>
-<tbody>
- <tr>
- <td>piwik</td>
- </tr>
- <tr>
- <td>open source</td>
- </tr>
- <tr>
- <td>web analytics</td>
- </tr>
- <tr>
- <td>free</td>
- </tr>
- <tr>
- <td>Strong message: Свободный Тибет</td>
- </tr>
-</tbody>
-</table>
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.json
deleted file mode 100644
index 7553c70fb4..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.json
+++ /dev/null
@@ -1 +0,0 @@
-[["piwik"],["open source"],["web analytics"],["free"],["Strong message: \u0421\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0422\u0438\u0431\u0435\u0442"]] \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.php
deleted file mode 100644
index 3a1a782a95..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.php
+++ /dev/null
@@ -1 +0,0 @@
-a:5:{i:0;a:1:{i:0;s:5:"piwik";}i:1;a:1:{i:0;s:11:"open source";}i:2;a:1:{i:0;s:13:"web analytics";}i:3;a:1:{i:0;s:4:"free";}i:4;a:1:{i:0;s:45:"Strong message: Свободный Тибет";}} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.tsv
deleted file mode 100644
index b9706fdbf4..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.tsv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.xml
deleted file mode 100644
index ca48f01970..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getDescriptionArray.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<result>
- <row>piwik</row>
- <row>open source</row>
- <row>web analytics</row>
- <row>free</row>
- <row>Strong message: Свободный Тибет</row>
-</result> \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.csv
deleted file mode 100644
index 0e6b852ec5..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.csv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.html
deleted file mode 100644
index 2a251be9e6..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<table id="ExampleAPI_getMoreInformationAnswerToLife" border="1">
-<thead>
- <tr>
- <th>value</th>
- </tr>
-</thead>
-<tbody>
- <tr>
- <td>Check http://en.wikipedia.org/wiki/The_Answer_to_Life,_the_Universe,_and_Everything</td>
- </tr>
-</tbody>
-</table>
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.json
deleted file mode 100644
index f66f45e348..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.json
+++ /dev/null
@@ -1 +0,0 @@
-{"value":"Check http:\/\/en.wikipedia.org\/wiki\/The_Answer_to_Life,_the_Universe,_and_Everything"} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.php
deleted file mode 100644
index b041c9d9a6..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.php
+++ /dev/null
@@ -1 +0,0 @@
-s:83:"Check http://en.wikipedia.org/wiki/The_Answer_to_Life,_the_Universe,_and_Everything"; \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.tsv
deleted file mode 100644
index 345534d535..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.tsv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.xml
deleted file mode 100644
index a8ddf5e69d..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMoreInformationAnswerToLife.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<result>Check http://en.wikipedia.org/wiki/The_Answer_to_Life,_the_Universe,_and_Everything</result> \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.csv
deleted file mode 100644
index 8203371f4e..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.csv
+++ /dev/null
@@ -1,21 +0,0 @@
-Error: Data structure returned is not convertible in the requested format. Try to call this method with the parameters '&amp;format=original&amp;serialize=1'; you will get the original php data structure serialized. The data structure looks like this:
- $data = array (
- 'Limitation' =&gt;
- array (
- 0 =&gt; 'Multi dimensional arrays is only supported by format=JSON',
- 1 =&gt; 'Known limitation',
- ),
- 'Second Dimension' =&gt;
- array (
- 0 =&gt; true,
- 1 =&gt; false,
- 2 =&gt; 1,
- 3 =&gt; 0,
- 4 =&gt; 152,
- 5 =&gt; 'test',
- 6 =&gt;
- array (
- 42 =&gt; 'end',
- ),
- ),
-); \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.html
deleted file mode 100644
index 24d7c53aef..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.html
+++ /dev/null
@@ -1,21 +0,0 @@
- Data structure returned is not convertible in the requested format. Try to call this method with the parameters '&amp;format=original&amp;serialize=1'; you will get the original php data structure serialized. The data structure looks like this: <br />
- $data = array (<br />
- 'Limitation' =&gt; <br />
- array (<br />
- 0 =&gt; 'Multi dimensional arrays is only supported by format=JSON',<br />
- 1 =&gt; 'Known limitation',<br />
- ),<br />
- 'Second Dimension' =&gt; <br />
- array (<br />
- 0 =&gt; true,<br />
- 1 =&gt; false,<br />
- 2 =&gt; 1,<br />
- 3 =&gt; 0,<br />
- 4 =&gt; 152,<br />
- 5 =&gt; 'test',<br />
- 6 =&gt; <br />
- array (<br />
- 42 =&gt; 'end',<br />
- ),<br />
- ),<br />
-); \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.json
deleted file mode 100644
index d5d2d57132..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Limitation":["Multi dimensional arrays is only supported by format=JSON","Known limitation"],"Second Dimension":[true,false,1,0,152,"test",{"42":"end"}]} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.php
deleted file mode 100644
index 02cb8b8afb..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.php
+++ /dev/null
@@ -1 +0,0 @@
-a:2:{s:10:"Limitation";a:2:{i:0;s:57:"Multi dimensional arrays is only supported by format=JSON";i:1;s:16:"Known limitation";}s:16:"Second Dimension";a:7:{i:0;b:1;i:1;b:0;i:2;i:1;i:3;i:0;i:4;i:152;i:5;s:4:"test";i:6;a:1:{i:42;s:3:"end";}}} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.tsv
deleted file mode 100644
index 8203371f4e..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.tsv
+++ /dev/null
@@ -1,21 +0,0 @@
-Error: Data structure returned is not convertible in the requested format. Try to call this method with the parameters '&amp;format=original&amp;serialize=1'; you will get the original php data structure serialized. The data structure looks like this:
- $data = array (
- 'Limitation' =&gt;
- array (
- 0 =&gt; 'Multi dimensional arrays is only supported by format=JSON',
- 1 =&gt; 'Known limitation',
- ),
- 'Second Dimension' =&gt;
- array (
- 0 =&gt; true,
- 1 =&gt; false,
- 2 =&gt; 1,
- 3 =&gt; 0,
- 4 =&gt; 152,
- 5 =&gt; 'test',
- 6 =&gt;
- array (
- 42 =&gt; 'end',
- ),
- ),
-); \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml
deleted file mode 100644
index c279e76ac2..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<result>
- <Limitation>
- <row>Multi dimensional arrays is only supported by format=JSON</row>
- <row>Known limitation</row>
-
- </Limitation>
- <Second_Dimension>
- <row>1</row>
- <row>0</row>
- <row>1</row>
- <row>0</row>
- <row>152</row>
- <row>test</row>
- <row>
- <row>end</row>
-
- </row>
-
- </Second_Dimension>
-
-</result> \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.csv
deleted file mode 100644
index 1a1d751354..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-message
-ok \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.html
deleted file mode 100644
index a68a872077..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.html
+++ /dev/null
@@ -1 +0,0 @@
-Success:ok \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.json
deleted file mode 100644
index b6935263ec..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.json
+++ /dev/null
@@ -1 +0,0 @@
-{"result":"success", "message":"ok"} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.php
deleted file mode 100644
index 6f039be5ce..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.php
+++ /dev/null
@@ -1 +0,0 @@
-a:2:{s:6:"result";s:7:"success";s:7:"message";s:2:"ok";} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.tsv
deleted file mode 100644
index a68a872077..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.tsv
+++ /dev/null
@@ -1 +0,0 @@
-Success:ok \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.xml
deleted file mode 100644
index ef26c9f568..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getNull.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<result>
- <success message="ok" />
-</result> \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.csv
deleted file mode 100644
index 6f022df26d..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.csv
+++ /dev/null
@@ -1 +0,0 @@
-Error: The API cannot handle this data structure. \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.html
deleted file mode 100644
index 9798700436..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.html
+++ /dev/null
@@ -1 +0,0 @@
-The API cannot handle this data structure. \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.json
deleted file mode 100644
index 6be6be4293..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.json
+++ /dev/null
@@ -1 +0,0 @@
-{"result":"error", "message":"The API cannot handle this data structure."} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.php
deleted file mode 100644
index e7c405b36b..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.php
+++ /dev/null
@@ -1 +0,0 @@
-a:2:{s:6:"result";s:5:"error";s:7:"message";s:42:"The API cannot handle this data structure.";} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.tsv
deleted file mode 100644
index 6f022df26d..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.tsv
+++ /dev/null
@@ -1 +0,0 @@
-Error: The API cannot handle this data structure. \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.xml
deleted file mode 100644
index 2b669038e1..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getObject.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<result>
- <error message="The API cannot handle this data structure." />
-</result> \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.csv
deleted file mode 100644
index 15022e49a2..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.csv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.html
deleted file mode 100644
index ed26b648c5..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<table id="ExampleAPI_getSum" border="1">
-<thead>
- <tr>
- <th>value</th>
- </tr>
-</thead>
-<tbody>
- <tr>
- <td>0</td>
- </tr>
-</tbody>
-</table>
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.json
deleted file mode 100644
index a45b788953..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.json
+++ /dev/null
@@ -1 +0,0 @@
-{"value":0} \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.php
deleted file mode 100644
index 8f66b5ba64..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.php
+++ /dev/null
@@ -1 +0,0 @@
-d:0; \ No newline at end of file
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.tsv
deleted file mode 100644
index 15022e49a2..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.tsv
+++ /dev/null
Binary files differ
diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.xml
deleted file mode 100644
index f5722c2b94..0000000000
--- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getSum.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<result>0</result> \ No newline at end of file
diff --git a/plugins/ExamplePlugin/tests/ExamplePlugin.test.php b/plugins/ExamplePlugin/tests/ExamplePlugin.test.php
deleted file mode 100644
index ff82417ab0..0000000000
--- a/plugins/ExamplePlugin/tests/ExamplePlugin.test.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-class Test_Piwik_ExamplePlugin extends UnitTestCase
-{
- function setUp()
- {
- $path = dirname(__FILE__).'/../config/local.config.php';
- if (file_exists($path))
- {
- @unlink($path);
- }
-
- $this->assertFalse(file_exists($path), 'unable to remove local.config.php');
- }
-
- function test_load_with_no_config()
- {
- $objectUnderTest = new Piwik_Plugin_Config('ExamplePlugin');
-
- $this->assertFalse($objectUnderTest->load(), 'load() with no config should fail');
- }
-
- function test_load_alternate_path()
- {
- $objectUnderTest = new Piwik_Plugin_Config('ExamplePlugin', 'local.config.sample.php');
- $config = $objectUnderTest->load();
-
- $this->assertTrue($config !== false);
- $this->assertTrue($config['id'] === 'Example');
- $this->assertTrue($config['name'] === 'ExamplePlugin');
- $this->assertTrue($config['description'] === 'This is an example');
- }
-
- function test_load()
- {
- $dir = dirname(__FILE__).'/../config';
- @copy($dir . '/local.config.sample.php', $dir . '/local.config.php');
-
- $objectUnderTest = new Piwik_Plugin_Config('ExamplePlugin');
- $config = $objectUnderTest->load();
-
- $this->assertTrue($config !== false);
- $this->assertTrue($config['id'] === 'Example');
- $this->assertTrue($config['name'] === 'ExamplePlugin');
- $this->assertTrue($config['description'] === 'This is an example');
- }
-
- function test_store()
- {
- $config = array(
- 1, 'mixed', array('a'), 'b' => 'c'
- );
-
- $objectUnderTest = new Piwik_Plugin_Config('ExamplePlugin');
- $objectUnderTest->store($config);
-
- $path = dirname(__FILE__).'/../config/local.config.php';
- $this->assertTrue(file_exists($path));
-
- $objectUnderTest = new Piwik_Plugin_Config('ExamplePlugin');
- $newConfig = $objectUnderTest->load();
-
- $this->assertTrue($config !== false);
- $this->assertTrue($config[0] === 1);
- $this->assertTrue($config[1] === 'mixed');
- $this->assertTrue(is_array($config[2]) && $config[2][0] === 'a');
- $this->assertTrue($config['b'] === 'c');
- }
-}
diff --git a/plugins/LanguagesManager/tests/LanguagesManager.test.php b/plugins/LanguagesManager/tests/LanguagesManager.test.php
deleted file mode 100644
index 730fd4024e..0000000000
--- a/plugins/LanguagesManager/tests/LanguagesManager.test.php
+++ /dev/null
@@ -1,259 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-require_once 'LanguagesManager/API.php';
-
-class Test_LanguagesManager extends UnitTestCase
-{
- function __construct( $title = '')
- {
- parent::__construct( $title );
- }
-
- // test all languages
- function test_getTranslationsForLanguages()
- {
- $allLanguages = Piwik_Common::getLanguagesList();
- $allCountries = Piwik_Common::getCountriesList();
- $englishStrings = Piwik_LanguagesManager_API::getInstance()->getTranslationsForLanguage('en');
- $englishStringsWithParameters = array();
- $expectedLanguageKeys = array();
- foreach($englishStrings as $englishString)
- {
- $stringLabel = $englishString['label'];
- $stringValue = $englishString['value'];
- $count = $this->getCountParametersToReplace($stringValue);
- if($count > 0)
- {
- $englishStringsWithParameters[$stringLabel] = $count;
- }
- $englishStringsIndexed[$stringLabel] = $stringValue;
- $expectedLanguageKeys[] = $stringLabel;
- }
-
- // we also test that none of the language php files outputs any character on the screen (eg. space before the <?php)
- $languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguages();
- foreach($languages as $language)
- {
- ob_start();
- $writeCleanedFile = false;
- $strings = Piwik_LanguagesManager_API::getInstance()->getTranslationsForLanguage($language);
- $content = ob_get_flush();
- $serializedStrings = serialize($strings);
- $invalids = array("<script", 'document.', 'javascript:', 'src=', 'BACKGROUND=', 'onload=' );
- foreach($invalids as $invalid)
- {
- $this->assertTrue(stripos($serializedStrings, $invalid) === false, "$language: language file containing javascript");
- }
- $this->assertTrue(count($strings) > 100, "$language: expecting at least 100 translations in the language file");
- $this->assertTrue(strlen($content) == 0, "$language: buffer was ".strlen($content)." long but should be zero. Translation file for '$language' must be buggy.");
-
- $cleanedStrings = array();
- foreach($strings as $string)
- {
- $stringLabel = $string['label'];
- $stringValue = $string['value'];
-
- $plugin = substr($stringLabel, 0, strpos($stringLabel, '_'));
- $plugins[$plugin] = true;
- // Testing that the translated string is not empty => '',
- if(empty($stringValue) || trim($stringValue) === '')
- {
- $writeCleanedFile = true;
- echo "$language: The string $stringLabel is empty in the translation file, removing the line. <br/>\n";
- $cleanedStrings[$stringLabel] = false;
- }
- elseif(!in_array($stringLabel, $expectedLanguageKeys)
- // translation files should not contain 3rd plugin translations, but if they are there, we shall not delete them
- // since translators have spent time working on it... at least for now we shall leave them in (until V2 and plugin repository is done)
- && !in_array($plugin, array('GeoIP', 'Forecast', 'EntryPage', 'UserLanguage'))
- )
- {
- $writeCleanedFile = true;
- echo "$language: The string $stringLabel was not found in the English language file, removing the line. <br/>\n";
- $cleanedStrings[$stringLabel] = false;
- }
- else
- {
- // checking that translated strings have the same number of %s as the english source strings
- if(isset($englishStringsWithParameters[$stringLabel]))
- {
- $englishParametersCount = $englishStringsWithParameters[$stringLabel];
- $countTranslation = $this->getCountParametersToReplace($stringValue);
- if($englishParametersCount != $countTranslation)
- {
- // Write fixed file in given location
- // Will trigger a ->fail()
- $writeCleanedFile = true;
- echo "$language: The string $stringLabel has $englishParametersCount parameters in English, but $countTranslation in this translation. <br/>\n";
- }
- else
- {
- $cleanedStrings[$stringLabel] = $stringValue;
- }
- }
- // No %s found
- else
- {
- $cleanedStrings[$stringLabel] = $stringValue;
- }
- }
-
- // If the translation is the same as in English, we remove it from the translation file (as it might have been copied by
- // the translator but this would skew translation stats
- if(isset($englishStringsIndexed[$stringLabel])
- && $englishStringsIndexed[$stringLabel] == $stringValue
- //Currently hackjed for Persian since only the Farsi translation seems affected by "english copy paste"
- && $language == 'fa')
- {
- $writeCleanedFile = true;
- echo "$language: The string $stringLabel is the same as in English, removing... <br/>\n";
- $cleanedStrings[$stringLabel] = false;
- }
- // remove excessive line breaks (and leading/trailing whitespace) from translations
- if(!empty($cleanedStrings[$stringLabel]))
- {
- $stringNoLineBreak = trim($cleanedStrings[$stringLabel]);
- if($stringLabel != 'Login_MailPasswordRecoveryBody')
- {
- $stringNoLineBreak = str_replace(array("\n", "\r"), " ", $stringNoLineBreak);
- }
- if($cleanedStrings[$stringLabel] !== $stringNoLineBreak)
- {
- echo "$language: found unnecessary whitespace in some strings in $stringLabel <br/>\n";
- $writeCleanedFile = true;
- $cleanedStrings[$stringLabel] = $stringNoLineBreak;
- }
- }
- // Test locale
- if($stringLabel == 'General_Locale'
- && !empty($cleanedStrings[$stringLabel]))
- {
- if(!preg_match('/^([a-z]{2})_([A-Z]{2})\.UTF-8$/', $cleanedStrings[$stringLabel], $matches))
- {
- $this->fail("$language: invalid locale in $stringLabel");
- }
- else if(!array_key_exists($matches[1], $allLanguages))
- {
- $this->fail("$language: invalid language code in $stringLabel");
- }
- else if(!array_key_exists(strtolower($matches[2]), $allCountries))
- {
- $this->fail("$language: invalid region (country code) in $stringLabel");
- }
- }
- if(isset($cleanedStrings[$stringLabel]))
- {
- $currentString = $cleanedStrings[$stringLabel];
- $decoded = Piwik_TranslationWriter::clean($currentString);
- if($currentString != $decoded )
- {
- echo "$language: found encoded entities in $stringLabel, converting entities to characters <br/>\n";
- $writeCleanedFile = true;
- $cleanedStrings[$stringLabel] = $decoded;
- }
- }
- }
- $this->assertTrue( !empty($cleanedStrings['General_TranslatorName'] ), "$language: translator info not specified");
- $this->assertTrue( !empty($cleanedStrings['General_TranslatorEmail'] ), "$language: translator info not specified");
- if(!empty($cleanedStrings['General_LayoutDirection'])
- && !in_array($cleanedStrings['General_LayoutDirection'], array('rtl','ltr')))
- {
- $writeCleanedFile = true;
- $cleanedStrings['General_LayoutDirection'] = false;
- echo "$language: General_LayoutDirection must be rtl or ltr";
- }
- if($writeCleanedFile)
- {
- $this->writeCleanedTranslationFile($cleanedStrings, $language);
- }
- }
-// var_dump('Unique plugins found: ' . var_export($plugins, 1));
- $this->pass();
- }
-
- private function writeCleanedTranslationFile($translations, $language)
- {
- $path = Piwik_TranslationWriter::getTranslationPath($language, 'tmp');
- Piwik_TranslationWriter::saveTranslation($translations, $path);
- $this->fail('Translation file errors detected in '.$language.'...
- Wrote cleaned translation file in: '.$path .".
- You can copy the cleaned files to /lang/<br/>\n");
- }
-
- private function getCountParametersToReplace($string)
- {
- $sprintfParameters = array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s');
- $count = 0;
- foreach($sprintfParameters as $parameter)
- {
- $count += substr_count($string, $parameter);
- }
- return $count;
- }
-
- //test language when it's not defined
- function test_getTranslationsForLanguages_not()
- {
- $this->assertFalse(Piwik_LanguagesManager_API::getInstance()->getTranslationsForLanguage("../no-language"));
- }
-
- // test English short name for language
- function test_getLanguageNamesInEnglish()
- {
- require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Languages.php';
-
- $languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguages();
- foreach($languages as $language)
- {
- require PIWIK_INCLUDE_PATH . "/lang/$language.php";
- $name = $translations['General_EnglishLanguageName'];
-
- if($language != 'en')
- {
- $this->assertFalse($name == 'English');
- }
-
- $languageCode = substr($language, 0, 2);
- $this->assertTrue(isset($GLOBALS['Piwik_LanguageList'][$languageCode]));
- $names = $GLOBALS['Piwik_LanguageList'][$languageCode];
-
- if(isset($GLOBALS['Piwik_LanguageList'][$language]))
- {
- if(is_array($names))
- {
- $this->assertTrue(in_array($name, $names), "$language: failed because $name not a known language name <br/>");
- }
- else
- {
- $this->assertTrue($name == $names, "$language: failed because $name == $names <br/>");
- }
- }
- else
- {
- if(is_array($names))
- {
- $this->assertTrue(strpos($name, $names[0]) !== false);
- }
- else
- {
- $this->fail("$language: expected an array of language names");
- }
- }
- }
- }
-
- // test format of DataFile/Languages.php
- function test_getLanguagesList()
- {
- $languages = Piwik_Common::getLanguagesList();
- $this->assertTrue( count($languages) > 0 );
- foreach($languages as $langCode => $langs) {
- $this->assertTrue(strlen($langCode) == 2, "$langCode length = 2");
- $this->assertTrue(is_array($langs) && count($langs) >= 1, "$langCode array(names) >= 1");
- }
- }
-}
diff --git a/plugins/Login/tests/Login.test.php b/plugins/Login/tests/Login.test.php
deleted file mode 100644
index ef6815ba15..0000000000
--- a/plugins/Login/tests/Login.test.php
+++ /dev/null
@@ -1,231 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-if(!class_exists('Piwik_Login_Auth', false))
-{
- require_once 'Login/Auth.php';
-}
-require_once 'Database.test.php';
-
-class Test_Piwik_Login extends Test_Database
-{
- function setUp()
- {
- parent::setUp();
-
- // setup the access layer
- $pseudoMockAccess = new FakeAccess;
- FakeAccess::setIdSitesView( array(1,2));
- FakeAccess::setIdSitesAdmin( array(3,4));
-
- //finally we set the user as a super user by default
- FakeAccess::$superUser = true;
- Zend_Registry::set('access', $pseudoMockAccess);
-
- // we make sure the tests don't depend on the config file content
- Piwik_Config::getInstance()->superuser = array(
- 'login'=>'superusertest',
- 'password'=>md5('passwordsuperusertest'),
- 'email'=>'superuser@example.com'
- );
- }
-
- public function test_authenticate()
- {
- // no login; no token auth
- $auth = new Piwik_Login_Auth();
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // empty login; no token auth
- $auth->setLogin('');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // non-existent user
- $auth->setLogin('nobody');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // anonymous user doesn't exist yet
- $auth->setLogin('anonymous');
- $auth->setTokenAuth('');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // empty login; anonymous user doesn't exist yet
- $auth->setLogin('');
- $auth->setTokenAuth('anonymous');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // API authentication; anonymous user doesn't exist yet
- $auth->setLogin(null);
- $auth->setTokenAuth('anonymous');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // anonymous user doesn't exist yet
- $auth->setLogin('anonymous');
- $auth->setTokenAuth('anonymous');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- Piwik::createAnonymousUser();
-
- // missing token_auth
- $auth->setLogin('anonymous');
- $auth->setTokenAuth('');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // empty login
- $auth->setLogin('');
- $auth->setTokenAuth('anonymous');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not equal
- $auth->setLogin('anonymous');
- $auth->setTokenAuth(0);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // API authentication
- $auth->setLogin(null);
- $auth->setTokenAuth('anonymous');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::SUCCESS );
-
- // valid login & token auth
- $auth->setLogin('anonymous');
- $auth->setTokenAuth('anonymous');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::SUCCESS );
-
- $user = array( 'login'=>'user',
- 'password'=>"geqgeagae",
- 'email'=>"test@test.com",
- 'alias'=>"alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] );
- $password = md5($user['password']);
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
-
- // empty token auth
- $auth->setLogin($user['login']);
- $auth->setTokenAuth('');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not a token auth
- $auth->setLogin($user['login']);
- $auth->setTokenAuth($user['password']);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not a token auth
- $auth->setLogin($user['login']);
- $auth->setTokenAuth($password);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // empty login
- $auth->setLogin('');
- $auth->setTokenAuth($tokenAuth);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not equal
- $auth->setLogin(0);
- $auth->setTokenAuth(0);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not equal
- $auth->setLogin(0);
- $auth->setTokenAuth($tokenAuth);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not equal
- $auth->setLogin($user['login']);
- $auth->setTokenAuth(0);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // API authentication
- $auth->setLogin(null);
- $auth->setTokenAuth($tokenAuth);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::SUCCESS );
-
- // valid login & token auth
- $auth->setLogin($user['login']);
- $auth->setTokenAuth($tokenAuth);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::SUCCESS );
-
- // valid login & hashed token auth
- $auth->setLogin($user['login']);
- $hash = $auth->getHashTokenAuth($user['login'], $tokenAuth);
- $auth->setTokenAuth($hash);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::SUCCESS );
-
- $user = Piwik_Config::getInstance()->superuser;
- $password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
-
- // empty token auth
- $auth->setLogin($user['login']);
- $auth->setTokenAuth('');
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not a token auth
- $auth->setLogin($user['login']);
- $auth->setTokenAuth($user['password']);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not a token auth
- $auth->setLogin($user['login']);
- $auth->setTokenAuth($password);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // empty login
- $auth->setLogin('');
- $auth->setTokenAuth($tokenAuth);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // not equal
- $auth->setLogin($user['login']);
- $auth->setTokenAuth(0);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::FAILURE );
-
- // API authentication
- $auth->setLogin(null);
- $auth->setTokenAuth($tokenAuth);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE );
-
- // valid login & token auth
- $auth->setLogin($user['login']);
- $auth->setTokenAuth($tokenAuth);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE );
-
- // valid login & hashed token auth
- $auth->setLogin($user['login']);
- $hash = $auth->getHashTokenAuth($user['login'], $tokenAuth);
- $auth->setTokenAuth($hash);
- $rc = $auth->authenticate();
- $this->assertEqual( $rc->getCode(), Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE );
- }
-}
diff --git a/plugins/PDFReports/tests/PDFReports.test.php b/plugins/PDFReports/tests/PDFReports.test.php
deleted file mode 100644
index 88b39d0256..0000000000
--- a/plugins/PDFReports/tests/PDFReports.test.php
+++ /dev/null
@@ -1,241 +0,0 @@
-<?php
-if(!defined("PIWIK_PATH_TEST_TO_ROOT")) {
- define('PIWIK_PATH_TEST_TO_ROOT', dirname(__FILE__).'/../../..');
-}
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once PIWIK_PATH_TEST_TO_ROOT . "/tests/config_test.php";
-}
-
-require_once PIWIK_PATH_TEST_TO_ROOT . '/tests/core/Database.test.php';
-require_once PIWIK_PATH_TEST_TO_ROOT . '/plugins/PDFReports/PDFReports.php';
-
-class Test_Piwik_PDFReports extends Test_Database
-{
- protected $idSiteAccess;
-
- function setUp()
- {
- parent::setUp();
-
- // setup the access layer
- $pseudoMockAccess = new FakeAccess;
- FakeAccess::$superUser = true;
- //finally we set the user as a super user by default
- Zend_Registry::set('access', $pseudoMockAccess);
- Piwik_PluginsManager::getInstance()->loadPlugins( array('API', 'UserCountry', 'LanguagesManager', 'PDFReports') );
- $plugin = Piwik_PluginsManager::getInstance()->getLoadedPlugin('LanguagesManager');
- $plugin->install();
- $plugin = Piwik_PluginsManager::getInstance()->getLoadedPlugin('PDFReports');
- $plugin->install();
- Piwik_PluginsManager::getInstance()->installLoadedPlugins();
- Piwik_PDFReports_API::$cache = array();
-
- $this->idSiteAccess = Piwik_SitesManager_API::getInstance()->addSite("Test",array("http://piwik.net"));
-
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("Test",array("http://piwik.net"));
- FakeAccess::setIdSitesView( array($this->idSiteAccess,2));
-
- }
-
- function tearDown()
- {
- Piwik_Query('TRUNCATE '.Piwik_Common::prefixTable('report'));
- Piwik_PDFReports_API::$cache = array();
- }
-
- function test_addReport_getReports()
- {
- $data = array(
- 'idsite' => $this->idSiteAccess,
- 'description' => 'test description"',
- 'type' => 'email',
- 'period' => 'day',
- 'format' => 'pdf',
- 'reports' => array('UserCountry_getCountry'),
- 'parameters' => array(
- 'displayFormat' => '1',
- 'emailMe' => true,
- 'additionalEmails' => array('test@test.com', 't2@test.com')
- )
- );
-
- $dataWebsiteTwo = $data;
- $dataWebsiteTwo['idsite'] = 2;
- $dataWebsiteTwo['period'] = 'month';
-
- $idReportTwo = $this->_createReport($dataWebsiteTwo);
- // Testing getReports without parameters
- $tmp = Piwik_PDFReports_API::getInstance()->getReports();
- $report = reset($tmp);
- $this->_checkReportsEqual($report, $dataWebsiteTwo);
-
- $idReport = $this->_createReport($data);
-
- // Passing 3 parameters
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($this->idSiteAccess, $data['period'], $idReport);
- $report = reset($tmp);
- $this->_checkReportsEqual($report, $data);
-
- // Passing only idsite
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($this->idSiteAccess);
- $report = reset($tmp);
- $this->_checkReportsEqual($report, $data);
-
- // Passing only period
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($idSite=false, $data['period']);
- $report = reset($tmp);
- $this->_checkReportsEqual($report, $data);
-
- // Passing only idreport
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($idSite=false,$period=false, $idReport);
- $report = reset($tmp);
- $this->_checkReportsEqual($report, $data);
- }
-
- function test_getReports_idReportNotFound()
- {
- try {
- $report = Piwik_PDFReports_API::getInstance()->getReports($idSite=false,$period=false, $idReport = 1);
- var_dump($report);
- $this->fail();
- } catch(Exception $e) {
- $this->pass();
- }
- }
-
- function test_getReports_invalidPermission()
- {
- $data = $this->_getAddReportData();
- $idReport = $this->_createReport($data);
-
- try {
- $report = Piwik_PDFReports_API::getInstance()->getReports($idSite=44,$period=false, $idReport);
- $this->fail();
- } catch(Exception $e){
- $this->pass();
- }
- }
-
- function test_addReport_invalidWebsite()
- {
- $data = $this->_getAddReportData();
- $data['idsite'] = 33;
- try {
- $idReport = $this->_createReport($data);
- $this->fail();
- } catch(Exception $e){
- $this->pass();
- }
- }
-
- function test_addReport_invalidPeriod()
- {
- $data = $this->_getAddReportData();
- $data['period'] = 'dx';
- try {
- $idReport = $this->_createReport($data);
- $this->fail();
- } catch(Exception $e){
- $this->pass();
- }
- }
-
- function test_updateReport()
- {
- $dataBefore = $this->_getAddReportData();
- $idReport = $this->_createReport($dataBefore);
- $dataAfter = $this->_getYetAnotherAddReportData();
- $this->_updateReport($idReport, $dataAfter);
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($idSite=false,$period=false, $idReport);
- $newReport = reset($tmp);
- $this->_checkReportsEqual($newReport, $dataAfter);
- }
-
- function test_deleteReport()
- {
- // Deletes non existing report throws exception
- try {
- Piwik_PDFReports_API::getInstance()->deleteReport($idReport = 1);
- $this->fail();
- } catch(Exception $e) {
- $this->pass();
- }
-
- $idReport = $this->_createReport($this->_getYetAnotherAddReportData());
- $this->assertEqual(1, count(Piwik_PDFReports_API::getInstance()->getReports()));
- Piwik_PDFReports_API::getInstance()->deleteReport($idReport);
- $this->assertEqual(0, count(Piwik_PDFReports_API::getInstance()->getReports()));
- }
-
-
- function _getAddReportData()
- {
- return array(
- 'idsite' => $this->idSiteAccess,
- 'description' => 'test description"',
- 'period' => 'day',
- 'type' => 'email',
- 'format' => 'pdf',
- 'reports' => array('UserCountry_getCountry'),
- 'parameters' => array(
- 'displayFormat' => '1',
- 'emailMe' => true,
- 'additionalEmails' => array('test@test.com', 't2@test.com')
- )
- );
- }
-
- function _getYetAnotherAddReportData()
- {
- return array(
- 'idsite' => $this->idSiteAccess,
- 'description' => 'very very long and possibly truncated description. very very long and possibly truncated description. very very long and possibly truncated description. very very long and possibly truncated description. very very long and possibly truncated description. ',
- 'period' => 'month',
- 'type' => 'email',
- 'format' => 'pdf',
- 'reports' => array('UserCountry_getContinent'),
- 'parameters' => array(
- 'displayFormat' => '1',
- 'emailMe' => false,
- 'additionalEmails' => array('blabla@ec.fr')
- )
- );
- }
- function _createReport($data)
- {
- $idReport = Piwik_PDFReports_API::getInstance()->addReport(
- $data['idsite'],
- $data['description'],
- $data['period'],
- $data['type'],
- $data['format'],
- $data['reports'],
- $data['parameters']
- );
- return $idReport;
- }
-
- function _updateReport($idReport, $data)
- {
- $idReport = Piwik_PDFReports_API::getInstance()->updateReport(
- $idReport,
- $data['idsite'],
- $data['description'],
- $data['period'],
- $data['type'],
- $data['format'],
- $data['reports'],
- $data['parameters']);
- return $idReport;
- }
-
- function _checkReportsEqual($report, $data)
- {
- foreach($data as $key => $value)
- {
- if($key == 'description') $value = substr($value,0,250);
- $this->assertEqual($value, $report[$key], "Error for $key for report ".var_export($report ,true)." and data ".var_export($data,true)." ---> %s ");
- }
- }
-}
diff --git a/plugins/PrivacyManager/tests/PrivacyManager.test.php b/plugins/PrivacyManager/tests/PrivacyManager.test.php
deleted file mode 100755
index fb93f30876..0000000000
--- a/plugins/PrivacyManager/tests/PrivacyManager.test.php
+++ /dev/null
@@ -1,850 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-require_once PIWIK_INCLUDE_PATH . '/tests/integration/Integration.php';
-
-class Test_Piwik_PrivacyManager extends Test_Integration
-{
- // constants used in checking whether numeric tables are populated correctly.
- // 'done' entries exist for every period, even if there's no metric data, so we need the
- // total archive count for each month.
- const TOTAL_JAN_ARCHIVE_COUNT = 37; // 31 + 4 + 1 + 1;
- const TOTAL_FEB_ARCHIVE_COUNT = 34; // 29 + 4 + 1;
-
- // the number of archive entries for a single metric if no purging is done. this #
- // is dependent on the number of periods for which there were visits.
- const JAN_METRIC_ARCHIVE_COUNT = 11; // 5 days + 4 weeks + 1 month + 1 year
- const FEB_METRIC_ARCHIVE_COUNT = 11; // 6 days + 4 weeks + 1 month
-
- // fake metric/report name used to make sure unwanted metrics are purged
- const GARBAGE_FIELD = 'abcdefg';
-
- private $idSite = null;
- private $dateTime = null;
- private $instance = null;
- private $daysAgoStart = 50;
- private $settings = null;
-
- private $unusedIdAction = null;
-
- public function __construct( $title = '' )
- {
- parent::__construct($title);
- $this->dateTime = Piwik_Date::factory('2012-02-28');
- }
-
- public function setUp()
- {
- parent::setUp();
-
- Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
-
- Piwik_PrivacyManager_LogDataPurger::$selectSegmentSize = 2;
- Piwik_PrivacyManager_ReportsPurger::$selectSegmentSize = 2;
- Piwik::$lockPrivilegeGranted = null;
-
- // purging depends upon today's date, so 'older_than' parts must be dependent upon today
- $today = Piwik_Date::factory('today');
- $daysSinceToday = ($today->getTimestamp() - $this->dateTime->getTimestamp()) / (24 * 60 * 60);
-
- $monthsSinceToday = 0;
- for ($date = $today; $date->toString('Y-m') != $this->dateTime->toString('Y-m'); $date = $date->subMonth(1))
- {
- ++$monthsSinceToday;
- }
-
- // set default config
- $settings = array();
- $settings['delete_logs_enable'] = 1;
- // purging log data from before 2012-01-24
- $settings['delete_logs_older_than'] = 35 + $daysSinceToday;
- $settings['delete_logs_schedule_lowest_interval'] = 7;
- $settings['delete_logs_max_rows_per_query'] = 100000;
- $settings['delete_reports_enable'] = 1;
- $settings['delete_reports_older_than'] = $monthsSinceToday;
- $settings['delete_reports_keep_basic_metrics'] = 0;
- $settings['delete_reports_keep_day_reports'] = 0;
- $settings['delete_reports_keep_week_reports'] = 0;
- $settings['delete_reports_keep_month_reports'] = 0;
- $settings['delete_reports_keep_year_reports'] = 0;
- $settings['delete_reports_keep_range_reports'] = 0;
- $settings['delete_reports_keep_segment_reports'] = 0;
- Piwik_PrivacyManager::savePurgeDataSettings($settings);
-
- $this->settings = $settings;
- $this->instance = new Piwik_PrivacyManager();
- }
-
- public function tearDown()
- {
- parent::tearDown();
-
- Piwik::$lockPrivilegeGranted = null;
-
- // remove archive tables (integration test teardown will only truncate)
- $archiveTables = $this->getArchiveTableNames();
- $archiveTables = array_merge($archiveTables['numeric'], $archiveTables['blob']);
- foreach ($archiveTables as $table)
- {
- Piwik_Query("DROP TABLE IF EXISTS ".Piwik_Common::prefixTable($table));
- }
-
- // refresh table name caches so next test will pass
- Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
- Piwik::getTablesInstalled(true);
-
- // drop temporary tables
- $tempTableName = Piwik_PrivacyManager_LogDataPurger::TEMP_TABLE_NAME;
- Piwik_Query("DROP TABLE IF EXISTS ".Piwik_Common::prefixTable($tempTableName));
- }
-
- /** Make sure the first time deleteLogData is run, nothing happens. */
- public function test_deleteLogData_initialRun()
- {
- $this->addLogData();
- $this->addReportData();
-
- $this->instance->deleteLogData();
-
- // check that initial option is set
- $this->assertEqual(
- 1, Piwik_GetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
-
- // perform other checks
- $this->checkNoDataChanges();
- }
-
- /** Make sure the first time deleteReportData is run, nothing happens. */
- public function test_deleteReportData_initialRun()
- {
- $this->addLogData();
- $this->addReportData();
-
- $this->instance->deleteReportData();
-
- // check that initial option is set
- $this->assertEqual(
- 1, Piwik_GetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
-
- // perform other checks
- $this->checkNoDataChanges();
- }
-
- /** Make sure the task is not run when its scheduled for later. */
- public function test_purgeData_notTimeToRun()
- {
- $this->addLogData();
- $this->addReportData();
-
- $yesterdaySecs = Piwik_Date::factory('yesterday')->getTimestamp();
-
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $yesterdaySecs);
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $yesterdaySecs);
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkNoDataChanges();
- }
-
- /** Make sure purging data runs when scheduled. */
- public function test_purgeData_notInitialAndTimeToRun()
- {
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array(
- Piwik_Common::prefixTable('log_conversion') => 6,
- Piwik_Common::prefixTable('log_link_visit_action') => 6,
- Piwik_Common::prefixTable('log_visit') => 3,
- Piwik_Common::prefixTable('log_conversion_item') => 3,
- Piwik_Common::prefixTable('archive_numeric_2012_01') => -1,
- Piwik_Common::prefixTable('archive_blob_2012_01') => -1
- );
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkLogDataPurged();
-
- $archiveTables = $this->getArchiveTableNames();
-
- // January numeric table should be dropped
- $this->assertFalse($this->tableExists($archiveTables['numeric'][0])); // January
-
- // Check february metric count (5 metrics per period w/ visits + 1 'done' archive for every period)
- // + 1 garbage metric
- $febRowCount = self::FEB_METRIC_ARCHIVE_COUNT * 5 + self::TOTAL_FEB_ARCHIVE_COUNT + 1;
- $this->assertEqual($febRowCount, $this->getTableCount($archiveTables['numeric'][1])); // February
-
- // January blob table should be dropped
- $this->assertFalse($this->tableExists($archiveTables['blob'][0])); // January
-
- // Check february blob count (1 blob per period w/ visits + 1 garbage report)
- $this->assertEqual(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->getTableCount($archiveTables['blob'][1])); // February
- }
-
- /** Make sure nothing happens when deleting logs & reports are both disabled. */
- public function test_purgeData_bothDisabled()
- {
- Piwik_PrivacyManager::savePurgeDataSettings(array(
- 'delete_logs_enable' => 0,
- 'delete_reports_enable' => 0
- ));
-
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array();
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkNoDataChanges();
- }
-
- /** Test that purgeData works when there's no data. */
- public function test_purgeData_deleteLogsNoData()
- {
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array();
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->assertEqual(0, $this->getTableCount('log_visit'));
- $this->assertEqual(0, $this->getTableCount('log_conversion'));
- $this->assertEqual(0, $this->getTableCount('log_link_visit_action'));
- $this->assertEqual(0, $this->getTableCount('log_conversion_item'));
-
- $archiveTables = $this->getArchiveTableNames();
- $this->assertFalse($this->tableExists($archiveTables['numeric'][0])); // January
- $this->assertFalse($this->tableExists($archiveTables['numeric'][1])); // February
- $this->assertFalse($this->tableExists($archiveTables['blob'][0])); // January
- $this->assertFalse($this->tableExists($archiveTables['blob'][1])); // February
- }
-
- /** Test that purgeData works correctly when the 'keep basic metrics' setting is set to true. */
- public function test_purgeData_deleteReportsKeepBasicMetrics()
- {
- Piwik_PrivacyManager::savePurgeDataSettings(array(
- 'delete_reports_keep_basic_metrics' => 1
- ));
-
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array(
- Piwik_Common::prefixTable('log_conversion') => 6,
- Piwik_Common::prefixTable('log_link_visit_action') => 6,
- Piwik_Common::prefixTable('log_visit') => 3,
- Piwik_Common::prefixTable('log_conversion_item') => 3,
- Piwik_Common::prefixTable('archive_numeric_2012_01') => 1, // remove the garbage metric
- Piwik_Common::prefixTable('archive_blob_2012_01') => -1
- );
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkLogDataPurged();
-
- $archiveTables = $this->getArchiveTableNames();
-
- // all numeric metrics should be saved except the garbage metric
- $janRowCount = $this->getExpectedNumericArchiveCountJan() - 1;
- $this->assertEqual($janRowCount, $this->getTableCount($archiveTables['numeric'][0])); // January
-
- // check february numerics not deleted
- $febRowCount = $this->getExpectedNumericArchiveCountFeb();
- $this->assertEqual($febRowCount, $this->getTableCount($archiveTables['numeric'][1])); // February
-
- // check that the january blob table was dropped
- $this->assertFalse($this->tableExists($archiveTables['blob'][0])); // January
-
- // check for no changes in the february blob table
- $this->assertEqual(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->getTableCount($archiveTables['blob'][1])); // February
- }
-
- /** Test that purgeData works correctly when the 'keep daily reports' setting is set to true. */
- public function test_purgeData_deleteReportsKeepDailyReports()
- {
- Piwik_PrivacyManager::savePurgeDataSettings(array(
- 'delete_reports_keep_day_reports' => 1
- ));
-
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array(
- Piwik_Common::prefixTable('log_conversion') => 6,
- Piwik_Common::prefixTable('log_link_visit_action') => 6,
- Piwik_Common::prefixTable('log_visit') => 3,
- Piwik_Common::prefixTable('log_conversion_item') => 3,
- Piwik_Common::prefixTable('archive_numeric_2012_01') => -1,
- Piwik_Common::prefixTable('archive_blob_2012_01') => 10 // removing 4 weeks, 1 month & 1 year + 1 garbage report + 2 range reports + 1 segmented report
- );
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkLogDataPurged();
- $this->checkReportsAndMetricsPurged($janBlobsRemaining = 5); // 5 blobs for 5 days
- }
-
- /** Test that purgeData works correctly when the 'keep weekly reports' setting is set to true. */
- public function test_purgeData_deleteReportsKeepWeeklyReports()
- {
- Piwik_PrivacyManager::savePurgeDataSettings(array(
- 'delete_reports_keep_week_reports' => 1
- ));
-
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array(
- Piwik_Common::prefixTable('log_conversion') => 6,
- Piwik_Common::prefixTable('log_link_visit_action') => 6,
- Piwik_Common::prefixTable('log_visit') => 3,
- Piwik_Common::prefixTable('log_conversion_item') => 3,
- Piwik_Common::prefixTable('archive_numeric_2012_01') => -1,
- Piwik_Common::prefixTable('archive_blob_2012_01') => 11 // 5 days, 1 month & 1 year to remove + 1 garbage report + 2 range reports + 1 segmented report
- );
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkLogDataPurged();
- $this->checkReportsAndMetricsPurged($janBlobsRemaining = 4); // 4 blobs for 4 weeks
- }
-
- /** Test that purgeData works correctly when the 'keep monthly reports' setting is set to true. */
- public function test_purgeData_deleteReportsKeepMonthlyReports()
- {
- Piwik_PrivacyManager::savePurgeDataSettings(array(
- 'delete_reports_keep_month_reports' => 1
- ));
-
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array(
- Piwik_Common::prefixTable('log_conversion') => 6,
- Piwik_Common::prefixTable('log_link_visit_action') => 6,
- Piwik_Common::prefixTable('log_visit') => 3,
- Piwik_Common::prefixTable('log_conversion_item') => 3,
- Piwik_Common::prefixTable('archive_numeric_2012_01') => -1,
- Piwik_Common::prefixTable('archive_blob_2012_01') => 14 // 5 days, 4 weeks, 1 year to remove + 1 garbage report + 2 range reports + 1 segmented report
- );
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkLogDataPurged();
- $this->checkReportsAndMetricsPurged($janBlobsRemaining = 1); // 1 blob for 1 month
- }
-
- /** Test that purgeData works correctly when the 'keep yearly reports' setting is set to true. */
- public function test_purgeData_deleteReportsKeepYearlyReports()
- {
- Piwik_PrivacyManager::savePurgeDataSettings(array(
- 'delete_reports_keep_year_reports' => 1
- ));
-
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array(
- Piwik_Common::prefixTable('log_conversion') => 6,
- Piwik_Common::prefixTable('log_link_visit_action') => 6,
- Piwik_Common::prefixTable('log_visit') => 3,
- Piwik_Common::prefixTable('log_conversion_item') => 3,
- Piwik_Common::prefixTable('archive_numeric_2012_01') => -1,
- Piwik_Common::prefixTable('archive_blob_2012_01') => 14 // 5 days, 4 weeks & 1 year to remove + 1 garbage report + 2 range reports + 1 segmented report
- );
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkLogDataPurged();
- $this->checkReportsAndMetricsPurged($janBlobsRemaining = 1); // 1 blob for 1 year
- }
-
- /** Test no concurrency issues when deleting log data from log_action table. */
- public function test_purgeLogData_concurrency()
- {
- Piwik_AddAction("LogDataPurger.actionsToKeepInserted.olderThan", array($this, 'addReferenceToUnusedAction'));
-
- $this->addLogData();
-
- $purger = Piwik_PrivacyManager_LogDataPurger::make($this->settings, true);
-
- $this->unusedIdAction = Piwik_FetchOne(
- "SELECT idaction FROM ".Piwik_Common::prefixTable('log_action')." WHERE name = ?",
- array('whatever.com/_40'));
- $this->assertTrue($this->unusedIdAction);
-
- // purge data
- $purger->purgeData();
-
- // check that actions were purged
- $this->assertEqual(22, $this->getTableCount('log_action')); // January
-
- // check that the unused action still exists
- $count = Piwik_FetchOne(
- "SELECT COUNT(*) FROM ".Piwik_Common::prefixTable('log_action')." WHERE idaction = ?",
- array($this->unusedIdAction));
- $this->assertEqual(1, $count);
-
- $this->unusedIdAction = null; // so the hook won't get executed twice
- }
-
- /** Tests that purgeData works correctly when the 'keep range reports' setting is set to true. */
- public function test_purgeData_deleteReportsKeepRangeReports()
- {
- Piwik_PrivacyManager::savePurgeDataSettings(array(
- 'delete_reports_keep_range_reports' => 1
- ));
-
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array(
- Piwik_Common::prefixTable('log_conversion') => 6,
- Piwik_Common::prefixTable('log_link_visit_action') => 6,
- Piwik_Common::prefixTable('log_visit') => 3,
- Piwik_Common::prefixTable('log_conversion_item') => 3,
- Piwik_Common::prefixTable('archive_numeric_2012_01') => -1,
- Piwik_Common::prefixTable('archive_blob_2012_01') => 13 // 5 days, 4 weeks, 1 month & 1 year + 1 garbage report + 1 segmented report
- );
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkLogDataPurged();
- $this->checkReportsAndMetricsPurged($janBlobsRemaining = 2); // 2 range blobs
- }
-
- /** Tests that purgeData works correctly when the 'keep segment reports' setting is set to true. */
- public function test_purgeData_deleteReportsKeepSegmentsReports()
- {
- Piwik_PrivacyManager::savePurgeDataSettings(array(
- 'delete_reports_keep_day_reports' => 1,
- 'delete_reports_keep_segment_reports' => 1
- ));
-
- $this->addLogData();
- $this->addReportData();
-
- // get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
-
- // perform checks on prediction
- $expectedPrediction = array(
- Piwik_Common::prefixTable('log_conversion') => 6,
- Piwik_Common::prefixTable('log_link_visit_action') => 6,
- Piwik_Common::prefixTable('log_visit') => 3,
- Piwik_Common::prefixTable('log_conversion_item') => 3,
- Piwik_Common::prefixTable('archive_numeric_2012_01') => -1,
- Piwik_Common::prefixTable('archive_blob_2012_01') => 9 // 4 weeks, 1 month & 1 year + 1 garbage report + 2 range reports
- );
- $this->assertEqual($expectedPrediction, $prediction);
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
- $this->instance->deleteReportData();
-
- // perform checks
- $this->checkLogDataPurged();
- $this->checkReportsAndMetricsPurged($janBlobsRemaining = 6); // 1 segmented blob + 5 day blobs
- }
-
- /** Tests that log actions are not purged when the lock privilege is not granted.
- * (Simulates absence of lock privilege.)
- */
- public function test_purgeData_deleteLogsWithoutLockPrivilege()
- {
- Piwik::$lockPrivilegeGranted = false;
-
- $this->addLogData();
-
- // purge data
- $this->setTimeToRun();
- $this->instance->deleteLogData();
-
- // perform checks
- $this->checkLogDataPurged($actionsPurged = false);
- }
-
- // --- utility functions follow ---
-
- private function addLogData()
- {
- // tracks visits on the following days:
- // - 2012-01-09
- // - 2012-01-14
- // - 2012-01-19
- // - 2012-01-24 <--- everything before this date is to be purged
- // - 2012-01-29
- // - 2012-02-03
- // - 2012-02-08
- // - 2012-02-13
- // - 2012-02-18
- // - 2012-02-23
- // - 2012-02-28
- // 6 visits in feb, 5 in jan
-
- // following actions are created:
- // - 'First page view'
- // - 'Second page view'
- // - 'SKU2'
- // - 'Canon SLR'
- // - 'Electronics & Cameras'
- // - for every visit (11 visits total):
- // - http://whatever.com/_{$daysSinceLastVisit}
- // - http://whatever.com/42/{$daysSinceLastVisit}
-
- $start = $this->dateTime;
- $this->idSite = $this->createWebsite('2012-01-01', $ecommerce=1);
- $idGoal = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'match all', 'url', 'http', 'contains');
-
- for ($daysAgo = $this->daysAgoStart; $daysAgo >= 0; $daysAgo -= 5) // one visit every 5 days
- {
- $dateTime = $start->subDay($daysAgo)->toString();
- $t = $this->getTracker($this->idSite, $dateTime, $defaultInit = true);
- $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)');
-
- // use $daysAgo to make sure new actions are created for every day and aren't used again.
- // when deleting visits, some of these actions will no longer be referenced in the DB.
- $t->setUrl("http://whatever.com/_$daysAgo");
- $t->doTrackPageView('First page view');
-
- $t->setUrl("http://whatever.com/42/$daysAgo");
- $t->doTrackPageView('Second page view');
-
- $t->addEcommerceItem($sku = 'SKU2', $name = 'Canon SLR' , $category = 'Electronics & Cameras',
- $price = 1500, $quantity = 1);
- $t->doTrackEcommerceOrder($orderId = '937nsjusu '.$dateTime, $grandTotal = 1111.11, $subTotal = 1000,
- $tax = 111, $shipping = 0.11, $discount = 666);
- }
- }
-
- private function addReportData()
- {
- $archive = Piwik_Archive::build($this->idSite, 'year', $this->dateTime);
- $archive->getNumeric('nb_visits', 'nb_hits');
-
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration(
- $this->idSite, 'year', $this->dateTime);
-
- // months are added via the 'year' period, but weeks must be done manually
- for ($daysAgo = $this->daysAgoStart; $daysAgo > 0; $daysAgo -= 7) // every week
- {
- $dateTime = $this->dateTime->subDay($daysAgo);
-
- $archive = Piwik_Archive::build($this->idSite, 'week', $dateTime);
- $archive->getNumeric('nb_visits');
-
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration(
- $this->idSite, 'week', $dateTime);
- }
-
- // add segment for one day
- $archive = Piwik_Archive::build($this->idSite, 'day', '2012-01-14', 'browserName==FF');
- $archive->getNumeric('nb_visits', 'nb_hits');
-
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration(
- $this->idSite, 'day', '2012-01-14', 'browserName==FF');
-
- // add range within January
- $rangeEnd = Piwik_Date::factory('2012-01-29');
- $rangeStart = $rangeEnd->subDay(1);
- $range = $rangeStart->toString('Y-m-d').",".$rangeEnd->toString('Y-m-d');
-
- $rangeArchive = Piwik_Archive::build($this->idSite, 'range', $range);
- $rangeArchive->getNumeric('nb_visits', 'nb_hits');
-
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration($this->idSite, 'range', $range);
-
- // add range between January & February
- $rangeStart = $rangeEnd;
- $rangeEnd = $rangeStart->addDay(3);
- $range = $rangeStart->toString('Y-m-d').",".$rangeEnd->toString('Y-m-d');
-
- $rangeArchive = Piwik_Archive::build($this->idSite, 'range', $range);
- $rangeArchive->getNumeric('nb_visits', 'nb_hits');
-
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration($this->idSite, 'range', $range);
-
- // when archiving is initiated, the archive metrics & reports for EVERY loaded plugin
- // are archived. don't want this test to depend on every possible metric, so get rid of
- // the unwanted archive data now.
- $metricsToSave = array(
- 'nb_visits',
- 'nb_actions',
- Piwik_Goals::getRecordName('revenue'),
- Piwik_Goals::getRecordName('nb_conversions', 1),
- Piwik_Goals::getRecordName('revenue', Piwik_Tracker_GoalManager::IDGOAL_ORDER)
- );
-
- $archiveTables = $this->getArchiveTableNames();
- foreach ($archiveTables['numeric'] as $table)
- {
- $realTable = Piwik_Common::prefixTable($table);
- Piwik_Query("DELETE FROM $realTable WHERE name NOT IN ('".implode("','", $metricsToSave)."') AND name NOT LIKE 'done%'");
- }
- foreach ($archiveTables['blob'] as $table)
- {
- $realTable = Piwik_Common::prefixTable($table);
- Piwik_Query("DELETE FROM $realTable WHERE name NOT IN ('VisitorInterest_timeGap')");
- }
-
- // add garbage metrics
- $janDate1 = '2012-01-05';
- $febDate1 = '2012-02-04';
-
- $sql = "INSERT INTO %s (idarchive,name,idsite,date1,date2,period,ts_archived,value)
- VALUES (10000,?,1,?,?,?,?,?)";
-
- // one metric for jan & one for feb
- Piwik_Query(sprintf($sql, Piwik_Common::prefixTable($archiveTables['numeric'][0])),
- array(self::GARBAGE_FIELD, $janDate1, $janDate1, $janDate1, 1, 100));
- Piwik_Query(sprintf($sql, Piwik_Common::prefixTable($archiveTables['numeric'][1])),
- array(self::GARBAGE_FIELD, $febDate1, $febDate1, $febDate1, 1, 200));
-
- // add garbage reports
- Piwik_Query(sprintf($sql, Piwik_Common::prefixTable($archiveTables['blob'][0])),
- array(self::GARBAGE_FIELD, $janDate1, $janDate1, $janDate1, 10, 'blobval'));
- Piwik_Query(sprintf($sql, Piwik_Common::prefixTable($archiveTables['blob'][1])),
- array(self::GARBAGE_FIELD, $febDate1, $febDate1, $febDate1, 20, 'blobval'));
- }
-
- private function checkNoDataChanges()
- {
- // 11 visits total w/ 2 actions per visit & 2 conversions per visit. 1 e-commerce order per visit.
- $this->assertEqual(11, $this->getTableCount('log_visit'));
- $this->assertEqual(22, $this->getTableCount('log_conversion'));
- $this->assertEqual(22, $this->getTableCount('log_link_visit_action'));
- $this->assertEqual(11, $this->getTableCount('log_conversion_item'));
- $this->assertEqual(27, $this->getTableCount('log_action'));
-
- $archiveTables = $this->getArchiveTableNames();
-
- $janMetricCount = $this->getExpectedNumericArchiveCountJan();
- $this->assertEqual($janMetricCount, $this->getTableCount($archiveTables['numeric'][0])); // January
-
- // no range metric for february
- $febMetricCount = $this->getExpectedNumericArchiveCountFeb();
- $this->assertEqual($febMetricCount, $this->getTableCount($archiveTables['numeric'][1])); // February
-
- // 1 entry per period w/ visits + 1 garbage report + 2 range reports + 1 segment report
- $this->assertEqual(self::JAN_METRIC_ARCHIVE_COUNT + 1 + 2 + 1, $this->getTableCount($archiveTables['blob'][0])); // January
- $this->assertEqual(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->getTableCount($archiveTables['blob'][1])); // February
- }
-
- /**
- * Helper method. Performs checks after reports are purged. Checks that the january numeric table
- * was dropped, that the february metric & blob tables are unaffected, and that the january blob
- * table has a certain number of blobs.
- */
- private function checkReportsAndMetricsPurged( $janBlobsRemaining )
- {
- $archiveTables = $this->getArchiveTableNames();
-
- // check that the january numeric table was dropped
- $this->assertFalse($this->tableExists($archiveTables['numeric'][0])); // January
-
- // check february numerics not deleted
- $febRowCount = $this->getExpectedNumericArchiveCountFeb();
- $this->assertEqual($febRowCount, $this->getTableCount($archiveTables['numeric'][1])); // February
-
- // check the january blob count
- $this->assertEqual($janBlobsRemaining, $this->getTableCount($archiveTables['blob'][0])); // January
-
- // check for no changes in the february blob table (1 blob for every period w/ visits in feb + 1 garbage report)
- $this->assertEqual(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->getTableCount($archiveTables['blob'][1])); // February
- }
-
- private function checkLogDataPurged( $actionsPurged = true )
- {
- // 3 days removed by purge, so 3 visits, 6 conversions, 6 visit actions, 3 e-commerce orders
- // & 6 actions removed
- $this->assertEqual(8, $this->getTableCount('log_visit'));
- $this->assertEqual(16, $this->getTableCount('log_conversion'));
- $this->assertEqual(16, $this->getTableCount('log_link_visit_action'));
- $this->assertEqual(8, $this->getTableCount('log_conversion_item'));
- if ($actionsPurged)
- {
- $this->assertEqual(21, $this->getTableCount('log_action'));
- }
- else
- {
- $this->assertEqual(27, $this->getTableCount('log_action'));
- }
- }
-
- /**
- * Event hook that adds a row into the DB that references unused idaction AFTER LogDataPurger
- * does the insert into the temporary table. When log_actions are deleted, this idaction should still
- * be kept. w/ the wrong strategy, it won't be and there will be a dangling reference
- * in the log_link_visit_action table.
- *
- * @param Piwik_Event_Notification $notification notification object
- */
- public function addReferenceToUnusedAction( $notification )
- {
- $unusedIdAction = $this->unusedIdAction;
- if (empty($unusedIdAction)) // make sure we only do this for one test case
- {
- return;
- }
-
- $tempTableName = Piwik_Common::prefixTable(Piwik_PrivacyManager_LogDataPurger::TEMP_TABLE_NAME);
- $logLinkVisitActionTable = Piwik_Common::prefixTable("log_link_visit_action");
-
- $sql = "INSERT INTO $logLinkVisitActionTable
- (idsite, idvisitor, server_time, idvisit, idaction_url, idaction_url_ref,
- idaction_name, idaction_name_ref, time_spent_ref_action)
- VALUES (1, 'abc', NOW(), 15, $unusedIdAction, $unusedIdAction,
- $unusedIdAction, $unusedIdAction, 1000)";
-
- Piwik_Query($sql);
- }
-
- private function setTimeToRun()
- {
- $lastDateSecs = Piwik_Date::factory('today')->subDay(8)->getTimestamp();
-
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDateSecs);
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $lastDateSecs);
- }
-
- private function getTableCount( $tableName, $where = '' )
- {
- $sql = "SELECT COUNT(*) FROM ".Piwik_Common::prefixTable($tableName)." $where";
- return Piwik_FetchOne($sql);
- }
-
- private function tableExists( $tableName )
- {
- $dbName = Piwik_Config::getInstance()->database['dbname'];
-
- $sql = "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = ? AND table_name = ?";
- return Piwik_FetchOne($sql, array($dbName, Piwik_Common::prefixTable($tableName))) == 1;
- }
-
- private function getArchiveTableNames()
- {
- return array(
- 'numeric' => array(
- 'archive_numeric_2012_01',
- 'archive_numeric_2012_02'
- ),
- 'blob' => array(
- 'archive_blob_2012_01',
- 'archive_blob_2012_02'
- )
- );
- }
-
- private function getExpectedNumericArchiveCountJan()
- {
- // 5 entries per period w/ visits
- // + 1 entry for every period in the month (the 'done' rows)
- // + 1 garbage metric
- // + 2 entries per range period (4 total) + 2 'done...' entries per range period (4 total)
- // + 2 entries per segment (2 total) + 2 'done...' entries per segment (2 total)
- return self::JAN_METRIC_ARCHIVE_COUNT * 5 + self::TOTAL_JAN_ARCHIVE_COUNT + 1 + 8 + 4;
- }
-
- private function getExpectedNumericArchiveCountFeb()
- {
- // (5 metrics per period w/ visits
- // + 1 'done' archive for every period)
- // + 1 garbage metric
- return self::FEB_METRIC_ARCHIVE_COUNT * 5 + self::TOTAL_FEB_ARCHIVE_COUNT + 1;
- }
-
- /** Irrelevant. Just needs to be defined. */
- public function getPathToTestDirectory()
- {
- return PIWIK_INCLUDE_PATH . '/tests/integration';
- }
-}
-
diff --git a/plugins/Proxy/tests/Proxy.test.php b/plugins/Proxy/tests/Proxy.test.php
deleted file mode 100644
index d84e15a4d0..0000000000
--- a/plugins/Proxy/tests/Proxy.test.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-class Test_Piwik_Proxy extends UnitTestCase
-{
- public function test_isAcceptableRemoteUrl()
- {
- Piwik::createConfigObject();
- Piwik_Config::getInstance()->setTestEnvironment();
-
- $data = array(
- // piwik white list (and used in homepage)
- 'http://piwik.org/' => array(true),
-
- 'http://piwik.org' => array(true),
- 'http://qa.piwik.org/' => array(true),
- 'http://forum.piwik.org/' => array(true),
- 'http://dev.piwik.org/' => array(true),
- 'http://demo.piwik.org/' => array(true),
-
- // not in the piwik white list
- 'http://www.piwik.org/' => array(false),
- 'https://piwik.org/' => array(false),
- 'http://example.org/' => array(false),
- );
-
- foreach($data as $url => $expected)
- {
- $this->assertEqual(Piwik_Proxy_Controller::isPiwikUrl($url), $expected[0], $url);
- }
- }
-}
-
diff --git a/plugins/Referers/tests/Referers.test.php b/plugins/Referers/tests/Referers.test.php
deleted file mode 100644
index e76d59e72c..0000000000
--- a/plugins/Referers/tests/Referers.test.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-require_once dirname(__FILE__).'/../Referers.php';
-require_once dirname(__FILE__).'/../functions.php';
-
-class Test_Referers extends UnitTestCase
-{
- function __construct( $title = '')
- {
- parent::__construct( $title );
- }
-
- // search engine has at least one keyword
- function test_missingSearchEngineKeyword()
- {
- require_once PIWIK_PATH_TEST_TO_ROOT . '/core/DataFiles/SearchEngines.php';
-
- // Get list of search engines and first appearing URL
- $searchEngines = array();
- foreach($GLOBALS['Piwik_SearchEngines'] as $url => $searchEngine)
- {
- $name = parse_url('http://'.$url);
- if(!array_key_exists($searchEngine[0], $searchEngines))
- {
- $searchEngines[$searchEngine[0]] = $url;
-
- $this->assertTrue(!empty($searchEngine[1]), $name['host']);
- }
- }
- }
-
- // search engine is defined in DataFiles/SearchEngines.php but there's no favicon
- function test_missingSearchEngineIcons()
- {
- require_once PIWIK_PATH_TEST_TO_ROOT . '/core/DataFiles/SearchEngines.php';
-
- // Get list of existing favicons
- $favicons = scandir(PIWIK_PATH_TEST_TO_ROOT . '/plugins/Referers/images/searchEngines/');
-
- // Get list of search engines and first appearing URL
- $searchEngines = array();
- foreach($GLOBALS['Piwik_SearchEngines'] as $url => $searchEngine)
- {
- $name = parse_url('http://'.$url);
- if(!array_key_exists($searchEngine[0], $searchEngines))
- {
- $searchEngines[$searchEngine[0]] = $url;
-
- $this->assertTrue(in_array($name['host'] . '.png', $favicons), $name['host']);
- }
- }
- }
-
- // favicon exists but there's no corresponding search engine defined in DataFiles/SearchEngines.php
- function test_obsoleteSearchEngineIcons()
- {
- require_once PIWIK_PATH_TEST_TO_ROOT . '/core/DataFiles/SearchEngines.php';
-
- // Get list of search engines and first appearing URL
- $searchEngines = array();
- foreach($GLOBALS['Piwik_SearchEngines'] as $url => $searchEngine)
- {
- $name = parse_url('http://'.$url);
- if(!array_key_exists($name['host'], $searchEngines))
- {
- $searchEngines[$name['host']] = true;
- }
- }
-
- // Get list of existing favicons
- $favicons = scandir(PIWIK_PATH_TEST_TO_ROOT . '/plugins/Referers/images/searchEngines/');
- foreach($favicons as $name)
- {
- if($name[0] == '.' || strpos($name, 'xx.') === 0)
- {
- continue;
- }
-
- $host = substr($name, 0, -4);
- $this->assertTrue(array_key_exists($host, $searchEngines), $host);
- }
- }
-
- // get search engine host from url
- function test_getSearchEngineHostFromUrl()
- {
- $data = array(
- 'http://www.google.com/cse' => array('www.google.com', 'www.google.com/cse'),
- 'http://www.google.com' => array('www.google.com', 'www.google.com'),
- );
-
- foreach($data as $url => $expected)
- {
- $this->assertEqual(Piwik_getSearchEngineHostFromUrl($url), $expected[0], $url);
- $this->assertEqual(Piwik_getSearchEngineHostPathFromUrl($url), $expected[1], $url);
- }
- }
-
- // get search engine url from name and keyword
- function test_getSearchEngineUrlFromUrlAndKeyword()
- {
- $data = array(
- array('http://apollo.lv/portal/search/', 'piwik', 'http://apollo.lv/portal/search/?cof=FORID%3A11&q=piwik&search_where=www'),
- array('http://bing.com/images/search', 'piwik', 'http://bing.com/images/search/?q=piwik'),
- array('http://google.com', 'piwik', 'http://google.com/search?q=piwik'),
- );
-
- foreach($data as $item)
- {
- $url = array_shift($item);
- $keyword = array_shift($item);
- $expected = array_shift($item);
- $this->assertEqual(Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword), $expected, "$url $keyword");
- }
- }
-}
diff --git a/plugins/SEO/tests/SEO.test.php b/plugins/SEO/tests/SEO.test.php
deleted file mode 100644
index 4cbafb9990..0000000000
--- a/plugins/SEO/tests/SEO.test.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-Mock::generate('Piwik_Access');
-
-class Test_SEO extends UnitTestCase
-{
- function setUp()
- {
- parent::setUp();
-
- $pseudoMockAccess = new MockPiwik_Access();
- $pseudoMockAccess->setReturnValue('isSuperUser', true);
- Zend_Registry::set('access', $pseudoMockAccess);
-
- Piwik::createConfigObject();
-
- $user_agents = array(
- 'Mozilla/6.0 (Macintosh; I; Intel Mac OS X 11_7_9; de-LI; rv:1.9b4) Gecko/2012010317 Firefox/10.0a4',
- 'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0',
- 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/18.6.872.0 Safari/535.2 UNTRUSTED/1.0 3gpp-gba UNTRUSTED/1.0',
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1',
- );
-
- $_SERVER['HTTP_USER_AGENT'] = $user_agents[mt_rand(0, count($user_agents) - 1)];
- }
-
- // tell us when the API is broken
- function test_API()
- {
- $dataTable = Piwik_SEO_API::getInstance()->getRank('http://forum.piwik.org/');
- $renderer = Piwik_DataTable_Renderer::factory('php');
- $renderer->setSerialize(false);
- $ranks = $renderer->render($dataTable);
- foreach ($ranks as $rank)
- {
- $this->assertTrue(!empty($rank['rank']), $rank['id'] . ' expected non-zero rank, got [' . $rank['rank'] . ']');
- }
- }
-}
diff --git a/plugins/SitesManager/tests/SitesManager.test.php b/plugins/SitesManager/tests/SitesManager.test.php
deleted file mode 100644
index d5686dad69..0000000000
--- a/plugins/SitesManager/tests/SitesManager.test.php
+++ /dev/null
@@ -1,930 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-require_once PIWIK_PATH_TEST_TO_ROOT . '/tests/core/Database.test.php';
-
-class Test_Piwik_SitesManager extends Test_Database
-{
- public function __construct()
- {
- // ExampleFeedburner modifies the 'site' table which would change the results of queries (vs expected)
- Piwik_PluginsManager::getInstance()->unloadPlugin('ExampleFeedburner');
-
- parent::__construct();
- }
-
- public function setUp()
- {
- parent::setUp();
-
- // setup the access layer
- $pseudoMockAccess = new FakeAccess;
- FakeAccess::$superUser = true;
- Zend_Registry::set('access', $pseudoMockAccess);
- }
-
- /**
- * empty name -> exception
- */
- public function test_addSite_emptyName()
- {
- try {
- Piwik_SitesManager_API::getInstance()->addSite("",array("http://piwik.net"));
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * no urls -> exception
- */
- public function test_addSite_noUrls()
- {
- try {
- Piwik_SitesManager_API::getInstance()->addSite("name",array());
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong urls -> exception
- */
- public function test_addSite_wrongUrls1()
- {
- try {
- Piwik_SitesManager_API::getInstance()->addSite("name",array(""));
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
- /**
- * wrong urls -> exception
- */
- public function test_addSite_wrongUrls2()
- {
- try {
- Piwik_SitesManager_API::getInstance()->addSite("name","");
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong urls -> exception
- */
- public function test_addSite_wrongUrls3()
- {
- try {
- Piwik_SitesManager_API::getInstance()->addSite("name","httpww://piwik.net");
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong urls -> exception
- */
- public function test_addSite_wrongUrls4()
- {
- try {
- Piwik_SitesManager_API::getInstance()->addSite("name","httpww://piwik.net/gqg~#");
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * Test with valid IPs
- */
- public function test_addSite_excludedIpsAndtimezoneAndCurrencyAndExcludedQueryParameters_valid()
- {
- $ips = '1.2.3.4,1.1.1.*,1.2.*.*,1.*.*.*';
- $timezone = 'Europe/Paris';
- $currency = 'EUR';
- $excludedQueryParameters = 'p1,P2, P33333';
- $expectedExcludedQueryParameters = 'p1,P2,P33333';
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name","http://piwik.net/", $ecommerce = 1, $ips, $excludedQueryParameters,$timezone, $currency);
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
- $this->assertEqual($siteInfo['excluded_ips'], $ips);
- $this->assertEqual($siteInfo['timezone'], $timezone);
- $this->assertEqual($siteInfo['currency'], $currency);
- $this->assertEqual($siteInfo['ecommerce'], $ecommerce);
- $this->assertEqual($siteInfo['excluded_parameters'], $expectedExcludedQueryParameters);
- }
-
- /**
- * Test with invalid IPs
- */
- public function test_addSite_excludedIps_notValid()
- {
- $invalidIps = array(
- '35817587341',
- 'ieagieha',
- '1.2.3',
- '*.1.1.1',
- '*.*.1.1',
- '*.*.*.1',
- '1.1.1.1.1',
- );
- foreach($invalidIps as $ip)
- {
- $raised = false;
- try {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name","http://piwik.net/", $ecommerce = 0,$ip);
- } catch(Exception $e) {
- $raised = true;
- }
- if(!$raised)
- {
- $this->fail('was expecting invalid IP exception to raise');
- }
- }
- $this->pass();
- }
-
- /**
- * one url -> one main_url and nothing inserted as alias urls
- */
- public function test_addSite_oneUrl()
- {
- $url = "http://piwik.net/";
- $urlOK = "http://piwik.net";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name",$url);
- $this->assertIsA( $idsite,'int');
-
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
- $this->assertEqual($siteInfo['main_url'], $urlOK);
- $this->assertEqual(date('Y-m-d', strtotime($siteInfo['ts_created'])), date('Y-m-d'));
-
- $siteUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
- $this->assertTrue(count($siteUrls)===1);
- }
-
- /**
- * several urls -> one main_url and others as alias urls
- */
- public function test_addSite_severalUrls()
- {
- $urls = array("http://piwik.net/","http://piwik.com","https://piwik.net/test/");
- $urlsOK = array("http://piwik.net","http://piwik.com","https://piwik.net/test");
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("super website",$urls);
- $this->assertIsA( $idsite,'int');
-
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
- $this->assertEqual($siteInfo['main_url'], $urlsOK[0]);
-
- $siteUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
- $this->assertEqual($siteUrls, $urlsOK);
- }
-
- /**
- * strange name
- */
- public function test_addSite_strangeName()
- {
- $name = "supertest(); ~@@()''!£\$'%%^'!£ போ";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite($name,"http://piwik.net");
- $this->assertIsA( $idsite,'int');
-
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
- $this->assertEqual($siteInfo['name'], $name);
-
- }
- /**
- * normal case
- */
- public function test_addSite()
- {
- $name = "website ";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite($name,array("http://piwik.net","http://piwik.com/test/"));
- $this->assertIsA( $idsite,'int');
-
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
- $this->assertEqual($siteInfo['name'], $name);
- $this->assertEqual($siteInfo['main_url'], "http://piwik.net");
-
- $siteUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
- $this->assertEqual($siteUrls, array("http://piwik.net","http://piwik.com/test"));
-
- return $idsite;
- }
-
- /**
- * no duplicate -> all the urls are saved
- */
- public function test_addSiteUrls_noDuplicate()
- {
- $idsite = $this->test_addSite();
-
- $siteUrlsBefore = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
- $toAdd = array( "http://piwik1.net",
- "http://piwik2.net",
- "http://piwik3.net/test/",
- "http://localhost/test",
- "http://localho5.st/test",
- "http://l42578gqege.f4",
- "http://super.com/test/test/atqata675675/te"
- );
- $toAddValid = array("http://piwik1.net",
- "http://piwik2.net",
- "http://piwik3.net/test",
- "http://localhost/test",
- "http://localho5.st/test",
- "http://l42578gqege.f4",
- "http://super.com/test/test/atqata675675/te");
-
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
- $this->assertEqual($insertedUrls, count($toAdd));
-
- $siteUrlsAfter = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
- $shouldHave = array_merge($siteUrlsBefore, $toAddValid);
- sort($shouldHave);
-
- sort($siteUrlsAfter);
-
- $this->assertEqual($shouldHave, $siteUrlsAfter);
- }
-
- /**
- * duplicate -> don't save the already existing URLs
- */
- public function test_addSiteUrls_duplicate()
- {
- $idsite = $this->test_addSite();
-
- $siteUrlsBefore = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
- $toAdd = array_merge($siteUrlsBefore, array("http://piwik1.net","http://piwik2.net"));
-
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
- $this->assertEqual($insertedUrls, count($toAdd) - count($siteUrlsBefore));
-
- $siteUrlsAfter = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
- $shouldHave = $toAdd;
- sort($shouldHave);
-
- sort($siteUrlsAfter);
-
- $this->assertEqual($shouldHave, $siteUrlsAfter);
- }
-
- /**
- * case empty array => nothing happens
- */
- public function test_addSiteUrls_noUrlsToAdd1()
- {
- $idsite = $this->test_addSite();
-
- $siteUrlsBefore = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
- $toAdd = array();
-
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
- $this->assertEqual($insertedUrls, count($toAdd));
-
- $siteUrlsAfter = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
- $shouldHave = $siteUrlsBefore;
- sort($shouldHave);
-
- sort($siteUrlsAfter);
-
- $this->assertEqual($shouldHave, $siteUrlsAfter);
- }
-
- /**
- * case array only duplicate => nothing happens
- */
- public function test_addSiteUrls_noUrlsToAdd2()
- {
- $idsite = $this->test_addSite();
-
- $siteUrlsBefore = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
- $toAdd = $siteUrlsBefore;
-
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
- $this->assertEqual($insertedUrls, 0);
-
- $siteUrlsAfter = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
- $shouldHave = $siteUrlsBefore;
- sort($shouldHave);
-
- sort($siteUrlsAfter);
-
- $this->assertEqual($shouldHave, $siteUrlsAfter);
- }
- /**
- * wrong format urls => exception
- */
- public function test_addSiteUrls_wrongUrlsFormat3()
- {
- $idsite = $this->test_addSite();
- $toAdd = array("http:mpigeq");
- try {
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong idsite => no exception because simply no access to this resource
- */
- public function test_addSiteUrls_wrongIdSite1()
- {
- $toAdd = array("http://pigeq.com/test");
- try {
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls(-1, $toAdd);
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong idsite => exception
- */
- public function test_addSiteUrls_wrongIdSite2()
- {
- $toAdd = array("http://pigeq.com/test");
-
- try {
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls(155, $toAdd);
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * no Id -> empty array
- */
- function test_getAllSitesId_noId()
- {
- $ids = Piwik_SitesManager_API::getInstance()->getAllSitesId();
- $this->assertEqual(array(),$ids);
- }
-
- /**
- * several Id -> normal array
- */
- function test_getAllSitesId_severalId()
- {
- $name="tetq";
- $idsites = array(
- Piwik_SitesManager_API::getInstance()->addSite($name,array("http://piwik.net","http://piwik.com/test/")),
- Piwik_SitesManager_API::getInstance()->addSite($name,array("http://piwik.net","http://piwik.com/test/")),
- Piwik_SitesManager_API::getInstance()->addSite($name,array("http://piwik.net","http://piwik.com/test/")),
- Piwik_SitesManager_API::getInstance()->addSite($name,array("http://piwik.net","http://piwik.com/test/")),
- Piwik_SitesManager_API::getInstance()->addSite($name,array("http://piwik.net","http://piwik.com/test/")),
- );
-
- $ids = Piwik_SitesManager_API::getInstance()->getAllSitesId();
- $this->assertEqual($idsites,$ids);
- }
-
- /**
- * wrong id => exception
- */
- function test_getSiteFromId_wrongId1()
- {
-
- try {
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId(0);
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
-
- }
- /**
- * wrong id => exception
- */
- function test_getSiteFromId_wrongId2()
- {
-
- try {
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId("x1");
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
-
- }
- /**
- * wrong id : no access => exception
- */
- function test_getSiteFromId_wrongId3()
- {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site",array("http://piwik.net","http://piwik.com/test/"));
- $this->assertEqual($idsite,1);
-
- // set noaccess to site 1
- FakeAccess::setIdSitesView (array(2));
- FakeAccess::setIdSitesAdmin (array());
-
- try {
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId(1);
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
-
- }
- /**
- * normal case
- */
- function test_getSiteFromId_normalId()
- {
- $name = "website ''";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite($name,array("http://piwik.net","http://piwik.com/test/"));
- $this->assertIsA( $idsite,'int');
-
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
- $this->assertEqual($siteInfo['name'], $name);
- $this->assertEqual($siteInfo['main_url'], "http://piwik.net");
- }
-
-
- /**
- * there is no admin site available -> array()
- */
- function test_getSitesWithAdminAccess_noResult()
- {
- FakeAccess::setIdSitesAdmin (array());
-
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
- $this->assertEqual($sites, array());
- }
-
-
- /**
- * normal case, admin and view and noaccess website => return only admin
- */
- function test_getSitesWithAdminAccess()
- {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array("http://piwik.net","http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2",array("http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org"));
-
- $resultWanted = array(
- 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net", "ecommerce" => 0, "excluded_ips" => "", 'excluded_parameters' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => ''),
- 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org", "ecommerce" => 0,"excluded_ips" => "", 'excluded_parameters' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => ''),
- );
-
- FakeAccess::setIdSitesAdmin (array(1,3));
-
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
-
- // we dont test the ts_created
- unset($sites[0]['ts_created']);
- unset($sites[1]['ts_created']);
- $this->assertEqual($sites, $resultWanted);
- }
-
- /**
- * there is no admin site available -> array()
- */
- function test_getSitesWithViewAccess_noResult()
- {
- FakeAccess::setIdSitesView (array());
- FakeAccess::setIdSitesAdmin (array());
-
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess();
- $this->assertEqual($sites, array());
- }
-
- /**
- * normal case, admin and view and noaccess website => return only admin
- */
- function test_getSitesWithViewAccess()
- {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array("http://piwik.net","http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2",array("http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org"));
-
- $resultWanted = array(
- 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net", "ecommerce" => 0,"excluded_ips" => "", 'excluded_parameters' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => ''),
- 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org", "ecommerce" => 0,"excluded_ips" => "", 'excluded_parameters' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => ''),
- );
-
- FakeAccess::setIdSitesView (array(1,3));
- FakeAccess::setIdSitesAdmin (array());
-
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess();
- // we dont test the ts_created
- unset($sites[0]['ts_created']);
- unset($sites[1]['ts_created']);
- $this->assertEqual($sites, $resultWanted);
- }
-
- /**
- * there is no admin site available -> array()
- */
- function test_getSitesWithAtLeastViewAccess_noResult()
- {
- FakeAccess::setIdSitesView (array());
- FakeAccess::setIdSitesAdmin (array());
-
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
- $this->assertEqual($sites, array());
- }
-
- /**
- * normal case, admin and view and noaccess website => return only admin
- */
- function test_getSitesWithAtLeastViewAccess()
- {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array("http://piwik.net","http://piwik.com/test/"), $ecommerce=1);
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2",array("http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org"));
-
- $resultWanted = array(
- 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net", "ecommerce" => 1,"excluded_ips" => "", 'excluded_parameters' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => ''),
- 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org", "ecommerce" => 0,"excluded_ips" => "", 'excluded_parameters' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => ''),
- );
-
- FakeAccess::setIdSitesView (array(1,3));
- FakeAccess::setIdSitesAdmin (array());
-
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
- // we dont test the ts_created
- unset($sites[0]['ts_created']);
- unset($sites[1]['ts_created']);
- $this->assertEqual($sites, $resultWanted);
- }
-
-
- /**
- * no urls for this site => array()
- */
- function test_getSiteUrlsFromId_noUrls()
- {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array("http://piwik.net"));
-
- $urls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
- $this->assertEqual(array("http://piwik.net"),$urls);
- }
-
- /**
- * normal case
- */
- function test_getSiteUrlsFromId_manyUrls()
- {
- $site = array("http://piwik.net",
- "http://piwik.org",
- "http://piwik.org",
- "http://piwik.com");
- sort($site);
-
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",$site);
-
-
- $siteWanted = array("http://piwik.net",
- "http://piwik.org",
- "http://piwik.com");
- sort($siteWanted);
- $urls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
-
-
- $this->assertEqual($siteWanted, $urls);
- }
-
- /**
- * wrongId => exception
- */
- function test_getSiteUrlsFromId_wrongId()
- {
- FakeAccess::setIdSitesView (array(3));
- FakeAccess::setIdSitesAdmin (array());
-
- try {
- Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId(1);
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * one url => no change to alias urls
- */
- function test_updateSite_oneUrl()
- {
- $urls = array("http://piwiknew.com",
- "http://piwiknew.net",
- "http://piwiknew.org",
- "http://piwiknew.fr");
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", $urls);
-
- $newMainUrl = "http://main.url";
-
- // Also test that the group was set to empty, and is searchable
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup('');
- $this->assertEqual(count($websites), 1);
-
- // the Update doesn't change the group field
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl );
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup('');
- $this->assertEqual(count($websites), 1);
-
- // Updating the group to something
- $group = 'something';
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl, $ecommerce = 0, $ips=null, $parametersExclude=null, $timezone=null, $currency=null, $group );
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($group);
- $this->assertEqual(count($websites), 1);
- $this->assertEqual(date('Y-m-d', strtotime($websites[0]['ts_created'])), date('Y-m-d'));
-
- // Updating the group to nothing
- $group = '';
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl, $ecommerce = 0, $ips=null, $parametersExclude=null, $timezone=null, $currency=null, $group, $startDate = '2010-01-01' );
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($group);
- $this->assertEqual(count($websites), 1);
- $this->assertEqual(date('Y-m-d', strtotime($websites[0]['ts_created'])), '2010-01-01');
-
- $allUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
- $this->assertEqual($allUrls[0], $newMainUrl);
- $aliasUrls = array_slice($allUrls,1);
- $this->assertEqual($aliasUrls,array());
- }
-
- /**
- * strange name and NO URL => name ok, main_url not updated
- */
- function test_updateSite_strangeNameNoUrl()
- {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1","http://main.url");
- $newName ="test toto@{'786'}";
-
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, $newName );
-
- $site = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
-
- $this->assertEqual($site['name'],$newName);
- // url didn't change because parameter url NULL in updateSite
- $this->assertEqual($site['main_url'],"http://main.url");
-
- $this->assertEqual(count(null),0);
-
- }
-
- /**
- * several urls => both main and alias are updated
- * also test the update of group field
- */
- function test_updateSite_severalUrls_andGroup()
- {
- $urls = array("http://piwiknew.com",
- "http://piwiknew.net",
- "http://piwiknew.org",
- "http://piwiknew.fr");
-
- $group = 'GROUP Before';
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",$urls, $ecommerce =1,$excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $group, $startDate = '2011-01-01');
-
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($group);
- $this->assertEqual(count($websites), 1);
-
- $newurls = array("http://piwiknew2.com",
- "http://piwiknew2.net",
- "http://piwiknew2.org",
- "http://piwiknew2.fr");
-
- $groupAfter = ' GROUP After';
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, "test toto@{}",$newurls, $ecommerce = 0, $excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $groupAfter);
-
- // no result for the group before update
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($group);
- $this->assertEqual(count($websites), 0);
-
- // Testing that the group was updated properly (and testing that the group value is trimmed before inserted/searched)
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($groupAfter . ' ');
- $this->assertEqual(count($websites), 1);
- $this->assertEqual(date('Y-m-d', strtotime($websites[0]['ts_created'])), '2011-01-01');
-
- // Test fetch website groups
- $expectedGroups = array(trim($groupAfter));
- $fetched = Piwik_SitesManager_API::getInstance()->getSitesGroups();
- $this->assertEqual($expectedGroups, $fetched);
-
- $allUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
- sort($allUrls);
- sort($newurls);
- $this->assertEqual($allUrls,$newurls);
-
- }
-
- function test_getSitesGroups()
- {
- $groups = array( 'group1', ' group1 ', '', 'group2');
- $expectedGroups = array('group1','','group2');
- foreach($groups as $group)
- {
- Piwik_SitesManager_API::getInstance()->addSite("test toto@{}", 'http://example.org',$ecommerce=1,$excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $group);
- }
-
- $this->assertEqual($expectedGroups, Piwik_SitesManager_API::getInstance()->getSitesGroups());
-
- }
- function test_addSites_invalidTimezone()
- {
- // trying invalid timezones
- try {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array('http://example.org'),$ecommerce=0, '', '', 'UTC+15');
- $this->fail('invalid timezone should raise an exception');
- } catch(Exception $e) {
- }
- try {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array('http://example.org'),$ecommerce=0, '', '', 'Paris');
- $this->fail('invalid timezone should raise an exception');
- } catch(Exception $e) {
- }
- $this->pass();
- }
-
- function test_addSites_invalidCurrency()
- {
- $invalidCurrency = '€';
- try {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array('http://example.org'),$ecommerce=0, '', 'UTC', $invalidCurrency);
- $this->fail('invalid currency should raise an exception');
- } catch(Exception $e) {
- }
- $this->pass();
- }
-
- function test_setDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps()
- {
- // test that they return default values
- $defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
- $this->assertEqual($defaultTimezone, 'UTC');
- $defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
- $this->assertEqual($defaultCurrency, 'USD');
- $excludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
- $this->assertEqual($excludedIps, '');
- $excludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
- $this->assertEqual($excludedQueryParameters, '');
-
- // test that when not specified, defaults are set as expected
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array('http://example.org'));
- $site = new Piwik_Site($idsite);
- $this->assertEqual($site->getTimezone(), 'UTC');
- $this->assertEqual($site->getCurrency(), 'USD');
- $this->assertEqual($site->getExcludedQueryParameters(), '');
- $this->assertEqual($site->getExcludedIps(), '');
- $this->assertEqual($site->isEcommerceEnabled(), false);
-
- // set the global timezone and get it
- $newDefaultTimezone = 'UTC+5.5';
- Piwik_SitesManager_API::getInstance()->setDefaultTimezone($newDefaultTimezone);
- $defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
- $this->assertEqual($defaultTimezone, $newDefaultTimezone);
-
- // set the default currency and get it
- $newDefaultCurrency = 'EUR';
- Piwik_SitesManager_API::getInstance()->setDefaultCurrency($newDefaultCurrency);
- $defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
- $this->assertEqual($defaultCurrency, $newDefaultCurrency);
-
- // set the global IPs to exclude and get it
- $newGlobalExcludedIps = '1.1.1.*,1.1.*.*,150.1.1.1';
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedIps($newGlobalExcludedIps);
- $globalExcludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
- $this->assertEqual($globalExcludedIps, $newGlobalExcludedIps);
-
- // set the global URL query params to exclude and get it
- $newGlobalExcludedQueryParameters = 'PHPSESSID,blabla, TesT';
- // removed the space
- $expectedGlobalExcludedQueryParameters = 'PHPSESSID,blabla,TesT';
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($newGlobalExcludedQueryParameters);
- $globalExcludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
- $this->assertEqual($globalExcludedQueryParameters, $expectedGlobalExcludedQueryParameters);
-
- // create a website and check that default currency and default timezone are set
- // however, excluded IPs and excluded query Params are not returned
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array('http://example.org'),$ecommerce=1, '', '', $newDefaultTimezone);
- $site = new Piwik_Site($idsite);
- $this->assertEqual($site->getTimezone(), $newDefaultTimezone);
- $this->assertEqual($site->getCreationDate()->toString(), date('Y-m-d'));
- $this->assertEqual($site->getCurrency(), $newDefaultCurrency);
- $this->assertEqual($site->getExcludedIps(), '');
- $this->assertEqual($site->getExcludedQueryParameters(), '');
- $this->assertEqual($site->isEcommerceEnabled(), true);
- }
-
- function test_getSitesIdFromSiteUrl_SuperUser()
- {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array("http://piwik.net","http://piwik.com"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2",array("http://piwik.com","http://piwik.net"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.com","http://piwik.org"));
-
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.org');
- $this->assertTrue(count($idsites) == 1);
-
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://www.piwik.org');
- $this->assertTrue(count($idsites) == 1);
-
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
- $this->assertTrue(count($idsites) == 2);
-
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
- $this->assertTrue(count($idsites) == 3);
- }
-
- function test_getSitesIdFromSiteUrl_User()
- {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array("http://www.piwik.net","http://piwik.com"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2",array("http://piwik.com","http://piwik.net"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.com","http://piwik.org"));
-
- $saveAccess = Zend_Registry::get('access');
-
- Piwik_UsersManager_API::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("user1", "view", array(1));
-
- Piwik_UsersManager_API::getInstance()->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("user2", "view", array(1));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user2", "admin", array(3));
-
- Piwik_UsersManager_API::getInstance()->addUser("user3", "geqgegagae", "tegst3@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("user3", "view", array(1,2));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user3", "admin", array(3));
-
- $pseudoMockAccess = new FakeAccess;
- FakeAccess::$superUser = false;
- FakeAccess::$identity = 'user1';
- FakeAccess::setIdSitesView (array(1));
- FakeAccess::setIdSitesAdmin (array());
- Zend_Registry::set('access', $pseudoMockAccess);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
- $this->assertTrue(count($idsites) == 1);
-
- // testing URL normalization
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://www.piwik.com');
- $this->assertTrue(count($idsites) == 1);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
- $this->assertTrue(count($idsites) == 1);
-
- $pseudoMockAccess = new FakeAccess;
- FakeAccess::$superUser = false;
- FakeAccess::$identity = 'user2';
- FakeAccess::setIdSitesView (array(1));
- FakeAccess::setIdSitesAdmin (array(3));
- Zend_Registry::set('access', $pseudoMockAccess);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
- $this->assertTrue(count($idsites) == 2);
-
- $pseudoMockAccess = new FakeAccess;
- FakeAccess::$superUser = false;
- FakeAccess::$identity = 'user3';
- FakeAccess::setIdSitesView (array(1,2));
- FakeAccess::setIdSitesAdmin (array(3));
- Zend_Registry::set('access', $pseudoMockAccess);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
- $this->assertTrue(count($idsites) == 3);
-
- Zend_Registry::set('access', $saveAccess);
- }
-
-
- function test_getSitesFromTimezones()
- {
- $idsite1 = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org"),null,null,null,'UTC');
- $idsite2 = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org"),null,null,null,'Pacific/Auckland');
- $idsite3 = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org"),null,null,null,'Pacific/Auckland');
- $idsite4 = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org"),null,null,null,'UTC+10');
- $result = Piwik_SitesManager_API::getInstance()->getSitesIdFromTimezones(array('UTC+10', 'Pacific/Auckland'));
- $this->assertEqual($result, array($idsite2,$idsite3,$idsite4));
-
- }
-
-}
diff --git a/plugins/UserCountry/tests/UserCountry.test.php b/plugins/UserCountry/tests/UserCountry.test.php
deleted file mode 100644
index 102dc9a743..0000000000
--- a/plugins/UserCountry/tests/UserCountry.test.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-require_once 'UserCountry/functions.php';
-
-class Test_Piwik_UserCountry extends UnitTestCase
-{
- public function test_getFlagFromCode()
- {
- $flag = Piwik_getFlagFromCode("us");
- $this->assertEqual( basename($flag), "us.png" );
- }
-
- public function test_getFlagFromInvalidCode()
- {
- $flag = Piwik_getFlagFromCode("foo");
- $this->assertEqual( basename($flag), "xx.png" );
- }
-
- public function test_flagsAndContinents()
- {
- require_once PIWIK_PATH_TEST_TO_ROOT . '/core/DataFiles/Countries.php';
-
- $continents = $GLOBALS['Piwik_ContinentList'];
- $countries = array_merge($GLOBALS['Piwik_CountryList'], $GLOBALS['Piwik_CountryList_Extras']);
-
- // Get list of existing flag icons
- $flags = scandir(PIWIK_PATH_TEST_TO_ROOT . '/plugins/UserCountry/flags/');
-
- // Get list of countries
- foreach($countries as $country => $continent)
- {
- // test continent
- $this->assertTrue(in_array($continent, $continents), "$country => $continent");
-
- // test flag
- $this->assertTrue(in_array($country . '.png', $flags), $country);
- }
-
- foreach($flags as $filename)
- {
- if($filename == '.' || $filename == '..' || $filename == '.svn')
- {
- continue;
- }
-
- $country = substr($filename, 0, strpos($filename, '.png'));
-
- // test country
- $this->assertTrue(array_key_exists($country, $countries), $filename);
- }
- }
-}
-
diff --git a/plugins/UserSettings/tests/UserSettings.test.php b/plugins/UserSettings/tests/UserSettings.test.php
deleted file mode 100644
index 1b7c2d7843..0000000000
--- a/plugins/UserSettings/tests/UserSettings.test.php
+++ /dev/null
@@ -1,971 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-if(!class_exists('Piwik_UserSettings', false))
-{
- require_once 'UserSettings/UserSettings.php';
-}
-require_once 'UserSettings/functions.php';
-
-class Test_Piwik_UserSettings extends UnitTestCase
-{
- // User agent strings and expected parser results
- protected $userAgents = array(
- // 'User Agent String' => array(
- // array( browser_id, name, short_name, version, major_number, minor_number, family ),
- // array( os_id, name, short_name )),
-
- // ABrowse
- 'Mozilla/5.0 (compatible; U; ABrowse 0.6; Syllable) AppleWebKit/420+ (KHTML, like Gecko)' => array(
- array('AB', 'ABrowse', 'ABrowse', '0.6', '0', '6', 'webkit'),
- array('SYL', 'Syllable', 'Syllable')),
- 'Mozilla/5.0 (compatible; ABrowse 0.4; Syllable)' => array(
- array('AB', 'ABrowse', 'ABrowse', '0.4', '0', '4', 'webkit'),
- array('SYL', 'Syllable', 'Syllable')),
-
- // Acoo Browser (treat as IE)
- 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6; Acoo Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Acoo Browser; .NET CLR 2.0.50727; .NET CLR 1.1.4322)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Acoo Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Amaya
- 'amaya/9.52 libwww/5.4.0' => array(
- array('AM', 'Amaya', 'Amaya', '9.52', '9', '52', 'unknown'),
- false),
-
- // AmigaVoyager
- 'AmigaVoyager/3.2 (AmigaOS/MC680x0)' => array(
- array('AV', 'AmigaVoyager', 'AmigaVoyager', '3.2', '3', '2', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
- 'AmigaVoyager/2.95 (compatible; MC680x0; AmigaOS; SV1)' => array(
- array('AV', 'AmigaVoyager', 'AmigaVoyager', '2.95', '2', '95', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
- 'AmigaVoyager/2.95 (compatible; MC680x0; AmigaOS)' => array(
- array('AV', 'AmigaVoyager', 'AmigaVoyager', '2.95', '2', '95', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
-
- // Android
- 'Mozilla/5.0 (Linux; U; Android 1.1; en-us; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2' => array(
- array('SF', 'Safari', 'Safari', '3.0', '3', '0', 'webkit'),
- array('AND', 'Android', 'Android')),
- 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1' => array(
- array('SF', 'Safari', 'Safari', '4.0', '4', '0', 'webkit'),
- array('AND', 'Android', 'Android')),
- 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; device Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Safari/533.1' => array(
- array('SF', 'Safari', 'Safari', '4.0', '4', '0', 'webkit'),
- array('AND', 'Android', 'Android')),
- 'Mozilla/5.0 (Linux; U; Android 4.0.1; en-us; Galaxy Nexus Build/ITL41D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30' => array(
- array('SF', 'Safari', 'Safari', '4.0', '4', '0', 'webkit'),
- array('AND', 'Android', 'Android')),
-
- // Android - Mobile Chrome
-/*
- 'Mozilla/5.0 (Linux; U; Android 4.1; en-us) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.16 Safari/534.24' => array(
- array('CH', 'Chrome', 'Chrome', '11.0', '11', '0', 'webkit'),
- array('AND', 'Android', 'Android')),
-*/
- 'Mozilla/5.0 (Linux; U; Android 4.0.1; en-us; Galaxy Nexus Build/ITL41F) AppleWebKit/535.7 (KHTML, like Gecko) CrMo/16.0.912.75 Mobile Safari/535.7' => array(
- array('CH', 'Chrome', 'Chrome', '16.0', '16', '0', 'webkit'),
- array('AND', 'Android', 'Android')),
-
- // AOL / America Online Browser (treat as IE)
- 'Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.43; Windows NT 5.1; .NET CLR 1.1.4322)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.1; AOLBuild 4334.5009; Windows NT 5.1; GTB5; .NET CLR 1.1.4322)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; InfoPath.1)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; AOL 8.0; Windows NT 5.1; SV1)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; AOL 7.0; Windows NT 5.1)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 6.0; Windows 98; Win 9x 4.90)' => array(
- array('IE', 'Internet Explorer', 'IE', '5.5', '5', '5', 'ie'),
- array('WME', 'Windows Me', 'Win Me')),
- 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 5.0; Windows NT 5.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '5.5', '5', '5', 'ie'),
- array('W2K', 'Windows 2000', 'Win 2000')),
- 'Mozilla/4.0 (compatible; MSIE 4.01; AOL 4.0; Windows 95)' => array(
- array('IE', 'Internet Explorer', 'IE', '4.01', '4', '01', 'ie'),
- array('W95', 'Windows 95', 'Win 95')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; America Online Browser 1.1; Windows NT 5.1; (R1 1.5); .NET CLR 2.0.50727; InfoPath.1)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; America Online Browser 1.1; Windows 98)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('W98', 'Windows 98', 'Win 98')),
-
- // Arora
- 'Mozilla/5.0 (X11; U; Linux; de-DE) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.8.0' => array(
- array('AR', 'Arora', 'Arora', '0.8', '0', '8', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6' => array(
- array('AR', 'Arora', 'Arora', '0.6', '0', '6', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.2; pt-BR) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )' => array(
- array('AR', 'Arora', 'Arora', '0.4', '0', '4', 'webkit'),
- array('WS3', 'Windows Server 2003 / XP x64', 'Win S2003')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)' => array(
- array('AR', 'Arora', 'Arora', '0.3', '0', '3', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2 (Change: 189 35c14e0)' => array(
- array('AR', 'Arora', 'Arora', '0.2', '0', '2', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
-
- // Avant (treat as IE)
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser; .NET CLR 2.0.50727; MAXTHON 2.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Avant Browser; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WI7', 'Windows 7', 'Win 7')),
-
- // AWeb
- 'Amiga-AWeb/3.5.07 beta' => array(
- array('AW', 'Amiga AWeb', 'AWeb', '3.5', '3', '5', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
- 'Mozilla/6.0; (Spoofed by Amiga-AWeb/3.5.07 beta)' => array(
- array('AW', 'Amiga AWeb', 'AWeb', '3.5', '3', '5', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
- 'MSIE/6.0; (Spoofed by Amiga-AWeb/3.4APL)' => array(
- array('AW', 'Amiga AWeb', 'AWeb', '3.4', '3', '4', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
-
- // Beonex
- 'Mozilla/5.0 (Windows; U; WinNT; en; rv:1.0.2) Gecko/20030311 Beonex/0.8.2-stable' => array(
- array('BE', 'Beonex', 'Beonex', '0.8', '0', '8', 'unknown'),
- array('WNT', 'Windows NT', 'Win NT')),
- 'Mozilla/5.0 (Windows; U; WinNT; en; Preview) Gecko/20020603 Beonex/0.8-stable' => array(
- array('BE', 'Beonex', 'Beonex', '0.8', '0', '8', 'unknown'),
- array('WNT', 'Windows NT', 'Win NT')),
-
- // BlackBerry
- 'BlackBerry8700/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1' => array(
- array('BB', 'BlackBerry', 'BlackBerry', '4.1', '4', '1', 'webkit'),
- array('BLB', 'BlackBerry', 'BlackBerry')),
-
- 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, Like Gecko) Version/6.0.0.141 Mobile Safari/534.1+' => array(
- array('BB', 'BlackBerry', 'BlackBerry', '6.0', '6', '0', 'webkit'),
- array('BLB', 'BlackBerry', 'BlackBerry')),
-
- 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/0.0.1 Safari/534.11+' => array(
- array('BP', 'PlayBook', 'PlayBook', '0.0', '0', '0', 'webkit' ),
- array('QNX', 'QNX', 'QNX')),
-
- 'Mozilla/5.0 (BB10; Dev Alpha) AppleWebKit/534.11+ (KHTML, like Gecko) Version/10.0 Mobile Safari/534.11+' => array(
- array('B2', 'BlackBerry', 'BlackBerry', '10.0', '10', '0', 'webkit' ),
- array('BBX', 'BB10', 'BB10')),
-
- // BrowseX
- 'Mozilla/4.61 [en] (X11; U; ) - BrowseX (2.0.0 Windows)' => array(
- array('BX', 'BrowseX', 'BrowseX', '2.0', '2', '0', 'unknown'),
- false),
-
- // Camino (formerly known as Chimera; not to be confused with another browser also named Chimera)
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en; rv:1.9.0.8pre) Gecko/2009022800 Camino/2.0b3pre' => array(
- array('CA', 'Camino', 'Camino', '2.0', '2', '0', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en; rv:1.9.0.10pre) Gecko/2009041800 Camino/2.0b3pre (like Firefox/3.0.10pre)' => array(
- array('CA', 'Camino', 'Camino', '2.0', '2', '0', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.4pre) Gecko/20070511 Camino/1.6pre' => array(
- array('CA', 'Camino', 'Camino', '1.6', '1', '6', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.6) Gecko/20070809 Firefox/2.0.0.6 Camino/1.5.1' => array(
- array('CA', 'Camino', 'Camino', '1.5', '1', '5', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20030306 Camino/0.7' => array(
- array('CA', 'Camino', 'Camino', '0.7', '0', '7', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; pl-PL; rv:1.0.1) Gecko/20021111 Chimera/0.6' => array(
- array('CA', 'Camino', 'Camino', '0.6', '0', '6', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
- // Cheshire
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.8 (KHTML, like Gecko, Safari) Cheshire/1.0.UNOFFICIAL' => array(
- array('CS', 'Cheshire', 'Cheshire', '1.0', '1', '0', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko, Safari/419.3) Cheshire/1.0.ALPHA' => array(
- array('CS', 'Cheshire', 'Cheshire', '1.0', '1', '0', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 (KHTML, like Safari) Cheshire/1.0.ALPHA' => array(
- array('CS', 'Cheshire', 'Cheshire', '1.0', '1', '0', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
- // Chrome / Chromium
- 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.310.0 Safari/532.9' => array(
- array('CH', 'Chrome', 'Chrome', '5.0', '5', '0', 'webkit'),
- array('WS3', 'Windows Server 2003 / XP x64', 'Win S2003')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.48 Safari/525.19' => array(
- array('CH', 'Chrome', 'Chrome', '1.0', '1', '0', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Linux; U; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13' => array(
- array('CH', 'Chrome', 'Chrome', '0.2', '0', '2', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.16 Safari/534.24' => array(
- array('CH', 'Chrome', 'Chrome', '11.0', '11', '0', 'webkit'),
- array('WVI', 'Windows Vista', 'Win Vista')),
- 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.16 Safari/534.24' => array(
- array('CH', 'Chrome', 'Chrome', '11.0', '11', '0', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
-
- // Chrome Frame
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; chromeframe/11.0.660.0)' => array(
- array('CF', 'Chrome Frame', 'Chrome Frame', '11.0', '11', '0', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) chromeframe/11.0.660.0' => array(
- array('CF', 'Chrome Frame', 'Chrome Frame', '11.0', '11', '0', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; chromeframe/11.0.660.0) AppleWebKit/534.18 (KHTML, like Gecko) Chrome/11.0.660.0 Safari/534.18' => array(
- array('CF', 'Chrome Frame', 'Chrome Frame', '11.0', '11', '0', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.18 (KHTML, like Gecko) Chrome/11.0.660.0 Safari/534.18' => array(
- array('CH', 'Chrome', 'Chrome', '11.0', '11', '0', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // ChromePlus (treat as Chrome)
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) ChromePlus/4.0.222.3 Chrome/4.0.222.3 Safari/532.2' => array(
- array('CH', 'Chrome', 'Chrome', '4.0', '4', '0', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 ChromePlus/4.0.222.3 Chrome/4.0.222.3 Safari/525.28.3' => array(
- array('CH', 'Chrome', 'Chrome', '3.2', '3', '2', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // CometBird
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2009011615 Firefox/3.0.5 CometBird/3.0.5' => array(
- array('CO', 'CometBird', 'CometBird', '3.0', '3', '0', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Crazy Browser (treat as IE)
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 1.1.4322; Crazy Browser 3.0.0 Beta2)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser; .NET CLR 2.0.50727; .NET CLR 3.0.04506.590; .NET CLR 3.5.20706; Crazy Browser 2.0.1)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Dillo
- 'Dillo/2.0' => array(
- array('DI', 'Dillo', 'Dillo', '2.0', '2', '0', 'unknown'),
- false),
- 'Dillo/0.6.4' => array(
- array('DI', 'Dillo', 'Dillo', '0.6', '0', '6', 'unknown'),
- false),
-
- // Dolfin (or Dolphin, depending on which Samsung documentation you read); and yes, it's "bada" (lower-case)
- 'Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S5250/S5250AIJI3; U; Bada/1.0; it-it) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.0 Mobile WQVGA SMM-MMS/1.2.0 NexPlayer/3.0 profile/MIDP-2.1 configuration/CLDC-1.1 OPN-B' => array(
- array('DF', 'Dolfin', 'Dolfin', '2.0', '2', '0', 'webkit'),
- array('SBA', 'bada', 'bada')),
- 'Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8530/S8530XXJKA; U; Bada/1.2; en-us) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.2 Mobile WVGA SMM-MMS/1.2.0 OPN-B' => array(
- array('DF', 'Dolfin', 'Dolfin', '2.2', '2', '2', 'webkit'),
- array('SBA', 'bada', 'bada')),
-
- // ELinks
- 'ELinks/0.12~pre2.dfsg0-1ubuntu1-lite (textmode; Debian; Linux 2.6.32-4-jolicloud i686; 143x37-2)' => array(
- array('EL', 'ELinks', 'ELinks', '0.12', '0', '12', 'unknown'),
- array('LIN', 'Linux', 'Linux')),
- 'ELinks/0.12pre5.GIT (textmode; CYGWIN_NT-6.1 1.7.1(0.218/5/3) i686; 80x24-2)' => array(
- array('EL', 'ELinks', 'ELinks', '0.12', '0', '12', 'unknown'),
- array('WI7', 'Windows 7', 'Win 7')),
- 'ELinks (0.4.3; NetBSD 3.0.2_PATCH sparc64; 141x19)' => array(
- array('EL', 'ELinks', 'ELinks', '0.4', '0', '4', 'unknown'),
- array('NBS', 'NetBSD', 'NetBSD')),
-
- // Epiphany
- 'Mozilla/5.0 (X11; U; Linux i686; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Safari/531.2+ Epiphany/2.29.5' => array(
- array('EP', 'Epiphany', 'Epiphany', '2.29', '2', '29', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9.0.11) Gecko/20080528 Epiphany/2.22 Firefox/3.0' => array(
- // technically, this should be 'gecko' but UserAgentParser only supports one browserType (family) per browser
- array('EP', 'Epiphany', 'Epiphany', '2.22', '2', '22', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
-
- // Fennec
- 'Mozilla/5.0 (Android; Linux armv7l; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 Fennec/2.0.1' => array(
- array('FE', 'Fennec', 'Fennec', '2.0', '2', '0', 'gecko'),
- array('AND', 'Android', 'Android')),
- 'Mozilla/5.0 (Maemo; Linux armv7l; rv2.0.1) Gecko/20100101 Firefox/4.0.1 Fennec/2.0.1' => array(
- array('FE', 'Fennec', 'Fennec', '2.0', '2', '0', 'gecko'),
- array('MAE', 'Maemo', 'Maemo')),
- 'Mozilla/5.0 (X11; Linux i686; rv2.0.1) Gecko/20100101 Firefox/4.0.1 Fennec/2.0.1' => array(
- array('FE', 'Fennec', 'Fennec', '2.0', '2', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2a1pre) Gecko/20090626 Fennec/1.0b2' => array(
- array('FE', 'Fennec', 'Fennec', '1.0', '1', '0', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (X11; U; Linux armv6l; en-US; rv:1.9.1b1pre) Gecko/20081005220218 Gecko/2008052201 Fennec/0.9pre' => array(
- array('FE', 'Fennec', 'Fennec', '0.9', '0', '9', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux armv6l; en-US; rv:1.9.1a1pre) Gecko/2008071707 Fennec/0.5' => array(
- array('FE', 'Fennec', 'Fennec', '0.5', '0', '5', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
-
- // Firefox (formerly Firebird, formerly Phoenix; and rebranded versions)
- 'Mozilla/5.0 (X11; Linux i686; rv:5.0a2) Gecko/20110413 Firefox/5.0a2' => array(
- array('FF', 'Firefox', 'Firefox', '5.0', '5', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1' => array(
- array('FF', 'Firefox', 'Firefox', '4.0', '4', '0', 'gecko'),
- array('WI7', 'Windows 7', 'Win 7')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:2.0a1pre) Gecko/2008060602 Minefield/4.0a1pre' => array(
- array('FF', 'Firefox', 'Firefox', '4.0', '4', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:2.0a1pre) Gecko/2008060602 Minefield/4.0a1p' => array(
- array('FF', 'Firefox', 'Firefox', '4.0', '4', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2a2pre) Gecko/20090826 Namoroka/3.6a2pre' => array(
- array('FF', 'Firefox', 'Firefox', '3.6', '3', '6', 'gecko'),
- array('WVI', 'Windows Vista', 'Win Vista')),
- 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100119 Namoroka/3.6' => array(
- array('FF', 'Firefox', 'Firefox', '3.6', '3', '6', 'gecko'),
- array('WI7', 'Windows 7', 'Win 7')),
- 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1b4pre) Gecko/20090420 Shiretoko/3.5b4pre (.NET CLR 3.5.30729)' => array(
- array('FF', 'Firefox', 'Firefox', '3.5', '3', '5', 'gecko'),
- array('WI7', 'Windows 7', 'Win 7')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2' => array(
- array('FF', 'Firefox', 'Firefox', '3.5', '3', '5', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6' => array(
- array('FF', 'Firefox', 'Firefox', '3.0', '3', '0', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9a7) Gecko/2007080210 GranParadiso/3.0a7' => array(
- array('FF', 'Firefox', 'Firefox', '3.0', '3', '0', 'gecko'),
- array('WVI', 'Windows Vista', 'Win Vista')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008072716 IceCat/3.0.1-g1' => array(
- array('FF', 'Firefox', 'Firefox', '3.0', '3', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.1) Gecko/2008071420 Iceweasel/3.0.1 (Debian-3.0.1-1)' => array(
- array('FF', 'Firefox', 'Firefox', '3.0', '3', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1b2) Gecko/20060821 BonEcho/2.0b2' => array(
- array('FF', 'Firefox', 'Firefox', '2.0', '2', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Darwin Power Macintosh; en-US; rv:1.8.0.12) Gecko/20070803 Firefox/1.5.0.12 Fink Community Edition' => array(
- array('FF', 'Firefox', 'Firefox', '1.5', '1', '5', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031212 Firebird/0.7+' => array(
- array('FB', 'Firebird', 'Firebird', '0.7', '0', '7', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Windows; U; Win98; de-DE; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6' => array(
- array('FB', 'Firebird', 'Firebird', '0.6', '0', '6', 'gecko'),
- array('W98', 'Windows 98', 'Win 98')),
- 'Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5' => array(
- array('PX', 'Phoenix', 'Phoenix', '0.5', '0', '5', 'gecko'),
- array('WNT', 'Windows NT', 'Win NT')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2b) Gecko/20020923 Phoenix/0.1' => array(
- array('PX', 'Phoenix', 'Phoenix', '0.1', '0', '1', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Nintendo DS v4; U; M3 Adapter CF + PassMe2; en-US; rv:1.8.0.6 ) Gecko/20060728 Firefox/1.5.0.6 (firefox.gba.ds)' => array(
- array('FF', 'Firefox', 'Firefox', '1.5', '1', '5', 'gecko'),
- array('NDS', 'Nintendo DS', 'DS')),
-
- // Flock
- 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Flock/3.0.0.3737 Chrome/4.1.249.1071 Safari/532.5' => array(
- array('FL', 'Flock', 'Flock', '3.0', '3', '0', 'webkit'),
- array('WI7', 'Windows 7', 'Win 7')),
- // pre-3.0 is actually gecko
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 Flock/2.5.6 (.NET CLR 3.5.30729)' => array(
- array('FL', 'Flock', 'Flock', '2.5', '2', '5', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 AppleWebKit/531.21.8 KHTML/4.3.5 (like Gecko) Firefox/3.5.7 Flock/2.5.6 (.NET CLR 3.5.30729)' => array(
- array('FL', 'Flock', 'Flock', '2.5', '2', '5', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 AppleWebKit/531.21.8 (KHTML, like Gecko) Firefox/3.5.7 Flock/2.5.6 (.NET CLR 3.5.30729)' => array(
- array('FL', 'Flock', 'Flock', '2.5', '2', '5', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071106 Firefox/2.0.0.9 Flock/1.0.1' => array(
- array('FL', 'Flock', 'Flock', '1.0', '1', '0', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.8) Gecko/20071101 Firefox/2.0.0.8 Flock/1.0' => array(
- array('FL', 'Flock', 'Flock', '1.0', '1', '0', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b5) Gecko/20051021 Flock/0.4 Firefox/1.0+' => array(
- array('FL', 'Flock', 'Flock', '0.4', '0', '4', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
- // Fluid
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; nl-nl) AppleWebKit/532.3+ (KHTML, like Gecko) Fluid/0.9.6 Safari/532.3+' => array(
- array('FD', 'Fluid', 'Fluid', '0.9', '0', '9', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Fluid/0.9.4 Safari/525.13' => array(
- array('FD', 'Fluid', 'Fluid', '0.9', '0', '9', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Galeon
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko/20090327 Galeon/2.0.7' => array(
- array('GA', 'Galeon', 'Galeon', '2.0', '2', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; OpenBSD i386; en-US; rv:1.8.1.19) Gecko/20090701 Galeon/2.0.7' => array(
- array('GA', 'Galeon', 'Galeon', '2.0', '2', '0', 'gecko'),
- array('OBS', 'OpenBSD', 'OpenBSD')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.19) Gecko/20081216 Galeon/2.0.4 Firefox/2.0.0.19' => array(
- array('GA', 'Galeon', 'Galeon', '2.0', '2', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.13pre) Gecko/20080207 Galeon/2.0.1 (Ubuntu package 2.0.1-1ubuntu2) Firefox/1.5.0.13pre' => array(
- array('GA', 'Galeon', 'Galeon', '2.0', '2', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040406 Galeon/1.3.15' => array(
- array('GA', 'Galeon', 'Galeon', '1.3', '1', '3', 'gecko'),
- array('BSD', 'FreeBSD', 'FreeBSD')),
- 'Mozilla/5.0 Galeon/1.2.9 (X11; Linux i686; U;) Gecko/20021213 Debian/1.2.9-0.bunk' => array(
- array('GA', 'Galeon', 'Galeon', '1.2', '1', '2', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 Galeon/1.0.3 (X11; Linux i686; U;) Gecko/0' => array(
- array('GA', 'Galeon', 'Galeon', '1.0', '1', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
-
- // Google Earth embedded browser
- 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.4 (KHTML, like Gecko) Google Earth/5.2.1.1329 Safari/532.4' => array(
- array('GE', 'Google Earth', 'Google Earth', '5.2', '5', '2', 'webkit'),
- array('WI7', 'Windows 7', 'Win 7')),
-
- // GreenBrowser (treat as IE)
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; .NET CLR 3.5.21022; GreenBrowser)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; InfoPath.2; .NET CLR 3.0.30729; GreenBrowser)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WVI', 'Windows Vista', 'Win Vista')),
-
- // Hana
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 (KHTML, like Gecko) Hana/1.1' => array(
- array('HA', 'Hana', 'Hana', '1.1', '1', '1', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/417.9 (KHTML, like Gecko) Hana/1.0' => array(
- array('HA', 'Hana', 'Hana', '1.0', '1', '0', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
- // HotJava
- 'HotJava/1.1.2 FCS' => array(
- array('HJ', 'HotJava', 'HotJava', '1.1', '1', '1', 'unknown'),
- false),
- 'HotJava/1.0.1/JRE1.1.x' => array(
- array('HJ', 'HotJava', 'HotJava', '1.0', '1', '0', 'unknown'),
- false),
-
- // iBrowse
- 'Mozilla/5.0 (compatible; IBrowse 3.0; AmigaOS4.0)' => array(
- array('IB', 'IBrowse', 'IBrowse', '3.0', '3', '0', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
- 'Mozilla/4.0 (compatible; IBrowse 2.3; AmigaOS4.0)' => array(
- array('IB', 'IBrowse', 'IBrowse', '2.3', '2', '3', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
- 'IBrowse/2.4 (AmigaOS 3.9; 68K)' => array(
- array('IB', 'IBrowse', 'IBrowse', '2.4', '2', '4', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
- 'IBrowse/2.3 (AmigaOS V51)' => array(
- array('IB', 'IBrowse', 'IBrowse', '2.3', '2', '3', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
- 'IBrowse/2.3 (AmigaOS 4.0)' => array(
- array('IB', 'IBrowse', 'IBrowse', '2.3', '2', '3', 'unknown'),
- array('AMI', 'AmigaOS', 'AmigaOS')),
-
- // iCab
- 'iCab/4.5 (Macintosh; U; PPC Mac OS X)' => array(
- array('IC', 'iCab', 'iCab', '4.5', '4', '5', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'iCab/4.5 (Macintosh; U; Mac OS X Leopard 10.5.7)' => array(
- array('IC', 'iCab', 'iCab', '4.5', '4', '5', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (compatible; iCab 3.0.5; Macintosh; U; PPC Mac OS)' => array(
- array('IC', 'iCab', 'iCab', '3.0', '3', '0', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (compatible; iCab 3.0.5; Macintosh; U; PPC Mac OS X)' => array(
- array('IC', 'iCab', 'iCab', '3.0', '3', '0', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS; en) iCab 3' => array(
- array('IC', 'iCab', 'iCab', '3.0', '3', '0', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/4.5 (compatible; iCab 2.7.1; Macintosh; I; PPC)' => array(
- array('IC', 'iCab', 'iCab', '2.7', '2', '7', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'iCab/2.9.8 (Macintosh; U; 68K)' => array(
- array('IC', 'iCab', 'iCab', '2.9', '2', '9', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Lynx/2.8 (compatible; iCab 2.9.8; Macintosh; U; 68K)' => array(
- array('IC', 'iCab', 'iCab', '2.9', '2', '9', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/4/5 (compatible; iCab 2.9.8; Macintosh; U; 68K)' => array(
- array('IC', 'iCab', 'iCab', '2.9', '2', '9', 'unknown'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC)' => array(
- array('IE', 'Internet Explorer', 'IE', '5.0', '5', '0', 'ie'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/4.76 (Macintosh; I; PPC)' => array(
- array('NS', 'Netscape', 'Netscape', '4.76', '4', '76', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
- // Internet Explorer
- 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '10.0', '10', '0', 'ie'),
- array('WI8', 'Windows 8', 'Win 8')),
- 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '10.0', '10', '0', 'ie'),
- array('WI7', 'Windows 7', 'Win 7')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '10.0', '10', '0', 'ie'),
- array('WI7', 'Windows 7', 'Win 7')),
- 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '9.0', '9', '0', 'ie'),
- array('WI7', 'Windows 7', 'Win 7')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '9.0', '9', '0', 'ie'),
- array('WVI', 'Windows Vista', 'Win Vista')),
- 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 3.0.04506; .NET CLR 3.5.21022; InfoPath.2; SLCC1; Zune 3.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WI7', 'Windows 7', 'Win 7')),
- 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WVI', 'Windows Vista', 'Win Vista')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WVI', 'Windows Vista', 'Win Vista')),
- 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WS3', 'Windows Server 2003 / XP x64', 'Win S2003')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; WOW64; SV1; .NET CLR 2.0.50727)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WS3', 'Windows Server 2003 / XP x64', 'Win S2003')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; Win64; x64; SV1; .NET CLR 2.0.50727)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WS3', 'Windows Server 2003 / XP x64', 'Win S2003')),
-
- // IE Mobile
- 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i917)' => array(
- array('IE', 'Internet Explorer', 'IE', '9.0', '9', '0', 'ie'),
- array('WPH', 'Windows Phone OS', 'WinPhone')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; XBLWP7; ZuneWP7)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WPH', 'Windows Phone OS', 'WinPhone')),
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; DeviceManufacturer; DeviceModel)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WPH', 'Windows Phone OS', 'WinPhone')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.11)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WMO', 'Windows Mobile', 'WinMo')),
- 'Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)' => array(
- array('IE', 'Internet Explorer', 'IE', '4.01', '4', '01', 'ie'),
- array('WCE', 'Windows CE', 'Win CE')),
-
- // Internet Explorer with misbehaving Google Tool Bar
- 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB0.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)' => array(
- array('IE', 'Internet Explorer', 'IE', '8.0', '8', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Iron
- 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/531.0 (KHTML, like Gecko) Iron/3.0.189.0 Safari/531.0' => array(
- array('IR', 'Iron', 'Iron', '3.0', '3', '0', 'webkit'),
- array('WI7', 'Windows 7', 'Win 7')),
-
- // K-Meleon
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090331 K-Meleon/1.5.3' => array(
- array('KM', 'K-Meleon', 'K-Meleon', '1.5', '1', '5', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Darwin; FreeBSD 5.6; en-GB; rv:1.8.1.17pre) Gecko/20080716 K-Meleon/1.5.0' => array(
- array('KM', 'K-Meleon', 'K-Meleon', '1.5', '1', '5', 'gecko'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.2b) Gecko/20021016 K-Meleon 0.7' => array(
- array('KM', 'K-Meleon', 'K-Meleon', '0.7', '0', '7', 'gecko'),
- array('WNT', 'Windows NT', 'Win NT')),
-
- // Kapiko
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.1) Gecko/20080722 Firefox/3.0.1 Kapiko/3.0' => array(
- array('KP', 'Kapiko', 'Kapiko', '3.0', '3', '0', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Kazehakase
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11) Gecko Kazehakase/0.5.4 Debian/0.5.4-2.1ubuntu3' => array(
- array('KZ', 'Kazehakase', 'Kazehakase', '0.5', '0', '5', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.13) Gecko/20080311 (Debian-1.8.1.13+nobinonly-0ubuntu1) Kazehakase/0.5.2' => array(
- array('KZ', 'Kazehakase', 'Kazehakase', '0.5', '0', '5', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; Linux x86_64; U;) Gecko/20060207 Kazehakase/0.3.5 Debian/0.3.5-1' => array(
- array('KZ', 'Kazehakase', 'Kazehakase', '0.3', '0', '3', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
-
- // KKMAN (treat as IE)
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; KKMAN3.2)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Konqueror
- 'Mozilla/5.0 (compatible; Konqueror/4.0; Linux) KHTML/4.0.5 (like Gecko)' => array(
- array('KO', 'Konqueror', 'Konqueror', '4.0', '4', '0', 'khtml'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (compatible; Konqueror/4.0; Microsoft Windows) KHTML/4.0.80 (like Gecko)' => array(
- array('KO', 'Konqueror', 'Konqueror', '4.0', '4', '0', 'khtml'),
- false),
- 'Mozilla/5.0 (compatible; Konqueror/3.5; GNU/kFreeBSD) KHTML/3.5.9 (like Gecko) (Debian)' => array(
- array('KO', 'Konqueror', 'Konqueror', '3.5', '3', '5', 'khtml'),
- array('BSD', 'FreeBSD', 'FreeBSD')),
- 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)' => array(
- array('KO', 'Konqueror', 'Konqueror', '2.1', '2', '1', 'khtml'),
- false),
-
- // Links
- 'Links' => array(
- false,
- false),
- 'Links (2.1pre31; Linux 2.6.21-omap1 armv6l; x)' => array(
- array('LI', 'Links', 'Links', '2.1', '2', '1', 'unknown'),
- array('LIN', 'Linux', 'Linux')),
- 'Links (0.99; OS/2 1 i386; 80x33)' => array(
- array('LI', 'Links', 'Links', '0.99', '0', '99', 'unknown'),
- array('OS2', 'OS/2', 'OS/2')),
-
- // Lunascape (identity crisis)
- 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1) Gecko/20090701 Firefox/3.5 Lunascape/5.1.2.3' => array(
- array('FF', 'Firefox', 'Firefox', '3.5', '3', '5', 'gecko'),
- array('WVI', 'Windows Vista', 'Win Vista')),
- 'Mozilla/5.0 (Windows; U; ; cs-CZ) AppleWebKit/532+ (KHTML, like Gecko, Safari/532.0) Lunascape/5.1.2.3' => array(
- array('SF', 'Safari', 'Safari', '4.0', '4', '0', 'webkit'),
- false),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Lunascape 5.1.2.3)' => array(
- array('IE', 'Internet Explorer', 'IE', '6.0', '6', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Lynx
- 'Lynx (textmode)' => array(
- false,
- false),
- 'Lynx/2.8.7dev.9 libwww-FM/2.14' => array(
- array('LX', 'Lynx', 'Lynx', '2.8', '2', '8', 'unknown'),
- false),
-
- // Maxathon (treat as IE)
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)' => array(
- array('IE', 'Internet Explorer', 'IE', '7.0', '7', '0', 'ie'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Midori
- 'Midori/0.1.9 (X11; Linux i686; U; fr-fr) WebKit/532+' => array(
- array('MI', 'Midori', 'Midori', '0.1', '0', '1', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
-
- // Mozilla Suite
- 'Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7) Gecko/20070606' => array(
- array('MO', 'Mozilla', 'Mozilla', '1.7', '1', '7', 'gecko'),
- array('SOS', 'SunOS', 'SunOS')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050927 Debian/1.7.8-1sarge3' => array(
- array('MO', 'Mozilla', 'Mozilla', '1.7', '1', '7', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
-
- // NCSA Mosaic
- 'PATHWORKS Mosaic/1.0 libwww/2.15_Spyglass' => array(
- array('MC', 'NCSA Mosaic', 'Mosaic', '1.0', '1', '0', 'unknown'),
- false),
- 'WinMosaic/Version 2.0 (ALPHA 2)' => array(
- array('MC', 'NCSA Mosaic', 'Mosaic', '2.0', '2', '0', 'unknown'),
- false),
- 'VMS_Mosaic/3.8-1 (Motif;OpenVMS V7.3-2 DEC 3000 - M700) libwww/2.12_Mosaic' => array(
- array('MC', 'NCSA Mosaic', 'Mosaic', '3.8', '3', '8', 'unknown'),
- array('VMS', 'OpenVMS', 'OpenVMS')),
- 'Mosaic from Digital/1.02_Win32' => array(
- array('MC', 'NCSA Mosaic', 'Mosaic', '1.02', '1', '02', 'unknown'),
- array('W95', 'Windows 95', 'Win 95')),
- 'NCSA Mosaic/2.0.0b4 (Windows AXP)' => array(
- array('MC', 'NCSA Mosaic', 'Mosaic', '2.0', '2', '0', 'unknown'),
- false),
- 'NCSA_Mosaic/2.7b5 (X11;Linux 2.6.7 i686) libwww/2.12 modified' => array(
- array('MC', 'NCSA Mosaic', 'Mosaic', '2.7', '2', '7', 'unknown'),
- array('LIN', 'Linux', 'Linux')),
- 'mMosaic/3.6.6 (X11;SunOS 5.8 sun4m)' => array(
- array('MC', 'NCSA Mosaic', 'Mosaic', '3.6', '3', '6', 'unknown'),
- array('SOS', 'SunOS', 'SunOS')),
-
- // Netscape Navigator (9.x)
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.8pre) Gecko/20071015 Firefox/2.0.0.7 Navigator/9.0' => array(
- array('NS', 'Netscape', 'Netscape', '9.0', '9', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20070321 Netscape/9.0' => array(
- array('NS', 'Netscape', 'Netscape', '9.0', '9', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
-
- // Netscape (6.x - 8.x)
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20070321 Netscape/8.1.3' => array(
- array('NS', 'Netscape', 'Netscape', '8.1', '8', '1', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)' => array(
- array('NS', 'Netscape', 'Netscape', '7.2', '7', '2', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (X11; U; OSF1 alpha; en-US; rv:0.9.4.1) Gecko/20020517 Netscape6/6.2.3' => array(
- array('NS', 'Netscape', 'Netscape', '6.2', '6', '2', 'gecko'),
- array('T64', 'Tru64', 'Tru64')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.1' => array(
- array('NS', 'Netscape', 'Netscape', '6.1', '6', '1', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
-
- // Netscape Communicator (4.x)
- 'Mozilla/4.76C-SGI [en] (X11; I; IRIX64 6.5 IP30)' => array(
- array('NS', 'Netscape', 'Netscape', '4.76', '4', '76', 'gecko'),
- array('IRI', 'IRIX', 'IRIX')),
- 'Mozilla/4.72 [en] (X11; I; HP-UX B.11.00 9000/800)' => array(
- array('NS', 'Netscape', 'Netscape', '4.72', '4', '72', 'gecko'),
- array('HPX', 'HP-UX', 'HP-UX')),
- 'Mozilla/4.41 (BEOS; U ;Nav)' => array(
- array('NS', 'Netscape', 'Netscape', '4.41', '4', '41', 'gecko'),
- array('BEO', 'BeOS', 'BeOS')),
- 'Mozilla/4.0 (compatible; Windows NT 5.1; U; en)' => array(
- array('NS', 'Netscape', 'Netscape', '4.0', '4', '0', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Netscape Navigator (up to 3.x)
- 'Mozilla/3.0 (X11; I; AIX 2)' => array(
- array('NS', 'Netscape', 'Netscape', '3.0', '3', '0', 'gecko'),
- array('AIX', 'AIX', 'AIX')),
- 'Mozilla/2.02 [fr] (WinNT; I)' => array(
- array('NS', 'Netscape', 'Netscape', '2.02', '2', '02', 'gecko'),
- array('WNT', 'Windows NT', 'Win NT')),
-
- // Omniweb
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US) AppleWebKit/525.18 (KHTML, like Gecko, Safari/525.20) OmniWeb/v622.3.0.105198' => array(
- array('OW', 'OmniWeb', 'OmniWeb', '5.8', '5', '8', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/522+ (KHTML, like Gecko, Safari/522) OmniWeb/v613' => array(
- array('OW', 'OmniWeb', 'OmniWeb', '5.6', '5', '6', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/420+ (KHTML, like Gecko, Safari/420) OmniWeb/v607' => array(
- array('OW', 'OmniWeb', 'OmniWeb', '5.5', '5', '5', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/125.4 (KHTML, like Gecko, Safari) OmniWeb/v563.34' => array(
- array('OW', 'OmniWeb', 'OmniWeb', '5.1', '5', '1', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/85 (KHTML, like Gecko) OmniWeb/v558.36' => array(
- array('OW', 'OmniWeb', 'OmniWeb', '5.0', '5', '0', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/85 (KHTML, like Gecko) OmniWeb/v496' => array(
- array('OW', 'OmniWeb', 'OmniWeb', '4.5', '4', '5', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
- // Opera
- 'Opera/9.63 (Windows NT 5.1; U; en) Presto/2.1.1' => array(
- array('OP', 'Opera', 'Opera', '9.63', '9', '63', 'opera'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Opera/9.30 (Nintendo Wii; U; ; 2047-7; en)' => array(
- array('OP', 'Opera', 'Opera', '9.30', '9', '30', 'opera'),
- array('WII', 'Nintendo Wii', 'Wii')),
- 'Opera/9.64 (Windows ME; U; en) Presto/2.1.1' => array(
- array('OP', 'Opera', 'Opera', '9.64', '9', '64', 'opera'),
- array('WME', 'Windows Me', 'Win Me')),
- 'Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.00' => array(
- array('OP', 'Opera', 'Opera', '10.00', '10', '0', 'opera'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/4.0 (compatible; MSIE 6.0; Nitro) Opera 8.50 [en Mozilla/4.0 (compatible; MSIE 6.0; Nitro) Opera 8.50 [ja]' => array(
- array('OP', 'Opera', 'Opera', '8.50', '8', '50', 'opera'),
- array('NDS', 'Nintendo DS', 'DS')),
- 'Opera/9.00 (Nintendo DS U; ; 1309-9; de)' => array(
- array('OP', 'Opera', 'Opera', '9.00', '9', '00', 'opera'),
- array('NDS', 'Nintendo DS', 'DS')),
- 'Opera/9.50 (Nintendo DSi; Opera/507; U; en-US) ' => array(
- array('OP', 'Opera', 'Opera', '9.50', '9', '50', 'opera'),
- array('DSI', 'Nintendo DSi', 'DSi')),
-
- // PlayStation
- 'Mozilla/5.0 (PLAYSTATION 3; 1.00)' => array(
- false,
- array('PS3', 'PlayStation 3', 'PS3')),
-
- // PSP
- 'PSP (PlayStation Portable); 2.00' => array(
- false,
- array('PSP', 'PlayStation Portable', 'PSP')),
- 'Mozilla/4.0 (PSP (PlayStation Portable); 2.00)' => array(
- false,
- array('PSP', 'PlayStation Portable', 'PSP')),
-
- // Safari
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Version/3.1.2 Safari/525.21' => array(
- array('SF', 'Safari', 'Safari', '3.1', '3', '1', 'webkit'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5G77 Safari/525.20' => array(
- array('SF', 'Safari', 'Safari', '3.1', '3', '1', 'webkit'),
- array('IPH', 'iPhone', 'iPhone')),
- 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3' => array(
- array('SF', 'Safari', 'Safari', '3.0', '3', '0', 'webkit'),
- array('IPD', 'iPod', 'iPod')),
- 'Mozilla/5.0 (iPod; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11a Safari/525.20' => array(
- array('SF', 'Safari', 'Safari', '3.1', '3', '1', 'webkit'),
- array('IPD', 'iPod', 'iPod')),
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/527.3+ (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1' => array(
- array('SF', 'Safari', 'Safari', '3.1', '3', '1', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10' => array(
- array('SF', 'Safari', 'Safari', '4.0', '4', '0', 'webkit'),
- array('IPA', 'iPad', 'iPad')),
- 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10' => array(
- array('SF', 'Safari', 'Safari', '4.0', '4', '0', 'webkit'),
- array('IPA', 'iPad', 'iPad')),
- 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7' => array(
- array('SF', 'Safari', 'Safari', '4.0', '4', '0', 'webkit'),
- array('IPD', 'iPod', 'iPod')),
- 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7' => array(
- array('SF', 'Safari', 'Safari', '4.0', '4', '0', 'webkit'),
- array('IPH', 'iPhone', 'iPhone')),
- 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) ' => array(
- array('SF', 'Safari', 'Safari', '5.0', '5', '0', 'webkit'),
- array('WVI', 'Windows Vista', 'Win Vista')),
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50' => array(
- array('SF', 'Safari', 'Safari', '5.1', '5', '1', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
-
- // SeaMonkey (formerly Mozilla Suite and rebranded versions)
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.8) Gecko/20071008 Iceape/1.1.5 (Ubuntu-1.1.5-1ubuntu0.7.10)' => array(
- array('SM', 'SeaMonkey', 'SeaMonkey', '1.1', '1', '1', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b4pre) Gecko/20090405 SeaMonkey/2.0b1pre' => array(
- array('SM', 'SeaMonkey', 'SeaMonkey', '2.0', '2', '0', 'gecko'),
- array('LIN', 'Linux', 'Linux')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko' => array(
- // this pre-2.0 UA is missing the SeaMonkey/X.Y
- array('SM', 'SeaMonkey', 'SeaMonkey', '1.9', '1', '9', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
- 'Mozilla/5.0 (Windows; U; Windows NT 5.1; cs; rv:1.9) Gecko/2008052906' => array(
- // this pre-2.0 UA is missing the SeaMonkey/X.Y
- array('SM', 'SeaMonkey', 'SeaMonkey', '1.9', '1', '9', 'gecko'),
- array('WXP', 'Windows XP', 'Win XP')),
-
- // Palm webOS
- 'Mozilla/5.0 (webOS/1.0; U; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0' => array(
- array('WO', 'Palm webOS', 'webOS', '1.0', '1', '0', 'webkit'),
- array('WOS', 'Palm webOS', 'webOS')),
- 'Mozilla/5.0 (webOS/Palm webOS 1.2.9; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pixi/1.0' => array(
- array('WO', 'Palm webOS', 'webOS', '1.0', '1', '0', 'webkit'),
- array('WOS', 'Palm webOS', 'webOS')),
- 'Mozilla/5.0 [en] (PalmOS; U; WebPro/3.5; Palm-Zi72)' => array(
- array('WP', 'WebPro', 'WebPro', '3.5', '3', '5', 'unknown'),
- array('POS', 'Palm OS', 'Palm OS')),
-
- // Palm WebPro
- 'Mozilla/4.76 [en] (PalmOS; U; WebPro/3.0.1a; Palm-Cct1)' => array(
- array('WP', 'WebPro', 'WebPro', '3.0', '3', '0', 'unknown'),
- array('POS', 'Palm OS', 'Palm OS')),
- 'Mozilla/4.76 [en] (PalmOS; U; WebPro/3.0; Palm-Arz1)' => array(
- array('WP', 'WebPro', 'WebPro', '3.0', '3', '0', 'unknown'),
- array('POS', 'Palm OS', 'Palm OS')),
-
- // Rekonq 1.0+
- 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) rekonq/1.0 Safari/534.34' => array(
- array('RK', 'Rekonq', 'Rekonq', '1.0', '1', '0', 'webkit'),
- array('LIN', 'Linux', 'Linux')),
-
- // Shiira 1.x - treat as Safari since it uses the installed version of Safari's WebKit
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/417.9 (KHTML, like Gecko, Safari) Shiira/1.1' => array(
- array('SF', 'Safari', 'Safari', '2.0', '2', '0', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
- 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; pl-pl) AppleWebKit/312.8 (KHTML, like Gecko) Shiira/1.2.1 Safari/125' => array(
- array('SF', 'Safari', 'Safari', '1.3', '1', '3', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
- // Shiira 2.x - ditto
- 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/525.28.3 (KHTML, like Gecko) Shiira Safari/125' => array(
- array('SF', 'Safari', 'Safari', '3.2', '3', '2', 'webkit'),
- array('MAC', 'Mac OS', 'Mac OS')),
-
- // SymbianOS
- 'Nokia3650/1.0 SymbianOS/6.1 Series60/1.2 Profile/MIDP-1.0 Configuration/CLDC-1.0' => array(
- false,
- array('SYM', 'SymbianOS', 'SymbianOS')),
- 'Mozilla/5.0 (SymbianOS/9.4; U; Series60/5.0 Nokia5800d-1b/20.2.014; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413' => array(
- array('SF', 'Safari', 'Safari', '2.0', '2', '0', 'webkit'),
- array('SYM', 'SymbianOS', 'SymbianOS')),
- 'Opera/9.80 (S60; SymbOS; Opera Mobi/499; U; en-GB) Presto/2.4.18 Version/10.00' => array(
- array('OP', 'Opera', 'Opera', '10.00', '10', '00', 'opera'),
- array('SYM', 'SymbianOS', 'SymbianOS')),
- 'SonyEricssonG700/R100 Mozilla/4.0 (compatible; MSIE 6.0; Symbian OS; 958) Opera 8.65 [ru]' => array(
- array('OP', 'Opera', 'Opera', '8.65', '8', '65', 'opera'),
- array('SYM', 'SymbianOS', 'SymbianOS')),
-
- // Appcelerator Titanium
- 'Appcelerator Titanium/1.8.0 (iPhone Simulator/4.3; iPhone OS; en_US;)' => array(
- array('TI', 'Titanium', 'Titanium', '1.8', '1', '8', 'webkit'),
- array('IPH', 'iPhone', 'iPhone')),
-
- 'Appcelerator Titanium/1.8.0 (iPod touch/4.3.1; iPhone OS; de_DE;)' => array(
- array('TI', 'Titanium', 'Titanium', '1.8', '1', '8', 'webkit'),
- array('IPD', 'iPod', 'iPod')),
-
- 'Appcelerator Titanium/1.8.0 (iPad/4.3.3; iPhone OS; de_DE;)' => array(
- array('TI', 'Titanium', 'Titanium', '1.8', '1', '8', 'webkit'),
- array('IPA', 'iPad', 'iPad')),
-
- 'Dalvik/1.1.0 (Linux; U; Android 2.1; google_sdk Build/ERD79) Titanium/1.8.0' => array(
- array('TI', 'Titanium', 'Titanium', '1.8', '1', '8', 'webkit'),
- array('AND', 'Android', 'Android')),
-
- 'Dalvik/1.4.0 (Linux; U; Android 2.3.3; GT-I9100 Build/GINGERBREAD) Titanium/1.8.0' => array(
- array('TI', 'Titanium', 'Titanium', '1.8', '1', '8', 'webkit'),
- array('AND', 'Android', 'Android')),
- );
-
- public function test_getBrowser()
- {
- foreach($this->userAgents as $userAgent => $expected)
- {
- $res = UserAgentParser::getBrowser($userAgent);
- $family = false;
-
- if($res === false)
- $ok = $res === $expected[0];
- else
- {
- $family = Piwik_getBrowserFamily($res['id']);
- $ok = $expected[0][0] == $res['id'] &&
- $expected[0][1] == $res['name'] &&
- $expected[0][2] == $res['short_name'] &&
- $expected[0][3] == $res['version'] &&
- $expected[0][4] == $res['major_number'] &&
- $expected[0][5] == $res['minor_number'] &&
- $expected[0][6] == $family;
- }
-
- $this->assertTrue($ok);
- if(!$ok)
- {
- var_dump(array($userAgent, $res, $family));
- }
- }
- }
-
- public function test_getOperatingSystem()
- {
- foreach($this->userAgents as $userAgent => $expected)
- {
- $res = UserAgentParser::getOperatingSystem($userAgent);
-
- $ok = $expected[1][0] == $res['id'] &&
- $expected[1][1] == $res['name'] &&
- $expected[1][2] == $res['short_name'];
-
- $this->assertTrue($ok);
- if(!$ok)
- {
- var_dump(array($userAgent, $res));
- }
- }
- }
-}
diff --git a/plugins/UsersManager/tests/UsersManager.test.php b/plugins/UsersManager/tests/UsersManager.test.php
deleted file mode 100644
index af3a6e6629..0000000000
--- a/plugins/UsersManager/tests/UsersManager.test.php
+++ /dev/null
@@ -1,985 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-require_once PIWIK_PATH_TEST_TO_ROOT . '/tests/core/Database.test.php';
-
-class Test_Piwik_UsersManager extends Test_Database
-{
- function __construct()
- {
- parent::__construct();
-
- Piwik_Config::getInstance()->setTestEnvironment();
- Piwik_PluginsManager::getInstance()->unloadPlugins();
- Piwik_PluginsManager::getInstance()->loadPlugins( array('LanguagesManager') );
- $plugin = Piwik_PluginsManager::getInstance()->getLoadedPlugin('LanguagesManager');
- $plugin->install();
- }
-
- function setUp()
- {
- parent::setUp();
-
- // setup the access layer
- $pseudoMockAccess = new FakeAccess;
- FakeAccess::setIdSitesView( array(1,2));
- FakeAccess::setIdSitesAdmin( array(3,4));
-
- //finally we set the user as a super user by default
- FakeAccess::$superUser = true;
- Zend_Registry::set('access', $pseudoMockAccess);
-
- // we make sure the tests don't depend on the config file content
- Piwik_Config::getInstance()->superuser = array(
- 'login'=>'superusertest',
- 'password'=>'passwordsuperusertest',
- 'email'=>'superuser@example.com'
- );
- }
-
- private function _flatten($sitesAccess)
- {
- $result = array();;
-
- foreach($sitesAccess as $siteAccess)
- {
- $result[ $siteAccess['site'] ] = $siteAccess['access'];
- }
- return $result;
- }
-
- private function _checkUserHasNotChanged($user, $newPassword, $newEmail = null, $newAlias= null)
- {
- if(is_null($newEmail))
- {
- $newEmail = $user['email'];
- }
- if(is_null($newAlias))
- {
- $newAlias = $user['alias'];
- }
- $userAfter = Piwik_UsersManager_API::getInstance()->getUser($user["login"]);
- unset($userAfter['date_registered']);
-
- // we now compute what the token auth should be, it should always be a hash of the login and the current password
- // if the password has changed then the token_auth has changed!
- $user['token_auth']= Piwik_UsersManager_API::getInstance()->getTokenAuth($user["login"], md5($newPassword) );
-
- $user['password']=md5($newPassword);
- $user['email']=$newEmail;
- $user['alias']=$newAlias;
- $this->assertEqual($user,$userAfter);
- }
-
- function test_all_superUserIncluded()
- {
- Piwik_Config::getInstance()->superuser = array(
- 'login'=>'superusertest',
- 'password'=>'passwordsuperusertest',
- 'email'=>'superuser@example.com'
- );
-
- $user = array( 'login'=>'user',
- 'password'=>"geqgeagae",
- 'email'=>"test@test.com",
- 'alias'=>"alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] );
-
- try {
- Piwik_UsersManager_API::getInstance()->addUser('superusertest','te','fake@fale.co','ega');
- $this->fail();
- } catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionSuperUser)", $expected->getMessage());
- }
- try {
- Piwik_UsersManager_API::getInstance()->updateUser('superusertest','te','fake@fale.co','ega');
- $this->fail();
- } catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionSuperUser)", $expected->getMessage());
- }
- try {
- Piwik_UsersManager_API::getInstance()->deleteUser('superusertest','te','fake@fale.co','ega');
- $this->fail();
- } catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionSuperUser)", $expected->getMessage());
- }
- try {
- Piwik_UsersManager_API::getInstance()->deleteUser('superusertest','te','fake@fale.co','ega');
- $this->fail();
- } catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionSuperUser)", $expected->getMessage());
- }
- $this->pass();
- }
- /**
- * bad password => exception
- */
- function test_updateUser_badpasswd()
- {
- $login="login";
- $user = array('login'=>$login,
- 'password'=>"geqgeagae",
- 'email'=>"test@test.com",
- 'alias'=>"alias");
-
- Piwik_UsersManager_API::getInstance()->addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] );
-
-
- try {
- Piwik_UsersManager_API::getInstance()->updateUser( $login, "pas");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionInvalidPassword)", $expected->getMessage());
-
- $this->_checkUserHasNotChanged($user,$user['password']);
- return;
- }
- $this->fail("Exception not raised.");
-
- }
-//} class test{
-
- /**
- * wrong login / integer => exception
- */
- function test_addUser_wrongLogin1()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser(12, "password", "email@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionInvalidLogin)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong login / too short => exception
- */
- function test_addUser_wrongLogin2()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("gegag'ggea'", "password", "email@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionInvalidLogin)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
- /**
- * wrong login / too long => exception
- */
- function test_addUser_wrongLogin3()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("gegag11gge&", "password", "email@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionInvalidLogin)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong login / bad characters => exception
- */
- function test_addUser_wrongLogin4()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("geg'ag11gge@", "password", "email@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionInvalidLogin)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * existing login => exception
- */
- function test_addUser_existingLogin()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("test", "password", "email@email.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("test", "password2", "em2ail@email.com", "al2ias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionLoginExists)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
-
- }
-
- /**
- * too short -> exception
- */
- function test_addUser_wrongPassword1()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "pas", "email@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionInvalidPassword)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
- /**
- * too long -> exception
- */
- function test_addUser_wrongPassword2()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("ghqgeggg", "gegageqqqqqqqgeqgqeg84897897897897g122", "email@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionInvalidPassword)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * empty -> exception
- */
- function test_addUser_wrongPassword3()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "", "email@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionInvalidPassword)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
- /**
- * wrong email => exception
- */
- function test_addUser_wrongEmail1()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "ema'il@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(mail)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong email => exception
- */
- function test_addUser_wrongEmail2()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "@email.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(mail)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
- /**
- * wrong email => exception
- */
- function test_addUser_wrongEmail3()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "email@.com", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(mail)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong email => exception
- */
- function test_addUser_wrongEmail4()
- {
- try {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "email@4.", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(mail)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * empty email => exception
- */
- function test_addUser_emptyEmail()
- {
-
- try {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "", "alias");
- }
- catch (Exception $expected) {
- $this->assertPattern("(mail)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * empty alias => use login
- */
- function test_addUser_emptyAlias()
- {
- $login ="geggeqgeqag";
- Piwik_UsersManager_API::getInstance()->addUser($login, "geqgeagae", "mgeagi@geq.com", "");
- $user = Piwik_UsersManager_API::getInstance()->getUser($login);
- $this->assertEqual($user['alias'], $login);
- $this->assertEqual($user['login'], $login);
-
- }
- /**
- * no alias => use login
- */
- function test_addUser_noAliasSpecified()
- {
- $login ="geggeqg455eqag";
- Piwik_UsersManager_API::getInstance()->addUser($login, "geqgeagae", "mgeagi@geq.com");
- $user = Piwik_UsersManager_API::getInstance()->getUser($login);
- $this->assertEqual($user['alias'], $login);
- $this->assertEqual($user['login'], $login);
-
- }
-
- /**
- * normal test case
- *
- */
- function test_addUser()
- {
- $login ="geggeq55eqag";
- $password = "mypassword";
- $email = "mgeag4544i@geq.com";
- $alias = "her is my alias )(&|\" '£%*(&%+))";
-
- $time = time();
- Piwik_UsersManager_API::getInstance()->addUser($login, $password, $email, $alias);
- $user = Piwik_UsersManager_API::getInstance()->getUser($login);
-
- // check that the date registered is correct
- $this->assertTrue( $time <= strtotime($user['date_registered']) && strtotime($user['date_registered']) <= time(),
- "the date_registered ".strtotime($user['date_registered'])." is different from the time() ". time());
- $this->assertTrue($user['date_registered'] <= time() );
-
- // check that token is 32 chars
- $this->assertEqual(strlen($user['password']), 32);
-
- // that the password has been md5
- $this->assertEqual($user['token_auth'], md5($login.md5($password)));
-
- // check that all fields are the same
- $this->assertEqual($user['login'], $login);
- $this->assertEqual($user['password'], md5($password));
- $this->assertEqual($user['email'], $email);
- $this->assertEqual($user['alias'], $alias);
-
- }
-
- /**
- * user doesnt exist => exception
- */
- function test_deleteUser_doesntExist()
- {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
-
- try {
- Piwik_UsersManager_API::getInstance()->deleteUser("geggeqggnew");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionDeleteDoesNotExist)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * empty name, doesnt exists =>exception
- */
- function test_deleteUser_emptyUser()
- {
- try {
- Piwik_UsersManager_API::getInstance()->deleteUser("");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionDeleteDoesNotExist)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * null user,, doesnt exists =>exception
- */
- function test_deleteUser_nullUser()
- {
- try {
- Piwik_UsersManager_API::getInstance()->deleteUser(null);
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionDeleteDoesNotExist)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * normal case, user deleted
- */
- function test_deleteUser()
- {
-
- //create the 3 websites
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1",array("http://piwik.net","http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2",array("http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org"));
-
- //add user and set some rights
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("geggeqgeqag", "view", array(1,2));
- Piwik_UsersManager_API::getInstance()->setUserAccess("geggeqgeqag", "admin", array(1,3));
-
- // check rights are set
- $this->assertNotEqual(Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("geggeqgeqag"), array());
-
- // delete the user
- Piwik_UsersManager_API::getInstance()->deleteUser("geggeqgeqag");
-
- // try to get it, it should raise an exception
- try {
- $user = Piwik_UsersManager_API::getInstance()->getUser("geggeqgeqag");
- $this->fail("Exception not raised.");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
- }
- // add the same user
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
-
- //checks access have been deleted
- //to do so we recreate the same user login and check if the rights are still there
- $this->assertEqual(Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("geggeqgeqag"), array());
-
- }
-
-
- /**
- * no user => exception
- */
- function test_getUser_noUser()
- {
- // try to get it, it should raise an exception
- try {
- $user = Piwik_UsersManager_API::getInstance()->getUser("geggeqgeqag");
- $this->fail("Exception not raised.");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
- }
- }
-
- /**
- * normal case
- */
- function test_getUser()
- {
- $login ="geggeq55eqag";
- $password = "mypassword";
- $email = "mgeag4544i@geq.com";
- $alias = "";
-
- Piwik_UsersManager_API::getInstance()->addUser($login, $password, $email, $alias);
- $user = Piwik_UsersManager_API::getInstance()->getUser($login);
-
- // check that all fields are the same
- $this->assertEqual($user['login'], $login);
- $this->assertIsA($user['password'], 'string');
- $this->assertIsA($user['date_registered'], 'string');
- $this->assertEqual($user['email'], $email);
-
- //alias shouldnt be empty even if no alias specified
- $this->assertTrue( strlen($user['alias']) > 0);
- }
-
-
- /**
- * no user => empty array
- */
- function test_getUsers_noUser()
- {
- $this->assertEqual(Piwik_UsersManager_API::getInstance()->getUsers(), array());
- }
-
- /**
- * normal case
- * as well as selecting specific user names, comma separated
- */
- function test_getUsers()
- {
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com");
-
- $users = Piwik_UsersManager_API::getInstance()->getUsers();
- $users = $this->removeNonTestableFieldsFromUsers($users);
- $user1 = array('login' => "gegg4564eqgeqag", 'password' => md5("geqgegagae"), 'alias' => "alias", 'email' => "tegst@tesgt.com");
- $user2 = array('login' => "geggeqge632ge56a4qag", 'password' => md5("geqgegeagae"),'alias' => "alias", 'email' => "tesggt@tesgt.com");
- $user3 = array('login' => "geggeqgeqagqegg", 'password' => md5("geqgeaggggae"), 'alias' => 'geggeqgeqagqegg','email' => "tesgggt@tesgt.com");
- $expectedUsers = array($user1, $user2, $user3);
- $this->assertEqual($users, $expectedUsers);
- $this->assertEqual( $this->removeNonTestableFieldsFromUsers(Piwik_UsersManager_API::getInstance()->getUsers('gegg4564eqgeqag')), array($user1));
- $this->assertEqual( $this->removeNonTestableFieldsFromUsers(Piwik_UsersManager_API::getInstance()->getUsers('gegg4564eqgeqag,geggeqge632ge56a4qag')), array($user1, $user2));
-
- }
-
- function removeNonTestableFieldsFromUsers($users)
- {
- foreach($users as &$user)
- {
- unset($user['token_auth']);
- unset($user['date_registered']);
- }
- return $users;
- }
-
- /**
- * normal case
- */
- function test_getUsersLogin()
- {
-
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com");
-
- $logins = Piwik_UsersManager_API::getInstance()->getUsersLogin();
-
- $this->assertEqual($logins,
- array( "gegg4564eqgeqag", "geggeqge632ge56a4qag", "geggeqgeqagqegg")
- );
- }
-
-
- /**
- * no login => exception
- */
- function test_setUserAccess_noLogin()
- {
- // try to get it, it should raise an exception
- try {
- Piwik_UsersManager_API::getInstance()->setUserAccess("nologin", "view", 1);
- $this->fail("Exception not raised.");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
- }
-
- }
-
- /**
- * wrong access specified => exception
- */
- function test_setUserAccess_wrongAccess()
- {
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
-
- // try to get it, it should raise an exception
- try {
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "viewnotknown", 1);
- $this->fail("Exception not raised.");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionAccessValues)", $expected->getMessage());
- }
- }
-
- /**
- * idsites = all => apply access to all websites with admin access
- */
- function test_setUserAccess_idsitesIsAll()
- {
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
-
- FakeAccess::$superUser = false;
-
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "all");
-
- FakeAccess::$superUser = true;
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
- $access = $this->_flatten($access);
-
- FakeAccess::$superUser = false;
- $this->assertEqual( array_keys($access), FakeAccess::getSitesIdWithAdminAccess());
-
- // we want to test the case for which we have actually set some rights
- // if this is not OK then change the setUp method and add some admin rights for some websites
- $this->assertTrue( count(array_keys($access)) > 0);
-
- }
-
- /**
- * idsites = all AND user is superuser=> apply access to all websites
- */
- function test_setUserAccess_idsitesIsAllSuperuser()
- {
- FakeAccess::$superUser = true;
-
- $id1=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
- $id2=Piwik_SitesManager_API::getInstance()->addSite("test2",array("http://piwik.net","http://piwik.com/test/"));
- $id3=Piwik_SitesManager_API::getInstance()->addSite("test3",array("http://piwik.net","http://piwik.com/test/"));
- $id4=Piwik_SitesManager_API::getInstance()->addSite("test4",array("http://piwik.net","http://piwik.com/test/"));
- $id5=Piwik_SitesManager_API::getInstance()->addSite("test5",array("http://piwik.net","http://piwik.com/test/"));
-
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "all");
-
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
- $access = $this->_flatten($access);
- $this->assertEqual( array($id1,$id2,$id3,$id4,$id5), array_keys($access));
-
- }
-
- /**
- * idsites is empty => no acccess set
- */
- function test_setUserAccess_idsitesEmpty()
- {
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
-
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array());
-
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
- $access = $this->_flatten($access);
- $this->assertEqual( array(), $access);
-
- }
-
- /**
- * normal case, access set for only one site
- */
- function test_setUserAccess_idsitesOneSite()
- {
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
-
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array(1));
-
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
- $access = $this->_flatten($access);
- $this->assertEqual( array(1), array_keys($access));
- }
-
- /**
- * normal case, access set for multiple sites
- */
- function test_setUserAccess_idsitesMultipleSites()
- {
-
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
- $id2=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
- $id3=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
-
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array($id1,$id3));
-
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
- $access = $this->_flatten($access);
- $this->assertEqual( array($id1,$id3), array_keys($access));
-
- }
- /**
- * normal case, string idSites comma separated access set for multiple sites
- */
- function test_setUserAccess_withIdSitesIsStringCommaSeparated()
- {
-
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
- $id2=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
- $id3=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
-
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "1,3");
-
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
- $access = $this->_flatten($access);
- $this->assertEqual( array($id1,$id3), array_keys($access));
- }
-
-
- /**
- * normal case, set different acccess to different websites for one user
- */
- function test_setUserAccess_multipleCallDistinctAccessSameUser()
- {
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
- $id2=Piwik_SitesManager_API::getInstance()->addSite("test",array("http://piwik.net","http://piwik.com/test/"));
-
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array($id1));
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "admin", array($id2));
-
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
- $access = $this->_flatten($access);
- $this->assertEqual( array($id1=>'view',$id2=>'admin'), $access);
- }
-
- /**
- * normal case, set different access to different websites for multiple users
- */
- function test_setUserAccess_multipleCallDistinctAccessMultipleUser()
- {
- Piwik_UsersManager_API::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
- $id1=Piwik_SitesManager_API::getInstance()->addSite("test1",array("http://piwik.net","http://piwik.com/test/"));
- $id2=Piwik_SitesManager_API::getInstance()->addSite("test2",array("http://piwik.net","http://piwik.com/test/"));
- $id3=Piwik_SitesManager_API::getInstance()->addSite("test2",array("http://piwik.net","http://piwik.com/test/"));
-
- Piwik_UsersManager_API::getInstance()->setUserAccess("user1", "view", array($id1,$id2));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user2", "admin", array($id1));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user2", "view", array($id3, $id2));
-
- $access1 = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("user1");
- $access1 = $this->_flatten($access1);
- $access2 = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("user2");
- $access2 = $this->_flatten($access2);
- $wanted1 = array( $id1 => 'view', $id2 => 'view', );
- $wanted2 = array( $id1 => 'admin', $id2 => 'view', $id3 => 'view' );
-
- $this->assertEqual($access1, $wanted1);
- $this->assertEqual($access2, $wanted2);
-
-
- $access1 = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite($id1);
- $access2 = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite($id2);
- $access3 = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite($id3);
- $wanted1 = array( 'user1' => 'view', 'user2' => 'admin', );
- $wanted2 = array( 'user1' => 'view', 'user2' => 'view' );
- $wanted3 = array( 'user2' => 'view' );
-
- $this->assertEqual($access1, $wanted1);
- $this->assertEqual($access2, $wanted2);
- $this->assertEqual($access3, $wanted3);
-
- $access1 = Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess('view');
- $access2 = Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess('admin');
- $wanted1 = array( 'user1' => array($id1,$id2), 'user2' => array($id2, $id3) );
- $wanted2 = array( 'user2' => array($id1) );
-
- $this->assertEqual($access1, $wanted1);
- $this->assertEqual($access2, $wanted2);
-
- // Test getUsersWithSiteAccess
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($id1, $access = 'view');
- $this->assertTrue(count($users) == 1 && $users[0]['login'] == 'user1');
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($id2, $access = 'view');
- $this->assertTrue(count($users) == 2);
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($id1, $access = 'admin');
- $this->assertTrue(count($users) == 1 && $users[0]['login'] == 'user2');
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($id3, $access = 'admin');
- $this->assertTrue(count($users) == 0);
- }
-
- /**
- * we set access for one user for one site several times and check that it is updated
- */
- function test_setUserAccess_multipleCallOverwriteSingleUserOneSite()
- {
- Piwik_UsersManager_API::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
-
- $id1=Piwik_SitesManager_API::getInstance()->addSite("test1",array("http://piwik.net","http://piwik.com/test/"));
- $id2=Piwik_SitesManager_API::getInstance()->addSite("test2",array("http://piwik.net","http://piwik.com/test/"));
-
- Piwik_UsersManager_API::getInstance()->setUserAccess("user1", "view", array($id1,$id2));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user1", "admin", array($id1));
-
- $access1 = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("user1");
- $access1 = $this->_flatten($access1);
- $wanted1 = array( $id1 => 'admin', $id2 => 'view', );
-
- $this->assertEqual($access1, $wanted1);
-
- }
-
-
- /**
- * wrong user =>exception
- */
- function test_getSitesAccessFromUser_wrongUser()
- {
- try {
- $access1 = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("user1");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- *wrong idsite =>exception
- */
- function test_getUsersAccessFromSite_wrongSite()
- {
- try {
- $access1 = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite(1);
- }
- catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * wrong access =>exception
- */
- function test_getUsersSitesFromAccess_wrongSite()
- {
- try {
- $access1 = Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess('unknown');
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionAccessValues)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
-
- /**
- * non existing login => exception
- */
- function test_updateUser_wrongLogin()
- {
- try {
- Piwik_UsersManager_API::getInstance()->updateUser( "lolgin", "password");
- }
- catch (Exception $expected) {
- $this->assertPattern("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
- return;
- }
- $this->fail("Exception not raised.");
- }
-
-
- /**
- * no email no alias => keep old ones
- */
- function test_updateUser_noemailnoalias()
- {
- $login="login";
- $user = array('login'=>$login,
- 'password'=>"geqgeagae",
- 'email'=>"test@test.com",
- 'alias'=>"alias");
-
- Piwik_UsersManager_API::getInstance()->addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] );
-
- Piwik_UsersManager_API::getInstance()->updateUser( $login, "passowordOK");
-
- $this->_checkUserHasNotChanged($user, "passowordOK");
- }
-
- /**
- *no email => keep old ones
- */
- function test_updateUser_noemail()
- {
-
- $login="login";
- $user = array('login'=>$login,
- 'password'=>"geqgeagae",
- 'email'=>"test@test.com",
- 'alias'=>"alias");
-
- Piwik_UsersManager_API::getInstance()->addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] );
-
- Piwik_UsersManager_API::getInstance()->updateUser( $login, "passowordOK", null, "newalias");
-
- $this->_checkUserHasNotChanged($user, "passowordOK", null, "newalias");
- }
-
- /**
- * no alias => keep old ones
- */
- function test_updateUser_noalias()
- {
-
- $login="login";
- $user = array('login'=>$login,
- 'password'=>"geqgeagae",
- 'email'=>"test@test.com",
- 'alias'=>"alias");
-
- Piwik_UsersManager_API::getInstance()->addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] );
-
- Piwik_UsersManager_API::getInstance()->updateUser( $login, "passowordOK", "email@geaga.com");
-
- $this->_checkUserHasNotChanged($user, "passowordOK", "email@geaga.com");
- }
-
- /**
- * check to modify as the user
- */
- function test_updateUser_IAmTheUser()
- {
- FakeAccess::$identity = 'login';
- $this->test_updateUser_noemailnoalias();
-
- }
- /**
- * check to modify as being another user => exception
- */
- function test_updateUser_IAmNOTTheUser()
- {
-
- FakeAccess::$identity = 'login2';
- FakeAccess::$superUser = false;
- try{
- $this->test_updateUser_noemailnoalias();
-
- }catch (Exception $expected) {
- return;
- }
- $this->fail("Exception not raised.");
- }
-
- /**
- * normal case, reused in other tests
- */
- function test_updateUser()
- {
-
- $login="login";
- $user = array('login'=>$login,
- 'password'=>"geqgeagae",
- 'email'=>"test@test.com",
- 'alias'=>"alias");
-
- Piwik_UsersManager_API::getInstance()->addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] );
-
- Piwik_UsersManager_API::getInstance()->updateUser( $login, "passowordOK", "email@geaga.com", "NEW ALIAS");
-
- $this->_checkUserHasNotChanged($user, "passowordOK", "email@geaga.com", "NEW ALIAS");
- }
-
-}