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:
authordiosmosis <benaka@piwik.pro>2015-07-13 02:31:17 +0300
committerdiosmosis <benaka@piwik.pro>2015-07-13 02:39:49 +0300
commitb94545320472fac30051e7e102a7c1a1eacafa6f (patch)
tree9476a6912ffa41836ef3c2b4ca0404917116efe4 /tests/PHPUnit/System/ExternalScriptsTest.php
parent96f3fb29d61757eabee90dec3646244b6852df70 (diff)
Refs #8311, add automated system test for the api_internal_call.php example script. Includes new proxy script that will call another script using Piwik's test environment, but w/o actually setting up the test env.
Diffstat (limited to 'tests/PHPUnit/System/ExternalScriptsTest.php')
-rw-r--r--tests/PHPUnit/System/ExternalScriptsTest.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/PHPUnit/System/ExternalScriptsTest.php b/tests/PHPUnit/System/ExternalScriptsTest.php
new file mode 100644
index 0000000000..950f2bb9e6
--- /dev/null
+++ b/tests/PHPUnit/System/ExternalScriptsTest.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Tests\System;
+
+use Piwik\DbHelper;
+use Piwik\Tests\Framework\Fixture;
+use Piwik\Tests\Framework\TestCase\SystemTestCase;
+
+class ExternalScriptsTest extends SystemTestCase
+{
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+
+ DbHelper::createAnonymousUser();
+
+ // the api_internal_call.php uses idSite=7, so we create 7 sites
+ for ($i = 0; $i != 7; ++$i) {
+ Fixture::createWebsite("2011-01-01 00:00:00", $ecommerce = 1, $siteName = "Site #$i");
+ }
+
+ // the script uses anonymous token auth, so give the anonymous user access
+ \Piwik\Plugins\UsersManager\API::getInstance()->setUserAccess('anonymous', 'view', array(7));
+ }
+
+ public function test_ApiInternalCallScript_ExecutesCorrectly()
+ {
+ $output = $this->executeApiInternalCall();
+ $expectedFileOutput = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<result />";
+ $this->assertEquals($expectedFileOutput, $output);
+ }
+
+ private function executeApiInternalCall()
+ {
+ $proxyIncludeScript = PIWIK_INCLUDE_PATH . '/tests/PHPUnit/proxy/include_single_file.php';
+ $apiInternalCallScript = PIWIK_INCLUDE_PATH . '/misc/others/api_internal_call.php';
+
+ $command = "php '$proxyIncludeScript' '$apiInternalCallScript' 2>&1";
+ return shell_exec($command);
+ }
+}