123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- declare(strict_types=1);
- namespace Test\File\SimpleFS;
- use OCP\Files\NotPermittedException;
- use OCP\Files\SimpleFS\InMemoryFile;
- use Test\TestCase;
- class InMemoryFileTest extends TestCase {
-
- private $testPdf;
-
- public function setupTestPdf() {
- $fileContents = file_get_contents(
- __DIR__ . '/../../../data/test.pdf'
- );
- $this->testPdf = new InMemoryFile('test.pdf', $fileContents);
- }
-
- public function testPutContent(): void {
- $this->testPdf->putContent('test');
- self::assertEquals('test', $this->testPdf->getContent());
- }
-
- public function testDelete(): void {
- $this->testPdf->delete();
-
- self::assertTrue(true);
- }
-
- public function testGetName(): void {
- self::assertEquals('test.pdf', $this->testPdf->getName());
- }
-
- public function testGetSize(): void {
- self::assertEquals(7083, $this->testPdf->getSize());
- }
-
- public function testGetContent(): void {
- self::assertEquals(
- file_get_contents(__DIR__ . '/../../../data/test.pdf'),
- $this->testPdf->getContent()
- );
- }
-
- public function testGetMTime(): void {
- self::assertTrue(is_int($this->testPdf->getMTime()));
- }
-
- public function testGetMimeType(): void {
- self::assertEquals('application/pdf', $this->testPdf->getMimeType());
- }
-
- public function testRead(): void {
- self::expectException(NotPermittedException::class);
- $this->testPdf->read();
- }
-
- public function testWrite(): void {
- self::expectException(NotPermittedException::class);
- $this->testPdf->write();
- }
- }
|