public function testSetDatetime() { $m = new ae_MediaModel(); $m->setDatetime('2014-10-19 23:34:00'); $this->assertEquals($m->getDatetime(), '2014-10-19 23:34:00'); $this->assertEquals($m->getDatetime('Y H:i'), '2014 23:34'); $this->setExpectedException('Exception'); $m->setDatetime('2014-10-19'); }
/** * Constructor. * @param {array} $files Uploaded file(s). */ public function __construct($files) { $numItems = count($files['tmp_name']); for ($i = 0; $i < $numItems; $i++) { $error = $files['error'][$i]; // File input in form for which no file has been selected if ($error == UPLOAD_ERR_NO_FILE) { continue; } // Something actually went wrong with an upload if ($error != UPLOAD_ERR_OK) { $msg = sprintf('[%s] Upload error for file <code>%s</code>: %s', get_class(), htmlspecialchars($files['name'][$i]), self::getUploadErrorString($error)); ae_Log::error($msg); $json = str_replace('\\/', '/', json_encode($files)); ae_Log::debug('File ' . $i . ': ' . $json); continue; } $type = self::getMIMEType($files['tmp_name'][$i], $files['type'][$i]); $m = new ae_MediaModel(); $m->setName($files['name'][$i]); $m->setTmpName($files['tmp_name'][$i]); $m->setDatetime(date('Y-m-d H:i:s')); $m->setType($type); $m->setUserId(ae_Security::getCurrentUserId()); $m->setStatus(ae_MediaModel::STATUS_AVAILABLE); $m->setMetaInfo(self::getMetaInfo($m)); $this->items[] = $m; } }