Пример #1
0
 /**
  * Query the dimensions.
  *
  * @param string $name  Dimension name
  * @param string $value Dimension value
  *
  * @return Query\Dimensions
  */
 public function dimension($name = null, $value = null)
 {
     $query = new Query\Dimensions($this->mongo, $this->entity, $this->ref, $this->dateRange);
     if (!empty($name)) {
         if (!empty($value)) {
             $query->setDimension($name, $value);
         } else {
             $query->setDimension($name);
         }
     }
     return $query;
 }
Пример #2
0
 public function testSetDimension()
 {
     $pipeline = $this->instance->getPipeline();
     $this->assertTrue(!isset($pipeline[0]['$match']['name']));
     $this->assertTrue(!isset($pipeline[0]['$match']['value']));
     $this->instance->setDimension('browser');
     $pipeline = $this->instance->getPipeline();
     $this->assertSame('browser', $pipeline[0]['$match']['name']);
     $this->assertTrue(!isset($pipeline[0]['$match']['value']));
     $this->instance->setDimension('browser', 'fireWolf');
     $pipeline = $this->instance->getPipeline();
     $this->assertSame('browser', $pipeline[0]['$match']['name']);
     $this->assertSame('fireWolf', $pipeline[0]['$match']['value']);
 }