public function testGetSetError() { $file = new FileUpload(); $this->assertEquals(UPLOAD_ERR_OK, $file->getError(), 'Default is ERR_OK'); $this->assertFalse($file->hasError(), 'ERR_OK is not an error'); $this->assertEquals($file, $file->setError(UPLOAD_ERR_INI_SIZE), 'Fluent API'); $this->assertEquals(UPLOAD_ERR_INI_SIZE, $file->getError()); $this->assertTrue($file->hasError()); }
$userManager = new ManageUser($db); $sesion = new Session(); $email = Request::post("email"); $newemail = Request::post("newemail"); $pass = Request::post("pass"); $alive = Request::post("alive"); $worker = Request::post("worker"); $admin = Request::post("admin"); $newemail = $newemail === null ? $email : $newemail; $alive = $alive === null ? 0 : 1; $worker = $worker === null ? 0 : 1; $admin = $admin === null ? 0 : 1; $usuario = $userManager->get($email); $usuario->setEmail($newemail); $usuario->setAlias(explode("@", $newemail)[0]); $usuario->setAlive($alive); $usuario->setWorker($worker); $usuario->setAdmin($admin); if ($pass !== null) { $usuario->setPass($pass); } $photo = new FileUpload("image"); if ($photo->getError() === false) { $usuario->setImage("images/" . $usuario->getAlias() . ".jpg"); $photo->setDestination("../images/"); $photo->setName($usuario->getAlias()); echo $photo->upload(); } $userManager->setEmail($usuario, $email); $sesion->destroy(); $sesion->sendRedirect("../admin.php");
private static function insertArt() { $sesion = new Session(); if ($sesion->isLogged()) { $db = new DataBase(); $manager = new ManageArt($db); $managerUser = new ManageUser($db); $email = Request::post("email"); $title = Request::post("title"); $usuario = $managerUser->get($email); $art = new Art(); $art->setEmail($email); $art->setTitle($title); $art->setCdate(date('Y-m-d G:i:s')); $fecha = date('_Y_m_d_G_i_s'); $photo = new FileUpload("image"); if ($photo->getError() === false) { $art->setImage("./resources/art/" . $usuario->getAlias() . $fecha . ".jpg"); $photo->setDestination("./resources/art/"); $photo->setName($usuario->getAlias() . $fecha); $photo->upload(); } $manager->insert($art); $db->close(); } self::viewProfile(); }