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]); }
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']); }
public function testQuery() { $query = $this->instance->query('browser', 10, DateHelper::today()); $this->assertInstanceOf('Webiny\\AnalyticsDb\\Query', $query); }
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()); }