2b8a293b02b13b0f32753a75d7c8b93af505b66a
3 require_once("ApiSetup.php");
5 class UploadFromChunksTest
extends ApiSetup
{
8 global $wgEnableUploads;
10 $wgEnableUploads=true;
11 ini_set('file_loads', true);
14 function testGetTitle() {
15 $filename = tempnam( wfTempDir(), "" );
16 $c = new UploadFromChunks();
17 $c->initialize(false, "temp.txt", null, $filename, 0, null);
18 $this->assertEquals(null, $c->getTitle());
20 $c = new UploadFromChunks();
21 $c->initialize(false, "temp.png", null, $filename, 0, null);
22 $this->assertEquals(Title
::makeTitleSafe(NS_FILE
, "Temp.png"), $c->getTitle());
25 function testGetEditToken() {
28 function testInitFromSessionKey() {
32 function testInitialize() {
35 function testSetupChunkSession() {
39 function makeChunk() {
40 $file = tempnam( wfTempDir(), "" );
41 $fh = fopen($file, "w");
43 $this->markTestIncomplete("Couldn't open $file!\n");
49 $_FILES['chunk']['tmp_name'] = $file;
50 $_FILES['chunk']['size'] = 3;
51 $_FILES['chunk']['error'] = null;
52 $_FILES['chunk']['name'] = "test.txt";
55 function cleanChunk() {
56 unlink($_FILES['chunk']['tmp_name']);
60 * @expectedException UsageException
62 function testPerformUploadInitError() {
65 $wgUser = User
::newFromId(1);
66 $token = $wgUser->editToken();
69 $req = new FauxRequest(
70 array('action' => 'upload',
71 'enablechunks' => '1',
72 'filename' => 'test.png',
75 $module = new ApiMain($req, true);
79 function testPerformUploadInitSuccess() {
82 $wgUser = User
::newFromId(1);
83 $token = $wgUser->editToken();
86 $req = new FauxRequest(
87 array('action' => 'upload',
88 'enablechunks' => '1',
89 'filename' => 'test.png',
92 $module = new ApiMain($req, true);
96 function testAppendToUploadFile() {
99 function testAppendChunk() {
102 function testPeformUploadChunk() {
105 function testPeformUploadDone() {