/**
  * Save a storage usage entity to the database
  *
  * @param StorageUsage $usage
  * @return boolean
  */
 public function save(StorageUsage $usage)
 {
     $query = $this->db->prepareQuery('INSERT INTO *PREFIX*uc_storageusage (created, username, `usage`, maximumusage) VALUES (?,?,?,?)');
     $result = $query->execute(array($usage->getDate()->format('Y-m-d H:i:s'), $usage->getUsername(), $usage->getUsage(), $usage->getMaximumUsage()));
     /*
      * $query->execute could return integer or OC_DB_StatementWrapper or false
      * I am expecting an integer with number 1
      */
     if (is_int($result) && $result === 1) {
         return true;
     }
     return false;
 }
 public function testFromRow()
 {
     $row = array('usage' => 124124124, 'created' => $this->date->format('Y-m-d H:i:s'), 'username' => 'test1', 'maximumusage' => 10245123345);
     $storage = StorageUsage::fromRow($row);
     $this->assertInstanceOf('OCA\\ocUsageCharts\\Entity\\Storage\\StorageUsage', $storage);
     $this->assertEquals(124124124, $storage->getUsage());
     $this->assertEquals($this->date, $storage->getDate());
     $this->assertEquals('test1', $storage->getUsername());
 }
 /**
  * @param StorageUsage $storageUsage
  * @return Storage
  */
 private function mapStorageUsageToStorageInformation(StorageUsage $storageUsage)
 {
     return new Storage($storageUsage->getUsage(), $storageUsage->getUsername(), $storageUsage->getMaximumUsage());
 }