Ejemplo n.º 1
0
 public function test_addManyCustomDimensions_shouldAddNewColumns()
 {
     // should add nothing as not a valid index
     $this->logVisit->addManyCustomDimensions(0);
     $this->logVisit->addManyCustomDimensions(null);
     $this->assertSame(range(1, 5), $this->logVisit->getInstalledIndexes());
     $this->logVisit->addManyCustomDimensions(1);
     $this->assertSame(range(1, 6), $this->logVisit->getInstalledIndexes());
     $this->logVisit->addManyCustomDimensions(4);
     $this->assertSame(range(1, 10), $this->logVisit->getInstalledIndexes());
     // should automatically add after highest index if some indexes are missing in between
     $this->logVisit->removeCustomDimension('8');
     $this->logVisit->removeCustomDimension('2');
     $this->logVisit->removeCustomDimension('1');
     $this->logVisit->addManyCustomDimensions(2);
     $this->assertSame(array(3, 4, 5, 6, 7, 9, 10, 11, 12), $this->logVisit->getInstalledIndexes());
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $scope = $this->getScope($input);
     $count = $this->getCount($input);
     $output->writeln(sprintf('Adding %d Custom Dimension(s) in scope %s.', $count, $scope));
     $output->writeln('<info>This causes schema changes in the database and may take a very long time.</info>');
     $noInteraction = $input->getOption('no-interaction');
     if (!$noInteraction && !$this->confirmChange($output)) {
         return;
     }
     $output->writeln('');
     $output->writeln('Starting to add Custom Dimension(s)');
     $output->writeln('');
     $tracking = new LogTable($scope);
     $tracking->addManyCustomDimensions($count);
     if ($scope === CustomDimensions::SCOPE_VISIT) {
         $tracking = new LogTable(CustomDimensions::SCOPE_CONVERSION);
         $tracking->addManyCustomDimensions($count);
     }
     Cache::clearCacheGeneral();
     $numDimensionsAvailable = $tracking->getNumInstalledIndexes();
     $this->writeSuccessMessage($output, array(sprintf('Your Piwik is now configured for up to %d Custom Dimensions in scope %s.', $numDimensionsAvailable, $scope)));
 }