mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 19:13:26 +00:00
Update Border File API
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Border;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Media\Type\Audio;
|
||||
use Alchemy\Phrasea\Media\Type\Document;
|
||||
use Alchemy\Phrasea\Media\Type\Flash;
|
||||
@@ -46,6 +47,7 @@ class File
|
||||
protected $media;
|
||||
protected $uuid;
|
||||
protected $sha256;
|
||||
protected $app;
|
||||
protected $originalName;
|
||||
protected $md5;
|
||||
protected $attributes;
|
||||
@@ -53,14 +55,16 @@ class File
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Applciation $app Application context
|
||||
* @param MediaInterface $media The media
|
||||
* @param \collection $collection The destination collection
|
||||
* @param string $originalName The original name of the file
|
||||
* (if not provided, original name is
|
||||
* extracted from the pathfile)
|
||||
*/
|
||||
public function __construct(MediaInterface $media, \collection $collection, $originalName = null)
|
||||
public function __construct(Application $app, MediaInterface $media, \collection $collection, $originalName = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->media = $media;
|
||||
$this->collection = $collection;
|
||||
$this->attributes = array();
|
||||
@@ -128,8 +132,6 @@ class File
|
||||
}
|
||||
|
||||
if ($write) {
|
||||
$writer = new Writer(new Exiftool());
|
||||
|
||||
$value = new MonoValue($this->uuid);
|
||||
$metadatas = new MetadataBag();
|
||||
|
||||
@@ -141,13 +143,13 @@ class File
|
||||
* PHPExiftool throws exception on some files not supported
|
||||
*/
|
||||
try {
|
||||
$writer->write($this->getFile()->getRealPath(), $metadatas);
|
||||
$this->app['exiftool.writer']->write($this->getFile()->getRealPath(), $metadatas);
|
||||
} catch (PHPExiftoolException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$writer = $reader = $metadatas = null;
|
||||
$reader = $metadatas = null;
|
||||
|
||||
return $this->uuid;
|
||||
}
|
||||
@@ -282,14 +284,14 @@ class File
|
||||
*
|
||||
* @return \Alchemy\Phrasea\Border\File
|
||||
*/
|
||||
public static function buildFromPathfile($pathfile, \collection $collection, MediaVorus $mediavorus, $originalName = null)
|
||||
public static function buildFromPathfile($pathfile, \collection $collection, Application $app, $originalName = null)
|
||||
{
|
||||
try {
|
||||
$media = $mediavorus->guess($pathfile);
|
||||
$media = $app['mediavorus']->guess($pathfile);
|
||||
} catch (FileNotFoundException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to build media file from non existant %s', $pathfile));
|
||||
}
|
||||
|
||||
return new File($media, $collection, $originalName);
|
||||
return new File($app, $media, $collection, $originalName);
|
||||
}
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ class RecordAdd extends Command
|
||||
$media = $this->container['mediavorus']->guess($file);
|
||||
}
|
||||
|
||||
$file = new File($media, $collection, $originalName);
|
||||
$file = new File($this->container, $media, $collection, $originalName);
|
||||
$session = new LazaretSession();
|
||||
$this->container['EM']->persist($session);
|
||||
|
||||
|
@@ -126,7 +126,7 @@ class Step31 implements DatasUpgraderInterface
|
||||
$media = $this->app['mediavorus']->guess($pathfile);
|
||||
$collection = \collection::get_from_coll_id($app, $databox, (int) $record['coll_id']);
|
||||
|
||||
$file = new File($media, $collection);
|
||||
$file = new File($this->app, $media, $collection);
|
||||
$uuid = $file->getUUID(true, true);
|
||||
$sha256 = $file->getSha256();
|
||||
|
||||
|
@@ -263,7 +263,7 @@ class Lazaret implements ControllerProviderInterface
|
||||
|
||||
try {
|
||||
$borderFile = Border\File::buildFromPathfile(
|
||||
$lazaretFileName, $lazaretFile->getCollection($app), $app['mediavorus'], $lazaretFile->getOriginalName()
|
||||
$lazaretFileName, $lazaretFile->getCollection($app), $app, $lazaretFile->getOriginalName()
|
||||
);
|
||||
|
||||
$record = null;
|
||||
|
@@ -192,7 +192,7 @@ class Upload implements ControllerProviderInterface
|
||||
|
||||
$app['EM']->persist($lazaretSession);
|
||||
|
||||
$packageFile = new File($media, $collection, $file->getClientOriginalName());
|
||||
$packageFile = new File($app, $media, $collection, $file->getClientOriginalName());
|
||||
|
||||
$postStatus = $request->request->get('status');
|
||||
|
||||
|
@@ -659,7 +659,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
|
||||
$media = $app['mediavorus']->guess($file->getPathname());
|
||||
|
||||
$Package = new Alchemy\Phrasea\Border\File($media, $collection, $file->getClientOriginalName());
|
||||
$Package = new Alchemy\Phrasea\Border\File($this->app, $media, $collection, $file->getClientOriginalName());
|
||||
|
||||
if ($request->get('status')) {
|
||||
$Package->addAttribute(new Status($app, $request->get('status')));
|
||||
|
@@ -110,7 +110,7 @@ class patch_370a7 implements patchInterface
|
||||
|
||||
$collection = \collection::get_from_base_id($app, $row['base_id']);
|
||||
|
||||
$borderFile = new \Alchemy\Phrasea\Border\File($media, $collection);
|
||||
$borderFile = new \Alchemy\Phrasea\Border\File($app, $media, $collection);
|
||||
|
||||
$lazaretSession = new \Entities\LazaretSession();
|
||||
$lazaretSession->setUsrId($row['usr_id']);
|
||||
|
@@ -1688,7 +1688,7 @@ class task_period_archive extends task_abstract
|
||||
|
||||
$metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption);
|
||||
}
|
||||
$file = new \Alchemy\Phrasea\Border\File($media, $collection);
|
||||
$file = new \Alchemy\Phrasea\Border\File($this->dependencyContainer, $media, $collection);
|
||||
|
||||
$file->addAttribute(new BorderAttribute\Status($this->dependencyContainer, $status));
|
||||
|
||||
|
@@ -969,7 +969,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
||||
{
|
||||
$this->setToken(self::$token);
|
||||
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../testfiles/test001.CR2'), self::$DI['collection']);
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../testfiles/test001.CR2'), self::$DI['collection']);
|
||||
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
||||
|
||||
$route = '/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setmetadatas/';
|
||||
@@ -1089,7 +1089,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
||||
*/
|
||||
public function testMoveRecordToCollection()
|
||||
{
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../testfiles/test001.CR2'), self::$DI['collection']);
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../testfiles/test001.CR2'), self::$DI['collection']);
|
||||
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
||||
|
||||
$this->setToken(self::$token);
|
||||
@@ -1790,7 +1790,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
||||
$tmpname = tempnam(sys_get_temp_dir(), 'test_quarantine');
|
||||
copy(__DIR__ . '/../../../testfiles/iphone_pic.jpg', $tmpname);
|
||||
|
||||
$file = \Alchemy\Phrasea\Border\File::buildFromPathfile($tmpname, self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
$file = \Alchemy\Phrasea\Border\File::buildFromPathfile($tmpname, self::$DI['collection'], self::$DI['app']);
|
||||
self::$DI['app']['border-manager']->process($lazaretSession, $file, $callback, \Alchemy\Phrasea\Border\Manager::FORCE_LAZARET);
|
||||
|
||||
return $quarantineItem;
|
||||
|
@@ -33,7 +33,7 @@ class ApplicationOverviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$media = self::$DI['app']['mediavorus']->guess($tmp);
|
||||
|
||||
$file = new Alchemy\Phrasea\Border\File($media, self::$DI['collection']);
|
||||
$file = new Alchemy\Phrasea\Border\File(self::$DI['app'], $media, self::$DI['collection']);
|
||||
$record = record_adapter::createFromFile($file, self::$DI['app']);
|
||||
|
||||
$record->generate_subdefs($record->get_databox(), self::$DI['app']);
|
||||
|
@@ -37,7 +37,7 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract
|
||||
->method('getFile')
|
||||
->will($this->returnValue(new \SplFileInfo(__FILE__)));
|
||||
|
||||
$File = new \Alchemy\Phrasea\Border\File($media, self::$DI['collection']);
|
||||
$File = new \Alchemy\Phrasea\Border\File(self::$DI['app'], $media, self::$DI['collection']);
|
||||
|
||||
$response = $this->object->check(self::$DI['app']['EM'], $File);
|
||||
|
||||
|
@@ -33,7 +33,7 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
|
||||
->method('getFile')
|
||||
->will($this->returnValue(new \SplFileInfo(__FILE__)));
|
||||
|
||||
$File = new \Alchemy\Phrasea\Border\File($media, self::$DI['collection']);
|
||||
$File = new \Alchemy\Phrasea\Border\File(self::$DI['app'], $media, self::$DI['collection']);
|
||||
|
||||
$object = new Dimension(self::$DI['app'], array('width' => 800));
|
||||
$response = $object->check(self::$DI['app']['EM'], $File);
|
||||
|
@@ -49,7 +49,7 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract
|
||||
->method('getFile')
|
||||
->will($this->returnValue($spl));
|
||||
|
||||
$File = new \Alchemy\Phrasea\Border\File($media, self::$DI['collection']);
|
||||
$File = new \Alchemy\Phrasea\Border\File(self::$DI['app'], $media, self::$DI['collection']);
|
||||
|
||||
$response = $this->object->check(self::$DI['app']['EM'], $File);
|
||||
|
||||
|
@@ -42,7 +42,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
|
||||
*/
|
||||
public function testCheck()
|
||||
{
|
||||
$response = $this->object->check(self::$DI['app']['EM'], new File($this->media, self::$DI['collection']));
|
||||
$response = $this->object->check(self::$DI['app']['EM'], new File(self::$DI['app'], $this->media, self::$DI['collection']));
|
||||
|
||||
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
|
||||
|
||||
|
@@ -29,7 +29,7 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract
|
||||
public function testCheck()
|
||||
{
|
||||
$media = self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2');
|
||||
$file = new File($media, self::$DI['collection']);
|
||||
$file = new File(self::$DI['app'], $media, self::$DI['collection']);
|
||||
$response = $this->object->check(self::$DI['app']['EM'], $file);
|
||||
|
||||
$this->assertTrue($response->isOk());
|
||||
@@ -37,7 +37,7 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract
|
||||
$object = new MediaType(self::$DI['app'], array('mediatypes' => array(MediaType::TYPE_VIDEO, MediaType::TYPE_AUDIO)));
|
||||
|
||||
$media = self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2');
|
||||
$file = new File($media, self::$DI['collection']);
|
||||
$file = new File(self::$DI['app'], $media, self::$DI['collection']);
|
||||
$response = $object->check(self::$DI['app']['EM'], $file);
|
||||
|
||||
$this->assertFalse($response->isOk());
|
||||
|
@@ -41,7 +41,7 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
|
||||
$session = new \Entities\LazaretSession();
|
||||
self::$DI['app']['EM']->persist($session);
|
||||
|
||||
self::$DI['app']['border-manager']->process($session, File::buildFromPathfile($this->media->getFile()->getPathname(), self::$DI['collection'], self::$DI['app']['mediavorus']), null, \Alchemy\Phrasea\Border\Manager::FORCE_RECORD);
|
||||
self::$DI['app']['border-manager']->process($session, File::buildFromPathfile($this->media->getFile()->getPathname(), self::$DI['collection'], self::$DI['app']), null, \Alchemy\Phrasea\Border\Manager::FORCE_RECORD);
|
||||
|
||||
$mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getSha256'), array($this->media, self::$DI['collection']));
|
||||
|
||||
|
@@ -38,7 +38,7 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
|
||||
*/
|
||||
public function testCheck()
|
||||
{
|
||||
$response = $this->object->check(self::$DI['app']['EM'], new File($this->media, self::$DI['collection']));
|
||||
$response = $this->object->check(self::$DI['app']['EM'], new File(self::$DI['app'], $this->media, self::$DI['collection']));
|
||||
|
||||
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
|
||||
|
||||
|
@@ -37,7 +37,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
|
||||
$this->media = self::$DI['app']['mediavorus']->guess($this->filename);
|
||||
|
||||
$this->object = new File($this->media, self::$DI['collection'], 'originalName.txt');
|
||||
$this->object = new File(self::$DI['app'], $this->media, self::$DI['collection'], 'originalName.txt');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,20 +73,20 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
|
||||
copy(__DIR__ . '/../../../testfiles/p4logo.jpg', $file);
|
||||
|
||||
$borderFile = new File(self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
|
||||
$borderFile = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
|
||||
$uuid = $borderFile->getUUID(true, false);
|
||||
|
||||
$this->assertTrue(\uuid::is_valid($uuid));
|
||||
$this->assertEquals($uuid, $borderFile->getUUID());
|
||||
|
||||
$borderFile = new File(self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
|
||||
$borderFile = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
|
||||
$newuuid = $borderFile->getUUID(true, true);
|
||||
|
||||
$this->assertTrue(\uuid::is_valid($newuuid));
|
||||
$this->assertNotEquals($uuid, $newuuid);
|
||||
$this->assertEquals($newuuid, $borderFile->getUUID());
|
||||
|
||||
$borderFile = new File(self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
|
||||
$borderFile = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
|
||||
$uuid = $borderFile->getUUID();
|
||||
|
||||
$this->assertTrue(\uuid::is_valid($uuid));
|
||||
@@ -152,7 +152,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
*/
|
||||
public function testOriginalNameAuto()
|
||||
{
|
||||
$object = new File(self::$DI['app']['mediavorus']->guess($this->filename), self::$DI['collection']);
|
||||
$object = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess($this->filename), self::$DI['collection']);
|
||||
$this->assertSame('iphone_pic.jpg', $object->getOriginalName());
|
||||
}
|
||||
|
||||
@@ -194,16 +194,16 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
public function testBuildFromPathfile()
|
||||
{
|
||||
$media = self::$DI['app']['mediavorus']->guess($this->filename);
|
||||
$file1 = new File($media, self::$DI['collection']);
|
||||
$file1 = new File(self::$DI['app'], $media, self::$DI['collection']);
|
||||
|
||||
$file2 = File::buildFromPathfile($this->filename, self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
$file2 = File::buildFromPathfile($this->filename, self::$DI['collection'], self::$DI['app']);
|
||||
|
||||
$this->assertEquals($file1, $file2);
|
||||
|
||||
$media = self::$DI['app']['mediavorus']->guess($this->filename);
|
||||
$file3 = new File($media, self::$DI['collection'], 'coco lapin');
|
||||
$file3 = new File(self::$DI['app'], $media, self::$DI['collection'], 'coco lapin');
|
||||
|
||||
$file4 = File::buildFromPathfile($this->filename, self::$DI['collection'], self::$DI['app']['mediavorus'], 'coco lapin');
|
||||
$file4 = File::buildFromPathfile($this->filename, self::$DI['collection'], self::$DI['app'], 'coco lapin');
|
||||
|
||||
$this->assertEquals($file3, $file4);
|
||||
$this->assertNotEquals($file1, $file4);
|
||||
@@ -215,7 +215,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
*/
|
||||
public function testBuildFromWrongPathfile()
|
||||
{
|
||||
File::buildFromPathfile('unexistent.file', self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
File::buildFromPathfile('unexistent.file', self::$DI['collection'], self::$DI['app']);
|
||||
}
|
||||
|
||||
protected function getMediaMock($type)
|
||||
@@ -238,7 +238,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$image = $this->getMediaMock(MediaInterface::TYPE_IMAGE);
|
||||
|
||||
$file = new File($image, self::$DI['collection'], 'hello');
|
||||
$file = new File(self::$DI['app'], $image, self::$DI['collection'], 'hello');
|
||||
|
||||
$this->assertEquals(new Image(), $file->getType());
|
||||
}
|
||||
@@ -250,7 +250,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$document = $this->getMediaMock(MediaInterface::TYPE_DOCUMENT);
|
||||
|
||||
$file = new File($document, self::$DI['collection'], 'hello');
|
||||
$file = new File(self::$DI['app'], $document, self::$DI['collection'], 'hello');
|
||||
|
||||
$this->assertEquals(new Document(), $file->getType());
|
||||
}
|
||||
@@ -262,7 +262,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$audio = $this->getMediaMock(MediaInterface::TYPE_AUDIO);
|
||||
|
||||
$file = new File($audio, self::$DI['collection'], 'hello');
|
||||
$file = new File(self::$DI['app'], $audio, self::$DI['collection'], 'hello');
|
||||
|
||||
$this->assertEquals(new Audio(), $file->getType());
|
||||
}
|
||||
@@ -274,7 +274,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$video = $this->getMediaMock(MediaInterface::TYPE_VIDEO);
|
||||
|
||||
$file = new File($video, self::$DI['collection'], 'hello');
|
||||
$file = new File(self::$DI['app'], $video, self::$DI['collection'], 'hello');
|
||||
|
||||
$this->assertEquals(new Video(), $file->getType());
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$flash = $this->getMediaMock(MediaInterface::TYPE_FLASH);
|
||||
|
||||
$file = new File($flash, self::$DI['collection'], 'hello');
|
||||
$file = new File(self::$DI['app'], $flash, self::$DI['collection'], 'hello');
|
||||
|
||||
$this->assertEquals(new Flash(), $file->getType());
|
||||
}
|
||||
@@ -298,7 +298,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$noType = $this->getMediaMock(null);
|
||||
|
||||
$file = new File($noType, self::$DI['collection'], 'hello');
|
||||
$file = new File(self::$DI['app'], $noType, self::$DI['collection'], 'hello');
|
||||
|
||||
$this->assertNull($file->getType());
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$records[] = $record;
|
||||
};
|
||||
|
||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']), $postProcessRecord));
|
||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcessRecord));
|
||||
$shaChecker = new Checker\Sha256(self::$DI['app']);
|
||||
$this->object->registerChecker($shaChecker);
|
||||
|
||||
@@ -86,7 +86,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$records[] = $element;
|
||||
};
|
||||
|
||||
$this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']), $postProcess));
|
||||
$this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcess));
|
||||
|
||||
$postProcess = function($element, $visa, $code) use ($phpunit, &$records) {
|
||||
$phpunit->assertInstanceOf('\\record_adapter', $element);
|
||||
@@ -95,7 +95,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$records[] = $element;
|
||||
};
|
||||
|
||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']), $postProcess, Manager::FORCE_RECORD));
|
||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcess, Manager::FORCE_RECORD));
|
||||
|
||||
foreach ($records as $record) {
|
||||
if ($record instanceof \record_adapter) {
|
||||
@@ -114,8 +114,8 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$postProcessRecord = function($record) use (&$records) {
|
||||
$records[] = $record;
|
||||
};
|
||||
$this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']), NULL, Manager::FORCE_LAZARET));
|
||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']), $postProcessRecord));
|
||||
$this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), NULL, Manager::FORCE_LAZARET));
|
||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcessRecord));
|
||||
|
||||
foreach ($records as $record) {
|
||||
if ($record instanceof \record_adapter) {
|
||||
@@ -135,7 +135,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$records[] = $record;
|
||||
};
|
||||
|
||||
$file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
$file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']);
|
||||
$first = $odd = false;
|
||||
$tofetch = array();
|
||||
foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) {
|
||||
@@ -245,7 +245,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$lazaret = $element;
|
||||
};
|
||||
|
||||
$file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
$file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']);
|
||||
$odd = false;
|
||||
$tofetchMeta = $tofetchField = array();
|
||||
foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) {
|
||||
@@ -357,7 +357,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testLazaretAttributes()
|
||||
{
|
||||
$file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
$file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']);
|
||||
|
||||
$objectNameTag = new \PHPExiftool\Driver\Tag\IPTC\ObjectName();
|
||||
$monoValue = new \PHPExiftool\Driver\Value\Mono('title');
|
||||
@@ -400,7 +400,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$manager->setPdfToText(self::$DI['app']['xpdf.pdf2text']);
|
||||
|
||||
$file = File::buildFromPathfile(__DIR__ . '/../../../testfiles/HelloWorld.pdf', self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
$file = File::buildFromPathfile(__DIR__ . '/../../../testfiles/HelloWorld.pdf', self::$DI['collection'], self::$DI['app']);
|
||||
|
||||
$count = count($file->getAttributes());
|
||||
$manager->addMediaAttributesTester($file);
|
||||
@@ -448,7 +448,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$manager = new ManagerTester(self::$DI['app']);
|
||||
|
||||
$file = File::buildFromPathfile(__DIR__ . '/../../../testfiles/test012.wav', self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
$file = File::buildFromPathfile(__DIR__ . '/../../../testfiles/test012.wav', self::$DI['collection'], self::$DI['app']);
|
||||
|
||||
$count = count($file->getAttributes());
|
||||
$manager->addMediaAttributesTester($file);
|
||||
@@ -495,7 +495,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$manager = new ManagerTester(self::$DI['app']);
|
||||
|
||||
$file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']);
|
||||
$file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']);
|
||||
|
||||
$count = count($file->getAttributes());
|
||||
$manager->addMediaAttributesTester($file);
|
||||
@@ -546,15 +546,15 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$records[] = $record;
|
||||
};
|
||||
|
||||
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']));
|
||||
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']));
|
||||
|
||||
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
|
||||
|
||||
$this->assertTrue($visa->isValid());
|
||||
|
||||
$this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']), $postProcessRecord);
|
||||
$this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcessRecord);
|
||||
|
||||
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']));
|
||||
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']));
|
||||
|
||||
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
|
||||
|
||||
@@ -562,7 +562,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$this->object->registerChecker(new Checker\Sha256(self::$DI['app']));
|
||||
|
||||
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']['mediavorus']));
|
||||
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']));
|
||||
|
||||
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
|
||||
|
||||
|
@@ -110,7 +110,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$collection = $this->createOneCollection();
|
||||
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
|
||||
\record_adapter::createFromFile($file, self::$DI['app']);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/collection/' . $collection->get_base_id() . '/informations/details/');
|
||||
@@ -430,7 +430,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$collection = $this->createOneCollection();
|
||||
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
|
||||
\record_adapter::createFromFile($file, self::$DI['app']);
|
||||
|
||||
if ($collection->get_record_amount() === 0) {
|
||||
@@ -827,7 +827,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$collection = $this->createOneCollection();
|
||||
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
|
||||
\record_adapter::createFromFile($file, self::$DI['app']);
|
||||
|
||||
if ($collection->get_record_amount() === 0) {
|
||||
|
@@ -570,7 +570,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$base = $this->createDatabox();
|
||||
$collection = \collection::create(self::$DI['app'], $base, self::$DI['app']['phraseanet.appbox'], 'TESTTODELETE');
|
||||
self::$createdCollections[] = $collection;
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
|
||||
$file = new \Alchemy\Phrasea\Border\File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
|
||||
\record_adapter::createFromFile($file, self::$DI['app']);
|
||||
|
||||
if ($collection->get_record_amount() === 0) {
|
||||
|
@@ -754,7 +754,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
PhraseanetPHPUnitAbstract::$recordsInitialized[] = $i;
|
||||
|
||||
// echo "\t\t\tcreating record $i step #1 ".(microtime(true)-$start)."\n";
|
||||
$file = new Alchemy\Phrasea\Border\File($app['mediavorus']->guess($resolvePathfile($i)->getPathname()), $DI['collection']);
|
||||
$file = new Alchemy\Phrasea\Border\File($app, $app['mediavorus']->guess($resolvePathfile($i)->getPathname()), $DI['collection']);
|
||||
|
||||
// echo "\t\t\tcreating record $i step #2 ".(microtime(true)-$start)."\n";
|
||||
$record = record_adapter::createFromFile($file, $app);
|
||||
@@ -779,7 +779,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
|
||||
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access';
|
||||
|
||||
$file = new Alchemy\Phrasea\Border\File($app['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), $DI['collection_no_access']);
|
||||
$file = new Alchemy\Phrasea\Border\File($app, $app['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), $DI['collection_no_access']);
|
||||
|
||||
return \record_adapter::createFromFile($file, $app);
|
||||
});
|
||||
@@ -788,7 +788,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
|
||||
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access_by_status';
|
||||
|
||||
$file = new Alchemy\Phrasea\Border\File($app['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), $DI['collection_no_access']);
|
||||
$file = new Alchemy\Phrasea\Border\File($app, $app['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), $DI['collection_no_access']);
|
||||
|
||||
return \record_adapter::createFromFile($file, $app);
|
||||
});
|
||||
|
@@ -86,7 +86,7 @@ class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
public function testGet_record_amount()
|
||||
{
|
||||
self::$object->empty_collection();
|
||||
$file = new Alchemy\Phrasea\Border\File(self::$DI['app']['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), self::$object);
|
||||
$file = new Alchemy\Phrasea\Border\File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), self::$object);
|
||||
record_adapter::createFromFile($file, self::$DI['app']);
|
||||
$this->assertTrue(self::$object->get_record_amount() === 1);
|
||||
self::$object->empty_collection();
|
||||
@@ -133,7 +133,7 @@ class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
|
||||
public function testGet_record_details()
|
||||
{
|
||||
$file = new Alchemy\Phrasea\Border\File(self::$DI['app']['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), self::$object);
|
||||
$file = new Alchemy\Phrasea\Border\File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), self::$object);
|
||||
$record = record_adapter::createFromFile($file, self::$DI['app']);
|
||||
$details = self::$object->get_record_details();
|
||||
|
||||
|
@@ -34,7 +34,7 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
$file = new File(self::$DI['app']['mediavorus']->guess(__DIR__ . "/../testfiles/iphone_pic.jpg"), self::$DI['collection']);
|
||||
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . "/../testfiles/iphone_pic.jpg"), self::$DI['collection']);
|
||||
|
||||
self::$recordonbleu = record_adapter::createFromFile($file, self::$DI['app']);
|
||||
self::$recordonbleu->generate_subdefs(self::$recordonbleu->get_databox(), self::$DI['app']);
|
||||
|
Reference in New Issue
Block a user