2 class File_Test extends PHPUnit\Framework\TestCase
13 $File =
File::Create(
"objects/tests/files/ZeroLengthFile.txt");
16 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
17 $this->assertInstanceOf(
'File', $File);
19 $StoredFilePath = $File->GetNameOfStoredFile();
21 $this->assertSame(file_get_contents(
"objects/tests/files/ValidFile.txt"),
22 file_get_contents($StoredFilePath));
25 $this->assertFileNotExists($StoredFilePath);
30 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
31 $Copy = $File->CreateCopy();
32 $this->assertSame($Copy->Name(), $File->Name());
33 $this->assertSame(file_get_contents($Copy->GetNameOfStoredFile()),
34 file_get_contents(
"objects/tests/files/ValidFile.txt"));
41 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
42 $this->assertSame($File->GetLength(),
'21');
48 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
49 $this->assertSame($File->GetType(),
'text/plain');
55 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
56 $File->Comment(
"abc123");
57 $this->assertSame($File->Comment(),
"abc123");
63 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
64 $File->FieldId(PHP_INT_MAX);
65 $this->assertSame($File->FieldId(), PHP_INT_MAX);
71 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
72 $File->ResourceId(PHP_INT_MAX);
73 $this->assertSame($File->ResourceId(), PHP_INT_MAX);
79 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
80 $this->assertSame($File->GetMimeType(),
"text/plain");
86 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
88 $GLOBALS[
"G_PluginManager"]->PluginEnabled(
"CleanURLs", FALSE);
89 $this->assertSame($File->GetLink(),
"index.php?P=DownloadFile&Id=".$File->Id());
91 $GLOBALS[
"G_PluginManager"]->PluginEnabled(
"CleanURLs", TRUE);
92 $this->assertSame($File->GetLink(),
"downloads/".$File->Id().
"/ValidFile.txt");
99 $File =
File::Create(
"objects/tests/files/ValidFile.txt");
100 $this->assertSame($File->GetStorageDirectory(),
"local/data/files");
const FILESTAT_ZEROLENGTH
const FILESTAT_DOESNOTEXIST
static Create($SourceFile, $DesiredFileName=NULL)
Create a new File object using an existing file.
testGetStorageDirectory()
testCreate()
Verify that files can be created and return the proper error/success codes.