本文整理汇总了PHP中FileHandler::SetFileUploader方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHandler::SetFileUploader方法的具体用法?PHP FileHandler::SetFileUploader怎么用?PHP FileHandler::SetFileUploader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHandler
的用法示例。
在下文中一共展示了FileHandler::SetFileUploader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createProblem
/**
*
*/
public static function createProblem($zipName = null, $title = null, $public = 1, Users $author = null, $languages = null)
{
if (is_null($zipName)) {
$zipName = OMEGAUP_RESOURCES_ROOT . 'testproblem.zip';
}
// Get a user
$problemData = self::getRequest($zipName, $title, $public, $author, $languages);
$r = $problemData["request"];
$problemAuthor = $problemData["author"];
// Login user
$r["auth_token"] = OmegaupTestCase::login($problemAuthor);
// Get File Uploader Mock and tell Omegaup API to use it
FileHandler::SetFileUploader(new FileUploaderMock());
// Call the API
ProblemController::apiCreate($r);
// Clean up our mess
unset($_REQUEST);
return array("request" => $r, "author" => $problemAuthor);
}
示例2: testCreateProblemMissingOutput
/**
* Basic test for uploadin problem missing outputs
*
* @expectedException InvalidParameterException
*/
public function testCreateProblemMissingOutput()
{
// Get the problem data
$problemData = ProblemsFactory::getRequest(OMEGAUP_RESOURCES_ROOT . 'missingout.zip');
$r = $problemData['request'];
$problemAuthor = $problemData['author'];
// Login user
$r['auth_token'] = $this->login($problemAuthor);
// Get File Uploader Mock and tell Omegaup API to use it
FileHandler::SetFileUploader($this->createFileUploaderMock());
// Call the API
$response = ProblemController::apiCreate($r);
}
示例3: testUpdateProblemFailed
/**
* Tests update problem: on error, original contents should persist
*/
public function testUpdateProblemFailed()
{
// Get a problem
$problemData = ProblemsFactory::createProblem();
// Get File Uploader Mock and tell Omegaup API to use it
FileHandler::SetFileUploader($this->createFileUploaderMock());
// Update Problem calls grader to rejudge, we need to detour grader calls
// We will submit 2 runs to the problem, so we can expect 2 calls to grader
// to rejudge them
$this->detourGraderCalls($this->exactly(0));
// Prepare request
$r = new Request();
$r['title'] = 'new title';
$r['time_limit'] = 12345;
$r['problem_alias'] = $problemData['request']['alias'];
$r['message'] = 'This shoudl fail';
// Set file upload context. This problem should fail
$_FILES['problem_contents']['tmp_name'] = OMEGAUP_RESOURCES_ROOT . 'nostmt.zip';
// Log in as contest director
$r['auth_token'] = $this->login($problemData['author']);
// Call API. Should fail
try {
ProblemController::apiUpdate($r);
} catch (InvalidParameterException $e) {
// Expected
}
// Verify contents were not erased
$targetpath = PROBLEMS_PATH . DIRECTORY_SEPARATOR . $r['problem_alias'] . DIRECTORY_SEPARATOR;
$temppath = PROBLEMS_PATH . DIRECTORY_SEPARATOR . $r['problem_alias'] . '_tmp' . DIRECTORY_SEPARATOR;
$this->assertFileNotExists($temppath);
$this->assertFileExists($targetpath . 'cases');
$this->assertFileExists($targetpath . 'statements' . DIRECTORY_SEPARATOR . 'es.html');
// Check statements still is the original one
$statement = file_get_contents($targetpath . 'statements' . DIRECTORY_SEPARATOR . 'es.html');
$this->assertContains('<h1>Entrada</h1>', $statement);
}