public function test_getCachedCustomDimensions_shouldReturnDimensionsForSiteButOnlyActiveOnes()
 {
     $this->configureSomeDimensions();
     $request = new Request(array('idsite' => 1));
     $dimensions = Processor::getCachedCustomDimensions($request);
     $this->assertCount(5, $dimensions);
     foreach ($dimensions as $dimension) {
         $this->assertSame('1', $dimension['idsite']);
         $this->assertTrue($dimension['active']);
         $this->assertStringStartsWith('MyName', $dimension['name']);
     }
     $request = new Request(array('idsite' => 2));
     $dimensions = Processor::getCachedCustomDimensions($request);
     $this->assertCount(1, $dimensions);
 }
 public function addConversionInformation(&$conversion, $visitInformation, Tracker\Request $request)
 {
     $dimensions = CustomDimensionsRequestProcessor::getCachedCustomDimensions($request);
     // we copy all visit custom dimensions, but only if the index also exists in the conversion table
     // to not fail while conversion custom dimensions are added
     $conversionIndexes = $this->getCachedInstalledIndexesForScope(self::SCOPE_CONVERSION);
     $conversionIndexes = array_map(function ($index) {
         return (int) $index;
         // make sure we work with integers
     }, $conversionIndexes);
     foreach ($dimensions as $dimension) {
         $index = (int) $dimension['index'];
         if ($dimension['scope'] === self::SCOPE_VISIT && in_array($index, $conversionIndexes)) {
             $field = LogTable::buildCustomDimensionColumnName($dimension);
             if (array_key_exists($field, $visitInformation)) {
                 $conversion[$field] = $visitInformation[$field];
             }
         }
     }
 }