diff --git a/lib/Alchemy/Phrasea/Border/File.php b/lib/Alchemy/Phrasea/Border/File.php index ab6209c0f9..3da3fc5a69 100644 --- a/lib/Alchemy/Phrasea/Border/File.php +++ b/lib/Alchemy/Phrasea/Border/File.php @@ -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); } } diff --git a/lib/Alchemy/Phrasea/Command/RecordAdd.php b/lib/Alchemy/Phrasea/Command/RecordAdd.php index 87de1fc663..f97c6771c9 100644 --- a/lib/Alchemy/Phrasea/Command/RecordAdd.php +++ b/lib/Alchemy/Phrasea/Command/RecordAdd.php @@ -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); diff --git a/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php b/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php index 57c38705ef..131196f4c2 100644 --- a/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php +++ b/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php @@ -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(); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php index d4372fd50e..d271d41e82 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php @@ -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; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index 87b5cc62b1..bad80c740f 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -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'); diff --git a/lib/classes/API/V1/adapter.class.php b/lib/classes/API/V1/adapter.class.php index e84acf065c..62f254e547 100644 --- a/lib/classes/API/V1/adapter.class.php +++ b/lib/classes/API/V1/adapter.class.php @@ -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'))); diff --git a/lib/classes/patch/370a7.class.php b/lib/classes/patch/370a7.class.php index d05419bc10..4b79c59aa7 100644 --- a/lib/classes/patch/370a7.class.php +++ b/lib/classes/patch/370a7.class.php @@ -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']); diff --git a/lib/classes/task/period/archive.class.php b/lib/classes/task/period/archive.class.php index bc38183a02..24402ce069 100755 --- a/lib/classes/task/period/archive.class.php +++ b/lib/classes/task/period/archive.class.php @@ -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)); diff --git a/tests/Alchemy/Phrasea/Application/ApiAbstract.inc b/tests/Alchemy/Phrasea/Application/ApiAbstract.inc index be465145fa..9ecb747eb1 100644 --- a/tests/Alchemy/Phrasea/Application/ApiAbstract.inc +++ b/tests/Alchemy/Phrasea/Application/ApiAbstract.inc @@ -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; diff --git a/tests/Alchemy/Phrasea/Application/OverviewTest.php b/tests/Alchemy/Phrasea/Application/OverviewTest.php index 54b2a42717..af540c1171 100644 --- a/tests/Alchemy/Phrasea/Application/OverviewTest.php +++ b/tests/Alchemy/Phrasea/Application/OverviewTest.php @@ -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']); diff --git a/tests/Alchemy/Phrasea/Border/Checker/ColorspaceTest.php b/tests/Alchemy/Phrasea/Border/Checker/ColorspaceTest.php index 4a58329594..6a72fcb436 100644 --- a/tests/Alchemy/Phrasea/Border/Checker/ColorspaceTest.php +++ b/tests/Alchemy/Phrasea/Border/Checker/ColorspaceTest.php @@ -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); diff --git a/tests/Alchemy/Phrasea/Border/Checker/DimensionTest.php b/tests/Alchemy/Phrasea/Border/Checker/DimensionTest.php index 1127fc6f4a..514118d259 100644 --- a/tests/Alchemy/Phrasea/Border/Checker/DimensionTest.php +++ b/tests/Alchemy/Phrasea/Border/Checker/DimensionTest.php @@ -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); diff --git a/tests/Alchemy/Phrasea/Border/Checker/ExtensionTest.php b/tests/Alchemy/Phrasea/Border/Checker/ExtensionTest.php index 291f322e28..cf696294d5 100644 --- a/tests/Alchemy/Phrasea/Border/Checker/ExtensionTest.php +++ b/tests/Alchemy/Phrasea/Border/Checker/ExtensionTest.php @@ -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); diff --git a/tests/Alchemy/Phrasea/Border/Checker/FilenameTest.php b/tests/Alchemy/Phrasea/Border/Checker/FilenameTest.php index 48189e3bc9..659a1a2cef 100644 --- a/tests/Alchemy/Phrasea/Border/Checker/FilenameTest.php +++ b/tests/Alchemy/Phrasea/Border/Checker/FilenameTest.php @@ -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); diff --git a/tests/Alchemy/Phrasea/Border/Checker/MediaTypeTest.php b/tests/Alchemy/Phrasea/Border/Checker/MediaTypeTest.php index 8f4b899e79..8665a7619c 100644 --- a/tests/Alchemy/Phrasea/Border/Checker/MediaTypeTest.php +++ b/tests/Alchemy/Phrasea/Border/Checker/MediaTypeTest.php @@ -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()); diff --git a/tests/Alchemy/Phrasea/Border/Checker/Sha256Test.php b/tests/Alchemy/Phrasea/Border/Checker/Sha256Test.php index db5e89aa45..a901fd2bef 100644 --- a/tests/Alchemy/Phrasea/Border/Checker/Sha256Test.php +++ b/tests/Alchemy/Phrasea/Border/Checker/Sha256Test.php @@ -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'])); diff --git a/tests/Alchemy/Phrasea/Border/Checker/UUIDTest.php b/tests/Alchemy/Phrasea/Border/Checker/UUIDTest.php index 75462cd405..eccb22d7f3 100644 --- a/tests/Alchemy/Phrasea/Border/Checker/UUIDTest.php +++ b/tests/Alchemy/Phrasea/Border/Checker/UUIDTest.php @@ -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); diff --git a/tests/Alchemy/Phrasea/Border/FileTest.php b/tests/Alchemy/Phrasea/Border/FileTest.php index a60e2665ed..e4d77d527c 100644 --- a/tests/Alchemy/Phrasea/Border/FileTest.php +++ b/tests/Alchemy/Phrasea/Border/FileTest.php @@ -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()); } diff --git a/tests/Alchemy/Phrasea/Border/ManagerTest.php b/tests/Alchemy/Phrasea/Border/ManagerTest.php index c217514cec..588da02088 100644 --- a/tests/Alchemy/Phrasea/Border/ManagerTest.php +++ b/tests/Alchemy/Phrasea/Border/ManagerTest.php @@ -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); diff --git a/tests/Alchemy/Phrasea/Controller/Admin/AdminCollectionTest.php b/tests/Alchemy/Phrasea/Controller/Admin/AdminCollectionTest.php index d2e16c1fda..6b5b63488b 100644 --- a/tests/Alchemy/Phrasea/Controller/Admin/AdminCollectionTest.php +++ b/tests/Alchemy/Phrasea/Controller/Admin/AdminCollectionTest.php @@ -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) { diff --git a/tests/Alchemy/Phrasea/Controller/Admin/DataboxTest.php b/tests/Alchemy/Phrasea/Controller/Admin/DataboxTest.php index ffcf4ed163..160dd8ecc8 100644 --- a/tests/Alchemy/Phrasea/Controller/Admin/DataboxTest.php +++ b/tests/Alchemy/Phrasea/Controller/Admin/DataboxTest.php @@ -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) { diff --git a/tests/PhraseanetPHPUnitAbstract.class.inc b/tests/PhraseanetPHPUnitAbstract.class.inc index c7555be8f4..f7c0c5e79c 100644 --- a/tests/PhraseanetPHPUnitAbstract.class.inc +++ b/tests/PhraseanetPHPUnitAbstract.class.inc @@ -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); }); diff --git a/tests/collectionTest.php b/tests/collectionTest.php index 8b6a0f4f7a..e985f81c41 100644 --- a/tests/collectionTest.php +++ b/tests/collectionTest.php @@ -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(); diff --git a/tests/media/media_subdefTest.php b/tests/media/media_subdefTest.php index 2fed349759..81e8e957dc 100644 --- a/tests/media/media_subdefTest.php +++ b/tests/media/media_subdefTest.php @@ -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']);