Ejemplo n.º 1
0
 public function test_getAllKnownUrlsForAllSites_shouldReturnAllUrls()
 {
     $idSite = $this->createMeasurable('website', 'http://apache.piwik');
     $this->model->insertSiteUrl($idSite, 'http://example.apache.piwik');
     $this->model->insertSiteUrl($idSite, 'http://example.org');
     $idSite2 = $this->createMeasurable('website');
     $this->model->insertSiteUrl($idSite2, 'http://example.org');
     $this->model->insertSiteUrl($idSite2, 'http://example.com');
     $idSite3 = $this->createMeasurable('website', 'http://example.pro');
     $expected = array(array('idsite' => $idSite, 'url' => 'http://apache.piwik'), array('idsite' => $idSite2, 'url' => 'http://piwik.net'), array('idsite' => $idSite3, 'url' => 'http://example.pro'), array('idsite' => $idSite, 'url' => 'http://example.apache.piwik'), array('idsite' => $idSite, 'url' => 'http://example.org'), array('idsite' => $idSite2, 'url' => 'http://example.com'), array('idsite' => $idSite2, 'url' => 'http://example.org'));
     $this->assertEquals($expected, $this->model->getAllKnownUrlsForAllSites());
 }
Ejemplo n.º 2
0
 public function getAllSiteUrls()
 {
     $model = new Model();
     $siteUrls = $model->getAllKnownUrlsForAllSites();
     if (empty($siteUrls)) {
         return array();
     }
     $urls = array();
     foreach ($siteUrls as $siteUrl) {
         $siteId = (int) $siteUrl['idsite'];
         if (!isset($urls[$siteId])) {
             $urls[$siteId] = array();
         }
         $urls[$siteId][] = $siteUrl['url'];
     }
     return $urls;
 }