/** @test */ public function can_verify_if_has_image() { $this->assertFalse($this->model->hasImage()); $this->model->addImage($this->uploaded_file); $this->assertTrue($this->model->hasImage()); $this->model->deleteImage(); }
public function image_file_overides_old_files_when_relationship_is_added_again() { $this->model->addImage($this->uploaded_file); $image = $this->model->getImage(); $firstFilePath = $image->getPath('original_style'); $wasWrittenFirstTime = $this->filemanager->pathExists($firstFilePath); $this->assertTrue($wasWrittenFirstTime); $firstFilePathOtherStyle = $image->getPath('original_style2'); $wasWrittenFirstTimeOtherStyle = $this->filemanager->pathExists($firstFilePathOtherStyle); $this->assertTrue($wasWrittenFirstTimeOtherStyle); $this->model->addImage($this->uploaded_file_2); $image = $this->model->getImage(); $secondFilePath = $image->getPath('original_style'); $secondFilePathOtherStyle = $image->getPath('original_style2'); $wasWrittenSecondTime = $this->filemanager->pathExists($secondFilePath); $wasWrittenSecondTimeOtherStyle = $this->filemanager->pathExists($secondFilePathOtherStyle); $this->assertNotEquals($firstFilePath, $image->getPath('original_style')); $this->assertNotEquals($firstFilePathOtherStyle, $image->getPath('original_style2')); $this->assertTrue($wasWrittenSecondTime); $this->assertTrue($wasWrittenSecondTimeOtherStyle); $this->model->deleteImage(); }
sendResponse(400, json_encode($response)); return false; } //Insert image into bucket $result = $client->putObject(array( 'Bucket' => $cdimageBucket['Name'], 'Key' => "/img/".$newFileNameWithExt, 'SourceFile' => $_FILES['file']['tmp_name'] )); // We can poll the object until it is accessible $client->waitUntil('ObjectExists', array( 'Bucket' => $cdimageBucket['Name'], 'Key' => "/img/".$newFileNameWithExt )); $Image->create($newFileNameWithExt); //Update the user's image $User->deleteImage(); $User->setImage($Image->ID); //Set the status to 1 (success) $response['meta']['status'] = 1; $response['data']['imageURL'] = $signedURL; //Send the response sendResponse(200, json_encode($response)); return true; ?>
} break; case 'sendNewPassword': $user = new user($_POST['values']['clientId']); $newPassword = $user->generateRandomPassword(); $loginCredentials = $user->createPassword($newPassword); if ($loginCredentials['success'] === 1) { $result = mailer::sendNewPasswordMail($user, $newPassword); if ($result === true) { $user->set('salt', $loginCredentials['salt']); $user->set('password', $loginCredentials['password']); $user->save(); echo json_encode(array('status' => 'correct', 'msg' => Texter::get('client|sendNewPassword'))); } else { echo json_encode(array('status' => Texter::get('client|sendNewPasswordfail'))); } } break; case 'deleteImage': $user = new User($_SESSION['user_id']); if ($user->deleteImage($_POST['values']['dataId']) === true) { echo json_encode(array('success' => 1, 'dataId' => $_POST['values']['dataId'])); } else { echo json_encode(array('success' => 0, 'msg' => 'test')); } break; default: echo json_encode(array('errmsg' => Texter::get('system|unknownRequest', array($_POST['module'])))); break; } //end switch