/** * Load stats * * @param EventInterface $event An event instance */ public function loadStats(EventInterface $event) { $response = $event->getResponse(); $database = $event->getDatabase(); $userLookup = $event->getUserLookup(); $publicKeys = $userLookup->getPublicKeys(); $users = array(); foreach ($publicKeys as $key) { $users[$key] = array('numImages' => $database->getNumImages($key), 'numBytes' => $database->getNumBytes($key)); } $statsModel = new Model\Stats(); $statsModel->setUsers($users); $response->setModel($statsModel); }
/** * @dataProvider getUsers * @covers Imbo\Model\Stats::getNumBytes */ public function testCanGetTotalAmountOfBytes(array $users, $numUsers, $images, $bytes) { $this->model->setUsers($users); $this->assertSame($bytes, $this->model->getNumBytes()); }