mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-15 08:48:42 +00:00
autofixes
This commit is contained in:
parent
249e2f65ad
commit
e8008ab855
|
|
@ -83,7 +83,7 @@ final class Installer extends InstallerAbstract
|
||||||
*/
|
*/
|
||||||
private static function installMedia($dbPool, $data) : void
|
private static function installMedia($dbPool, $data) : void
|
||||||
{
|
{
|
||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
$collection->name = (string) $data['name'] ?? '';
|
$collection->name = (string) $data['name'] ?? '';
|
||||||
$collection->setVirtualPath((string) $data['virtualPath'] ?? '/');
|
$collection->setVirtualPath((string) $data['virtualPath'] ?? '/');
|
||||||
$collection->setPath((string) ($data['path'] ?? '/Modules/Media/Files/' . ((string) $data['name'] ?? '')));
|
$collection->setPath((string) ($data['path'] ?? '/Modules/Media/Files/' . ((string) $data['name'] ?? '')));
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ use phpOMS\Message\NotificationLevel;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Model\Message\FormValidation;
|
use phpOMS\Model\Message\FormValidation;
|
||||||
|
use phpOMS\System\File\FileUtils;
|
||||||
use phpOMS\System\File\Local\Directory;
|
use phpOMS\System\File\Local\Directory;
|
||||||
use phpOMS\Utils\Parser\Markdown\Markdown;
|
use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||||
use phpOMS\System\File\FileUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Media class.
|
* Media class.
|
||||||
|
|
@ -113,7 +113,7 @@ final class ApiController extends Controller
|
||||||
* @param array $files Files
|
* @param array $files Files
|
||||||
* @param int $account Uploader
|
* @param int $account Uploader
|
||||||
* @param string $basePath Base path. The path which is used for the upload.
|
* @param string $basePath Base path. The path which is used for the upload.
|
||||||
* @param string $virtualPath Virtual path The path which is used to visually structure the files, like directories.
|
* @param string $virtualPath virtual path The path which is used to visually structure the files, like directories
|
||||||
* @param string $type Media type (internal/custom media categorization)
|
* @param string $type Media type (internal/custom media categorization)
|
||||||
* The file storage on the system can be different
|
* The file storage on the system can be different
|
||||||
* @param string $password File password. The password to protect the file (only database)
|
* @param string $password File password. The password to protect the file (only database)
|
||||||
|
|
@ -241,8 +241,8 @@ final class ApiController extends Controller
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
|
|
||||||
$media->setPath(self::normalizeDbPath($status['path']) . '/' . $status['filename']);
|
$media->setPath(self::normalizeDbPath($status['path']) . '/' . $status['filename']);
|
||||||
$media->name = $status['name'];
|
$media->name = $status['name'];
|
||||||
$media->size = $status['size'];
|
$media->size = $status['size'];
|
||||||
$media->createdBy = new NullAccount($account);
|
$media->createdBy = new NullAccount($account);
|
||||||
$media->extension = $status['extension'];
|
$media->extension = $status['extension'];
|
||||||
$media->setVirtualPath($virtualPath);
|
$media->setVirtualPath($virtualPath);
|
||||||
|
|
@ -315,8 +315,8 @@ final class ApiController extends Controller
|
||||||
$id = (int) $request->getData('id');
|
$id = (int) $request->getData('id');
|
||||||
|
|
||||||
/** @var Media $media */
|
/** @var Media $media */
|
||||||
$media = MediaMapper::get($id);
|
$media = MediaMapper::get($id);
|
||||||
$media->name = (string) ($request->getData('name') ?? $media->name);
|
$media->name = (string) ($request->getData('name') ?? $media->name);
|
||||||
$media->description = (string) ($request->getData('description') ?? $media->description);
|
$media->description = (string) ($request->getData('description') ?? $media->description);
|
||||||
$media->setPath((string) ($request->getData('path') ?? $media->getPath()));
|
$media->setPath((string) ($request->getData('path') ?? $media->getPath()));
|
||||||
$media->setVirtualPath(\urldecode((string) ($request->getData('virtualpath') ?? $media->getVirtualPath())));
|
$media->setVirtualPath(\urldecode((string) ($request->getData('virtualpath') ?? $media->getVirtualPath())));
|
||||||
|
|
@ -328,7 +328,7 @@ final class ApiController extends Controller
|
||||||
) {
|
) {
|
||||||
$name = \explode('.', \basename($path));
|
$name = \explode('.', \basename($path));
|
||||||
|
|
||||||
$media->name = $name[0];
|
$media->name = $name[0];
|
||||||
$media->extension = $name[1] ?? '';
|
$media->extension = $name[1] ?? '';
|
||||||
$media->setVirtualPath(\dirname($path));
|
$media->setVirtualPath(\dirname($path));
|
||||||
$media->setPath('/Modules/Media/Files/' . \ltrim($path, '\\/'));
|
$media->setPath('/Modules/Media/Files/' . \ltrim($path, '\\/'));
|
||||||
|
|
@ -404,11 +404,11 @@ final class ApiController extends Controller
|
||||||
*/
|
*/
|
||||||
private function createCollectionFromRequest(RequestAbstract $request) : Collection
|
private function createCollectionFromRequest(RequestAbstract $request) : Collection
|
||||||
{
|
{
|
||||||
$mediaCollection = new Collection();
|
$mediaCollection = new Collection();
|
||||||
$mediaCollection->name = $request->getData('name') ?? '';
|
$mediaCollection->name = $request->getData('name') ?? '';
|
||||||
$mediaCollection->description = ($description = Markdown::parse($request->getData('description') ?? ''));
|
$mediaCollection->description = ($description = Markdown::parse($request->getData('description') ?? ''));
|
||||||
$mediaCollection->descriptionRaw = $description;
|
$mediaCollection->descriptionRaw = $description;
|
||||||
$mediaCollection->createdBy = new NullAccount($request->header->account);
|
$mediaCollection->createdBy = new NullAccount($request->header->account);
|
||||||
|
|
||||||
$media = $request->getDataJson('media-list');
|
$media = $request->getDataJson('media-list');
|
||||||
foreach ($media as $file) {
|
foreach ($media as $file) {
|
||||||
|
|
@ -459,11 +459,11 @@ final class ApiController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create collection */
|
/* Create collection */
|
||||||
$mediaCollection = new Collection();
|
$mediaCollection = new Collection();
|
||||||
$mediaCollection->name = $name;
|
$mediaCollection->name = $name;
|
||||||
$mediaCollection->description = Markdown::parse($description);
|
$mediaCollection->description = Markdown::parse($description);
|
||||||
$mediaCollection->descriptionRaw = $description;
|
$mediaCollection->descriptionRaw = $description;
|
||||||
$mediaCollection->createdBy = new NullAccount($account);
|
$mediaCollection->createdBy = new NullAccount($account);
|
||||||
$mediaCollection->setSources($media);
|
$mediaCollection->setSources($media);
|
||||||
$mediaCollection->setVirtualPath('/');
|
$mediaCollection->setVirtualPath('/');
|
||||||
$mediaCollection->setPath('/Modules/Media/Files');
|
$mediaCollection->setPath('/Modules/Media/Files');
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ final class BackendController extends Controller
|
||||||
$collection = CollectionMapper::getParentCollection($path);
|
$collection = CollectionMapper::getParentCollection($path);
|
||||||
|
|
||||||
if (\is_array($collection) && \is_dir(__DIR__ . '/../Files' . $path)) {
|
if (\is_array($collection) && \is_dir(__DIR__ . '/../Files' . $path)) {
|
||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
$collection->name = \basename($path);
|
$collection->name = \basename($path);
|
||||||
$collection->setVirtualPath(\dirname($path));
|
$collection->setVirtualPath(\dirname($path));
|
||||||
$collection->setPath(\dirname($path));
|
$collection->setPath(\dirname($path));
|
||||||
|
|
@ -144,8 +144,8 @@ final class BackendController extends Controller
|
||||||
|
|
||||||
$pathinfo = \pathinfo($file);
|
$pathinfo = \pathinfo($file);
|
||||||
|
|
||||||
$localMedia = new Media();
|
$localMedia = new Media();
|
||||||
$localMedia->name = $pathinfo['filename'];
|
$localMedia->name = $pathinfo['filename'];
|
||||||
$localMedia->extension = \is_dir($file) ? 'collection' : $pathinfo['extension'] ?? '';
|
$localMedia->extension = \is_dir($file) ? 'collection' : $pathinfo['extension'] ?? '';
|
||||||
$localMedia->setVirtualPath($path);
|
$localMedia->setVirtualPath($path);
|
||||||
$localMedia->createdBy = new Account();
|
$localMedia->createdBy = new Account();
|
||||||
|
|
@ -200,7 +200,7 @@ final class BackendController extends Controller
|
||||||
) {
|
) {
|
||||||
$name = \explode('.', \basename($path));
|
$name = \explode('.', \basename($path));
|
||||||
|
|
||||||
$media->name = $name[0];
|
$media->name = $name[0];
|
||||||
$media->extension = $name[1] ?? '';
|
$media->extension = $name[1] ?? '';
|
||||||
$media->setVirtualPath(\dirname($path));
|
$media->setVirtualPath(\dirname($path));
|
||||||
$media->setPath('/Modules/Media/Files/' . \ltrim($path, '\\/'));
|
$media->setPath('/Modules/Media/Files/' . \ltrim($path, '\\/'));
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Media\Models;
|
namespace Modules\Media\Models;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\RelationType;
|
|
||||||
use Modules\Admin\Models\Account;
|
use Modules\Admin\Models\Account;
|
||||||
|
use phpOMS\DataStorage\Database\RelationType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper class.
|
* Mapper class.
|
||||||
|
|
@ -122,13 +122,13 @@ final class CollectionMapper extends MediaMapper
|
||||||
*/
|
*/
|
||||||
public static function getCollectionsByPath(string $path, bool $showDirectories = false) : array
|
public static function getCollectionsByPath(string $path, bool $showDirectories = false) : array
|
||||||
{
|
{
|
||||||
$collection = CollectionMapper::getByVirtualPath($path);
|
$collection = self::getByVirtualPath($path);
|
||||||
$parent = [];
|
$parent = [];
|
||||||
|
|
||||||
if ($showDirectories) {
|
if ($showDirectories) {
|
||||||
$parent = CollectionMapper::getParentCollection($path);
|
$parent = self::getParentCollection($path);
|
||||||
if (\is_array($parent) && \is_dir(__DIR__ . '/../../Media/Files' . $path)) {
|
if (\is_array($parent) && \is_dir(__DIR__ . '/../../Media/Files' . $path)) {
|
||||||
$parent = new Collection();
|
$parent = new Collection();
|
||||||
$parent->name = \basename($path);
|
$parent->name = \basename($path);
|
||||||
$parent->setVirtualPath(\dirname($path));
|
$parent->setVirtualPath(\dirname($path));
|
||||||
$parent->setPath(\dirname($path));
|
$parent->setPath(\dirname($path));
|
||||||
|
|
@ -162,8 +162,8 @@ final class CollectionMapper extends MediaMapper
|
||||||
|
|
||||||
$pathinfo = \pathinfo($file);
|
$pathinfo = \pathinfo($file);
|
||||||
|
|
||||||
$localMedia = new Collection();
|
$localMedia = new Collection();
|
||||||
$localMedia->name = $pathinfo['filename'];
|
$localMedia->name = $pathinfo['filename'];
|
||||||
$localMedia->extension = \is_dir($file) ? 'collection' : $pathinfo['extension'] ?? '';
|
$localMedia->extension = \is_dir($file) ? 'collection' : $pathinfo['extension'] ?? '';
|
||||||
$localMedia->setVirtualPath($path);
|
$localMedia->setVirtualPath($path);
|
||||||
$localMedia->createdBy = new Account();
|
$localMedia->createdBy = new Account();
|
||||||
|
|
|
||||||
|
|
@ -35,23 +35,23 @@ class MediaMapper extends DataMapperAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static array $columns = [
|
protected static array $columns = [
|
||||||
'media_id' => ['name' => 'media_id', 'type' => 'int', 'internal' => 'id'],
|
'media_id' => ['name' => 'media_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
'media_name' => ['name' => 'media_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
'media_name' => ['name' => 'media_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||||
'media_type' => ['name' => 'media_type', 'type' => 'string', 'internal' => 'type'],
|
'media_type' => ['name' => 'media_type', 'type' => 'string', 'internal' => 'type'],
|
||||||
'media_description' => ['name' => 'media_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true],
|
'media_description' => ['name' => 'media_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true],
|
||||||
'media_description_raw' => ['name' => 'media_description_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
'media_description_raw' => ['name' => 'media_description_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
||||||
'media_versioned' => ['name' => 'media_versioned', 'type' => 'bool', 'internal' => 'isVersioned'],
|
'media_versioned' => ['name' => 'media_versioned', 'type' => 'bool', 'internal' => 'isVersioned'],
|
||||||
'media_hidden' => ['name' => 'media_hidden', 'type' => 'bool', 'internal' => 'isHidden'],
|
'media_hidden' => ['name' => 'media_hidden', 'type' => 'bool', 'internal' => 'isHidden'],
|
||||||
'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path', 'autocomplete' => true],
|
'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path', 'autocomplete' => true],
|
||||||
'media_virtual' => ['name' => 'media_virtual', 'type' => 'string', 'internal' => 'virtualPath', 'autocomplete' => true],
|
'media_virtual' => ['name' => 'media_virtual', 'type' => 'string', 'internal' => 'virtualPath', 'autocomplete' => true],
|
||||||
'media_absolute' => ['name' => 'media_absolute', 'type' => 'bool', 'internal' => 'isAbsolute'],
|
'media_absolute' => ['name' => 'media_absolute', 'type' => 'bool', 'internal' => 'isAbsolute'],
|
||||||
'media_nonce' => ['name' => 'media_nonce', 'type' => 'string', 'internal' => 'nonce'],
|
'media_nonce' => ['name' => 'media_nonce', 'type' => 'string', 'internal' => 'nonce'],
|
||||||
'media_password' => ['name' => 'media_password', 'type' => 'string', 'internal' => 'password'],
|
'media_password' => ['name' => 'media_password', 'type' => 'string', 'internal' => 'password'],
|
||||||
'media_extension' => ['name' => 'media_extension', 'type' => 'string', 'internal' => 'extension'],
|
'media_extension' => ['name' => 'media_extension', 'type' => 'string', 'internal' => 'extension'],
|
||||||
'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'],
|
'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'],
|
||||||
'media_collection' => ['name' => 'media_collection', 'type' => 'int', 'internal' => 'collection'],
|
'media_collection' => ['name' => 'media_collection', 'type' => 'int', 'internal' => 'collection'],
|
||||||
'media_created_by' => ['name' => 'media_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
'media_created_by' => ['name' => 'media_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||||
'media_created_at' => ['name' => 'media_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
'media_created_at' => ['name' => 'media_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -134,15 +134,15 @@ trait ApiControllerCollectionTrait
|
||||||
*/
|
*/
|
||||||
public function testApiCollectionFromMedia() : void
|
public function testApiCollectionFromMedia() : void
|
||||||
{
|
{
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
$media->createdBy = new NullAccount(1);
|
$media->createdBy = new NullAccount(1);
|
||||||
$media->description = 'desc';
|
$media->description = 'desc';
|
||||||
$media->descriptionRaw = 'descRaw';
|
$media->descriptionRaw = 'descRaw';
|
||||||
$media->setPath('some/path');
|
$media->setPath('some/path');
|
||||||
$media->size = 11;
|
$media->size = 11;
|
||||||
$media->extension = 'png';
|
$media->extension = 'png';
|
||||||
$media->name = 'Media for collection';
|
$media->name = 'Media for collection';
|
||||||
$id = MediaMapper::create($media);
|
$id = MediaMapper::create($media);
|
||||||
|
|
||||||
self::assertGreaterThan(0, $media->getId());
|
self::assertGreaterThan(0, $media->getId());
|
||||||
self::assertEquals($id, $media->getId());
|
self::assertEquals($id, $media->getId());
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,14 @@ class CollectionMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testCR() : void
|
public function testCR() : void
|
||||||
{
|
{
|
||||||
$media = new Collection();
|
$media = new Collection();
|
||||||
$media->createdBy = new NullAccount(1);
|
$media->createdBy = new NullAccount(1);
|
||||||
$media->description = 'desc';
|
$media->description = 'desc';
|
||||||
$media->descriptionRaw = 'descRaw';
|
$media->descriptionRaw = 'descRaw';
|
||||||
$media->setPath('some/path');
|
$media->setPath('some/path');
|
||||||
$media->size = 11;
|
$media->size = 11;
|
||||||
$media->name = 'Collection';
|
$media->name = 'Collection';
|
||||||
$id = CollectionMapper::create($media);
|
$id = CollectionMapper::create($media);
|
||||||
|
|
||||||
self::assertGreaterThan(0, $media->getId());
|
self::assertGreaterThan(0, $media->getId());
|
||||||
self::assertEquals($id, $media->getId());
|
self::assertEquals($id, $media->getId());
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,15 @@ class MediaMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testCR() : void
|
public function testCR() : void
|
||||||
{
|
{
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
$media->createdBy = new NullAccount(1);
|
$media->createdBy = new NullAccount(1);
|
||||||
$media->description = 'desc';
|
$media->description = 'desc';
|
||||||
$media->descriptionRaw = 'descRaw';
|
$media->descriptionRaw = 'descRaw';
|
||||||
$media->setPath('some/path');
|
$media->setPath('some/path');
|
||||||
$media->size = 11;
|
$media->size = 11;
|
||||||
$media->extension = 'png';
|
$media->extension = 'png';
|
||||||
$media->name = 'Image';
|
$media->name = 'Image';
|
||||||
$id = MediaMapper::create($media);
|
$id = MediaMapper::create($media);
|
||||||
|
|
||||||
self::assertGreaterThan(0, $media->getId());
|
self::assertGreaterThan(0, $media->getId());
|
||||||
self::assertEquals($id, $media->getId());
|
self::assertEquals($id, $media->getId());
|
||||||
|
|
@ -62,15 +62,15 @@ class MediaMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testAbsolute() : void
|
public function testAbsolute() : void
|
||||||
{
|
{
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
$media->createdBy = new NullAccount(1);
|
$media->createdBy = new NullAccount(1);
|
||||||
$media->description = 'desc';
|
$media->description = 'desc';
|
||||||
$media->setPath('https://avatars0.githubusercontent.com/u/16034994');
|
$media->setPath('https://avatars0.githubusercontent.com/u/16034994');
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
$media->size = 11;
|
$media->size = 11;
|
||||||
$media->extension = 'png';
|
$media->extension = 'png';
|
||||||
$media->name = 'Absolute path';
|
$media->name = 'Absolute path';
|
||||||
$id = MediaMapper::create($media);
|
$id = MediaMapper::create($media);
|
||||||
|
|
||||||
self::assertGreaterThan(0, $media->getId());
|
self::assertGreaterThan(0, $media->getId());
|
||||||
self::assertEquals($id, $media->getId());
|
self::assertEquals($id, $media->getId());
|
||||||
|
|
@ -92,15 +92,15 @@ class MediaMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testDirectoryMapping() : void
|
public function testDirectoryMapping() : void
|
||||||
{
|
{
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
$media->createdBy = new NullAccount(1);
|
$media->createdBy = new NullAccount(1);
|
||||||
$media->description = 'desc';
|
$media->description = 'desc';
|
||||||
$media->setPath(\realpath(__DIR__ . '/../../../../../'));
|
$media->setPath(\realpath(__DIR__ . '/../../../../../'));
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
$media->size = 11;
|
$media->size = 11;
|
||||||
$media->extension = 'collection';
|
$media->extension = 'collection';
|
||||||
$media->name = 'Directory';
|
$media->name = 'Directory';
|
||||||
$id = MediaMapper::create($media);
|
$id = MediaMapper::create($media);
|
||||||
|
|
||||||
self::assertGreaterThan(0, $media->getId());
|
self::assertGreaterThan(0, $media->getId());
|
||||||
self::assertEquals($id, $media->getId());
|
self::assertEquals($id, $media->getId());
|
||||||
|
|
@ -122,16 +122,16 @@ class MediaMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testGetVirtualPath() : void
|
public function testGetVirtualPath() : void
|
||||||
{
|
{
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
$media->createdBy = new NullAccount(1);
|
$media->createdBy = new NullAccount(1);
|
||||||
$media->description = 'desc';
|
$media->description = 'desc';
|
||||||
$media->setPath('https://avatars0.githubusercontent.com/u/16034994');
|
$media->setPath('https://avatars0.githubusercontent.com/u/16034994');
|
||||||
$media->setVirtualPath('/mediamappertest/path');
|
$media->setVirtualPath('/mediamappertest/path');
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
$media->size = 11;
|
$media->size = 11;
|
||||||
$media->extension = 'png';
|
$media->extension = 'png';
|
||||||
$media->name = 'With virtual path';
|
$media->name = 'With virtual path';
|
||||||
$id = MediaMapper::create($media);
|
$id = MediaMapper::create($media);
|
||||||
|
|
||||||
self::assertGreaterThan(0, $media->getId());
|
self::assertGreaterThan(0, $media->getId());
|
||||||
self::assertEquals($id, $media->getId());
|
self::assertEquals($id, $media->getId());
|
||||||
|
|
@ -154,29 +154,29 @@ class MediaMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testParentcollection() : void
|
public function testParentcollection() : void
|
||||||
{
|
{
|
||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
$collection->createdBy = new NullAccount(1);
|
$collection->createdBy = new NullAccount(1);
|
||||||
$collection->description = 'desc';
|
$collection->description = 'desc';
|
||||||
$collection->descriptionRaw = 'descRaw';
|
$collection->descriptionRaw = 'descRaw';
|
||||||
$collection->setPath('some/path');
|
$collection->setPath('some/path');
|
||||||
$collection->setVirtualPath('/virtual/path');
|
$collection->setVirtualPath('/virtual/path');
|
||||||
$collection->size = 11;
|
$collection->size = 11;
|
||||||
$collection->name = 'Collection';
|
$collection->name = 'Collection';
|
||||||
$idCollection = CollectionMapper::create($collection);
|
$idCollection = CollectionMapper::create($collection);
|
||||||
|
|
||||||
self::assertGreaterThan(0, $collection->getId());
|
self::assertGreaterThan(0, $collection->getId());
|
||||||
self::assertEquals($idCollection, $collection->getId());
|
self::assertEquals($idCollection, $collection->getId());
|
||||||
|
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
$media->createdBy = new NullAccount(1);
|
$media->createdBy = new NullAccount(1);
|
||||||
$media->description = 'desc';
|
$media->description = 'desc';
|
||||||
$media->setPath('https://avatars0.githubusercontent.com/u/16034994');
|
$media->setPath('https://avatars0.githubusercontent.com/u/16034994');
|
||||||
$media->setVirtualPath('/virtual/path/Collection');
|
$media->setVirtualPath('/virtual/path/Collection');
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
$media->size = 11;
|
$media->size = 11;
|
||||||
$media->extension = 'png';
|
$media->extension = 'png';
|
||||||
$media->name = 'Absolute path';
|
$media->name = 'Absolute path';
|
||||||
$idMedia = MediaMapper::create($media);
|
$idMedia = MediaMapper::create($media);
|
||||||
|
|
||||||
self::assertGreaterThan(0, $media->getId());
|
self::assertGreaterThan(0, $media->getId());
|
||||||
self::assertEquals($idMedia, $media->getId());
|
self::assertEquals($idMedia, $media->getId());
|
||||||
|
|
|
||||||
|
|
@ -196,12 +196,12 @@ class MediaTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->media->createdBy = $acc = new NullAccount(1);
|
$this->media->createdBy = $acc = new NullAccount(1);
|
||||||
$this->media->extension = 'pdf';
|
$this->media->extension = 'pdf';
|
||||||
$this->media->setPath('/home/root');
|
$this->media->setPath('/home/root');
|
||||||
$this->media->isAbsolute = true;
|
$this->media->isAbsolute = true;
|
||||||
$this->media->name = 'Report';
|
$this->media->name = 'Report';
|
||||||
$this->media->description = 'This is a description';
|
$this->media->description = 'This is a description';
|
||||||
$this->media->descriptionRaw = 'This is a description raw';
|
$this->media->descriptionRaw = 'This is a description raw';
|
||||||
$this->media->size = 11;
|
$this->media->size = 11;
|
||||||
$this->media->isVersioned = true;
|
$this->media->isVersioned = true;
|
||||||
$this->media->setVirtualPath('/test/path');
|
$this->media->setVirtualPath('/test/path');
|
||||||
$this->media->isHidden = true;
|
$this->media->isHidden = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ class MediaViewTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$media->setPath(__DIR__);
|
$media->setPath(__DIR__);
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
$media->extension = 'collection';
|
$media->extension = 'collection';
|
||||||
self::assertFalse(
|
self::assertFalse(
|
||||||
$method->invoke($this->view, $media, '/MediaViewTest.php')
|
$method->invoke($this->view, $media, '/MediaViewTest.php')
|
||||||
);
|
);
|
||||||
|
|
@ -108,7 +108,7 @@ class MediaViewTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$media->setPath(__DIR__);
|
$media->setPath(__DIR__);
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
$media->extension = 'collection';
|
$media->extension = 'collection';
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
$method->invoke($this->view, $media, '/something')
|
$method->invoke($this->view, $media, '/something')
|
||||||
);
|
);
|
||||||
|
|
@ -194,7 +194,7 @@ class MediaViewTest extends \PHPUnit\Framework\TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$media->setPath(__DIR__ . '/test.jpg');
|
$media->setPath(__DIR__ . '/test.jpg');
|
||||||
$media->extension = 'jpg';
|
$media->extension = 'jpg';
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
$method->invoke($this->view, $media)
|
$method->invoke($this->view, $media)
|
||||||
|
|
@ -218,14 +218,14 @@ class MediaViewTest extends \PHPUnit\Framework\TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$media->setPath(__DIR__ . '/test.md');
|
$media->setPath(__DIR__ . '/test.md');
|
||||||
$media->extension = 'md';
|
$media->extension = 'md';
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
$method->invoke($this->view, $media)
|
$method->invoke($this->view, $media)
|
||||||
);
|
);
|
||||||
|
|
||||||
$media->setPath(__DIR__ . '/test.jpg');
|
$media->setPath(__DIR__ . '/test.jpg');
|
||||||
$media->extension = 'jpg';
|
$media->extension = 'jpg';
|
||||||
$media->isAbsolute = true;
|
$media->isAbsolute = true;
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
$method->invoke($this->view, $media, __DIR__ . '/test.md')
|
$method->invoke($this->view, $media, __DIR__ . '/test.md')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user