public function testSetGetTimestamp() { $this->assertSame(strtotime(date('Y-m-d')), $this->instance->getTimestamp()['ts']); $this->assertSame(date('n'), $this->instance->getTimestamp()['month']); $this->assertSame(date('Y'), $this->instance->getTimestamp()['year']); $this->assertSame(strtotime(date('Y-m-01')), $this->instance->getTimestamp()['monthTs']); $ts = time() - 86400 * 90; $this->instance->setTimestamp($ts); $this->assertSame(strtotime(date('Y-m-d', $ts)), $this->instance->getTimestamp()['ts']); $this->assertSame(date('n', $ts), $this->instance->getTimestamp()['month']); $this->assertSame(date('Y', $ts), $this->instance->getTimestamp()['year']); $this->assertSame(strtotime(date('Y-m-01', $ts)), $this->instance->getTimestamp()['monthTs']); }
/** * Set the timestamp for the analytics db, otherwise use the current timestamp. * * @param int $time Unix timestamp. */ public function setTimestamp($time) { $this->analyticsDb->setTimestamp((int) $time); }