Exemplo n.º 1
0
 public function testToday()
 {
     $result = DateHelper::today();
     $this->assertTrue(is_array($result));
     $date = strtotime(date('Y-m-d'));
     $this->assertSame($date, $result[0]);
     $this->assertSame($date, $result[1]);
 }
Exemplo n.º 2
0
 public function testConstructor()
 {
     $this->assertInstanceOf('Webiny\\AnalyticsDb\\Query\\Dimensions', $this->instance);
     $pipeline = $this->instance->getPipeline();
     // test $match
     $ts = DateHelper::today();
     $defaultMatch = ['entity' => 'browser', 'ts' => ['$gte' => $ts[0], '$lte' => $ts[1]]];
     $this->assertSame($defaultMatch, $pipeline[0]['$match']);
     // test $project
     $defaultProject = ['ts' => 1, 'entity' => 1, 'month' => 1, 'year' => 1, 'name' => 1, 'value' => 1, 'total' => 1, 'count.100' => 1];
     $this->assertSame($defaultProject, $pipeline[1]['$project']);
 }
Exemplo n.º 3
0
 public function testQuery()
 {
     $query = $this->instance->query('browser', 10, DateHelper::today());
     $this->assertInstanceOf('Webiny\\AnalyticsDb\\Query', $query);
 }
Exemplo n.º 4
0
 public function setUp()
 {
     \Webiny\Component\Mongo\Mongo::setConfig(new ConfigObject(['Driver' => 'Webiny\\AnalyticsDb\\Test\\MongoDriverMock']));
     $this->instance = new Query(new Mongo('localhost', 'testDb'), 'browser', 100, DateHelper::today());
 }