Esempio n. 1
0
 /**
  * @group Plugins
  */
 public function test_AddAndGet_AnotherSegment()
 {
     $name = 'name';
     $definition = 'searches>1,visitIp!=127.0.0.1';
     $idSegment = API::getInstance()->add($name, $definition, $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
     $this->assertEquals($idSegment, 1);
     // Testing get()
     $segment = API::getInstance()->get($idSegment);
     $expected = array('idsegment' => '1', 'name' => $name, 'definition' => $definition, 'login' => 'superUserLogin', 'enable_all_users' => '1', 'enable_only_idsite' => '1', 'auto_archive' => '1', 'ts_last_edit' => null, 'deleted' => '0');
     unset($segment['ts_created']);
     $this->assertEquals($segment, $expected);
     // There is a segment to process for this particular site
     $model = new Model();
     $segments = $model->getSegmentsToAutoArchive($idSite);
     unset($segments[0]['ts_created']);
     $this->assertEquals($segments, array($expected));
     // There is no segment to process for a non existing site
     try {
         $segments = $model->getSegmentsToAutoArchive(33);
         $this->fail();
     } catch (Exception $e) {
         // expected
     }
     // There is no segment to process across all sites
     $segments = $model->getSegmentsToAutoArchive($idSite = false);
     $this->assertEquals($segments, array());
 }
Esempio n. 2
0
 /**
  * Adds the pre-processed segments to the list of Segments.
  * Used by CronArchive, ArchiveProcessor\Rules, etc.
  *
  * @param $segments
  * @param $idSite
  */
 public function getKnownSegmentsToArchiveForSite(&$segments, $idSite)
 {
     $model = new Model();
     $segmentToAutoArchive = $model->getSegmentsToAutoArchive($idSite);
     foreach ($segmentToAutoArchive as $segmentInfo) {
         $segments[] = $segmentInfo['definition'];
     }
     $segments = array_unique($segments);
 }