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

MultiSitesTest.php « Plugins « PHPUnit « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 63d952c8a67caafd9328f3607694db17635a0d1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

use Piwik\Access;

class MultiSitesTest extends DatabaseTestCase
{
    protected $idSiteAccess;

    public function setUp()
    {
        parent::setUp();

        $access = Access::getInstance();
        $access->setSuperUser(true);

        $this->idSiteAccess = Piwik_SitesManager_API::getInstance()->addSite("test", "http://test");

        \Piwik\PluginsManager::getInstance()->loadPlugins(array('MultiSites', 'VisitsSummary', 'Actions'));
        \Piwik\PluginsManager::getInstance()->installLoadedPlugins();
    }


    /**
     * Testing that getOne returns a row even when there are no data
     * This is necessary otherwise Piwik_API_ResponseBuilder throws 'Call to a member function getColumns() on a non-object'
     *
     * @group Plugins
     * @group MultiSites
     */
    public function testWhenNoDataGetOneReturnsRow()
    {
        $dataTable = Piwik_MultiSites_API::getInstance()->getOne($this->idSiteAccess, 'month', '01-01-2010');
        $this->assertEquals(1, $dataTable->getRowsCount());

        // safety net
        $this->assertEquals(0, $dataTable->getFirstRow()->getColumn('nb_visits'));
    }
}