Implement new attachment property in its getters/setters.

This commit is contained in:
Jan Böhmer 2019-09-24 16:36:41 +02:00
parent ba4bf4b613
commit 97cb91a3b2
2 changed files with 49 additions and 4 deletions

View file

@ -48,6 +48,12 @@ class AttachmentTest extends TestCase
$this->setProtectedProperty($attachment, 'path', '%BASE%/foo/bar.jpg');
$this->assertFalse($attachment->isExternal());
$this->setProtectedProperty($attachment, 'path', '%FOOTPRINTS%/foo/bar.jpg');
$this->assertFalse($attachment->isExternal());
$this->setProtectedProperty($attachment, 'path', '%FOOTPRINTS3D%/foo/bar.jpg');
$this->assertFalse($attachment->isExternal());
//Every other string is not a external attachment
$this->setProtectedProperty($attachment, 'path', '%test%/foo/bar.ghp');
$this->assertTrue($attachment->isExternal());
@ -68,6 +74,11 @@ class AttachmentTest extends TestCase
$this->setProtectedProperty($attachment, 'path', '%MEDIA%/foo/bar.JPeg');
$this->assertEquals('jpeg', $attachment->getExtension());
//Test if we can override the filename
$this->setProtectedProperty($attachment, 'path', '%MEDIA%/foo/bar.JPeg');
$this->setProtectedProperty($attachment, 'original_filename', 'test.txt');
$this->assertEquals('txt', $attachment->getExtension());
$this->setProtectedProperty($attachment, 'path', 'https://foo.bar');
$this->assertNull( $attachment->getExtension());
@ -110,6 +121,10 @@ class AttachmentTest extends TestCase
$this->setProtectedProperty($attachment, 'path', '%MEDIA%/foo/bar.txt');
$this->assertEquals('bar.txt', $attachment->getFilename());
$this->setProtectedProperty($attachment, 'path', '%MEDIA%/foo/bar.JPeg');
$this->setProtectedProperty($attachment, 'original_filename', 'test.txt');
$this->assertEquals('test.txt', $attachment->getFilename());
$this->setProtectedProperty($attachment, 'path', 'https://www.google.de/test.txt');
$this->assertNull($attachment->getFilename());
}