قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-22 15:07:44 +00:00

* Disable autosanitize for MultiSites API * Add proper type hints accross MultiSites plugin * cs/ws * Replace Common::getRequestVar with Request class methods * some more type hints * simplify table filter * updates expected UI test file * clean up more code & bring code to phpstan lvl 5 * Add tooltips to table header * small code improvements
79 خطوط
2.2 KiB
PHP
79 خطوط
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Matomo - free/libre analytics platform
|
|
*
|
|
* @link https://matomo.org
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
|
*/
|
|
|
|
namespace Piwik\Plugins\MultiSites\tests\Integration;
|
|
|
|
use Piwik\Access;
|
|
use Piwik\FrontController;
|
|
use Piwik\Plugins\MultiSites\API as APIMultiSites;
|
|
use Piwik\Plugins\SitesManager\API as APISitesManager;
|
|
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
|
|
|
|
/**
|
|
* Class Plugins_MultiSitesTest
|
|
*
|
|
* @group Plugins
|
|
*/
|
|
class MultiSitesTest extends IntegrationTestCase
|
|
{
|
|
protected $idSiteAccess;
|
|
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$access = Access::getInstance();
|
|
$access->setSuperUserAccess(true);
|
|
|
|
$this->idSiteAccess = APISitesManager::getInstance()->addSite("test", "http://test");
|
|
|
|
\Piwik\Plugin\Manager::getInstance()->loadPlugins(['MultiSites', 'VisitsSummary', 'Actions']);
|
|
\Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
|
|
}
|
|
|
|
/**
|
|
* Testing that getOne returns a row even when there are no data
|
|
* This is necessary otherwise ResponseBuilder throws 'Call to a member function getColumns() on a non-object'
|
|
*
|
|
* @group Plugins
|
|
*/
|
|
public function testWhenNoDataGetOneReturnsRow()
|
|
{
|
|
$dataTable = APIMultiSites::getInstance()->getOne($this->idSiteAccess, 'month', '01-01-2010');
|
|
$this->assertEquals(1, $dataTable->getRowsCount());
|
|
|
|
// safety net
|
|
$this->assertEquals(0, $dataTable->getFirstRow()->getColumn('nb_visits'));
|
|
}
|
|
|
|
/**
|
|
* Testing that getOne does not error out when format=rss, #10407
|
|
*
|
|
* @group Plugins
|
|
*/
|
|
public function testWhenRssFormatGetOneDoesNotError()
|
|
{
|
|
$_GET = [
|
|
'method' => 'MultiSites.getOne',
|
|
'idSite' => $this->idSiteAccess,
|
|
'period' => 'month',
|
|
'date' => 'last10',
|
|
'format' => 'rss'
|
|
];
|
|
|
|
$output = FrontController::getInstance()->fetchDispatch('API');
|
|
|
|
self::assertStringContainsString('<item>', $output);
|
|
self::assertStringContainsString('</rss>', $output);
|
|
self::assertStringNotContainsString('error', $output);
|
|
|
|
$_GET = [];
|
|
}
|
|
}
|