Update Border File API

This commit is contained in:
Romain Neutron
2012-09-28 19:12:28 +02:00
parent f66cc5eb04
commit ad11bd0f51
24 changed files with 70 additions and 68 deletions

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border; namespace Alchemy\Phrasea\Border;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Media\Type\Audio; use Alchemy\Phrasea\Media\Type\Audio;
use Alchemy\Phrasea\Media\Type\Document; use Alchemy\Phrasea\Media\Type\Document;
use Alchemy\Phrasea\Media\Type\Flash; use Alchemy\Phrasea\Media\Type\Flash;
@@ -46,6 +47,7 @@ class File
protected $media; protected $media;
protected $uuid; protected $uuid;
protected $sha256; protected $sha256;
protected $app;
protected $originalName; protected $originalName;
protected $md5; protected $md5;
protected $attributes; protected $attributes;
@@ -53,14 +55,16 @@ class File
/** /**
* Constructor * Constructor
* *
* @param Applciation $app Application context
* @param MediaInterface $media The media * @param MediaInterface $media The media
* @param \collection $collection The destination collection * @param \collection $collection The destination collection
* @param string $originalName The original name of the file * @param string $originalName The original name of the file
* (if not provided, original name is * (if not provided, original name is
* extracted from the pathfile) * 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->media = $media;
$this->collection = $collection; $this->collection = $collection;
$this->attributes = array(); $this->attributes = array();
@@ -128,8 +132,6 @@ class File
} }
if ($write) { if ($write) {
$writer = new Writer(new Exiftool());
$value = new MonoValue($this->uuid); $value = new MonoValue($this->uuid);
$metadatas = new MetadataBag(); $metadatas = new MetadataBag();
@@ -141,13 +143,13 @@ class File
* PHPExiftool throws exception on some files not supported * PHPExiftool throws exception on some files not supported
*/ */
try { try {
$writer->write($this->getFile()->getRealPath(), $metadatas); $this->app['exiftool.writer']->write($this->getFile()->getRealPath(), $metadatas);
} catch (PHPExiftoolException $e) { } catch (PHPExiftoolException $e) {
} }
} }
$writer = $reader = $metadatas = null; $reader = $metadatas = null;
return $this->uuid; return $this->uuid;
} }
@@ -282,14 +284,14 @@ class File
* *
* @return \Alchemy\Phrasea\Border\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 { try {
$media = $mediavorus->guess($pathfile); $media = $app['mediavorus']->guess($pathfile);
} catch (FileNotFoundException $e) { } catch (FileNotFoundException $e) {
throw new \InvalidArgumentException(sprintf('Unable to build media file from non existant %s', $pathfile)); 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);
} }
} }

View File

@@ -93,7 +93,7 @@ class RecordAdd extends Command
$media = $this->container['mediavorus']->guess($file); $media = $this->container['mediavorus']->guess($file);
} }
$file = new File($media, $collection, $originalName); $file = new File($this->container, $media, $collection, $originalName);
$session = new LazaretSession(); $session = new LazaretSession();
$this->container['EM']->persist($session); $this->container['EM']->persist($session);

View File

@@ -126,7 +126,7 @@ class Step31 implements DatasUpgraderInterface
$media = $this->app['mediavorus']->guess($pathfile); $media = $this->app['mediavorus']->guess($pathfile);
$collection = \collection::get_from_coll_id($app, $databox, (int) $record['coll_id']); $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); $uuid = $file->getUUID(true, true);
$sha256 = $file->getSha256(); $sha256 = $file->getSha256();

View File

@@ -263,7 +263,7 @@ class Lazaret implements ControllerProviderInterface
try { try {
$borderFile = Border\File::buildFromPathfile( $borderFile = Border\File::buildFromPathfile(
$lazaretFileName, $lazaretFile->getCollection($app), $app['mediavorus'], $lazaretFile->getOriginalName() $lazaretFileName, $lazaretFile->getCollection($app), $app, $lazaretFile->getOriginalName()
); );
$record = null; $record = null;

View File

@@ -192,7 +192,7 @@ class Upload implements ControllerProviderInterface
$app['EM']->persist($lazaretSession); $app['EM']->persist($lazaretSession);
$packageFile = new File($media, $collection, $file->getClientOriginalName()); $packageFile = new File($app, $media, $collection, $file->getClientOriginalName());
$postStatus = $request->request->get('status'); $postStatus = $request->request->get('status');

View File

@@ -659,7 +659,7 @@ class API_V1_adapter extends API_V1_Abstract
$media = $app['mediavorus']->guess($file->getPathname()); $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')) { if ($request->get('status')) {
$Package->addAttribute(new Status($app, $request->get('status'))); $Package->addAttribute(new Status($app, $request->get('status')));

View File

@@ -110,7 +110,7 @@ class patch_370a7 implements patchInterface
$collection = \collection::get_from_base_id($app, $row['base_id']); $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 = new \Entities\LazaretSession();
$lazaretSession->setUsrId($row['usr_id']); $lazaretSession->setUsrId($row['usr_id']);

View File

@@ -1688,7 +1688,7 @@ class task_period_archive extends task_abstract
$metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption); $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)); $file->addAttribute(new BorderAttribute\Status($this->dependencyContainer, $status));

View File

@@ -969,7 +969,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
{ {
$this->setToken(self::$token); $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']); $record = \record_adapter::createFromFile($file, self::$DI['app']);
$route = '/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setmetadatas/'; $route = '/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setmetadatas/';
@@ -1089,7 +1089,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
*/ */
public function testMoveRecordToCollection() 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']); $record = \record_adapter::createFromFile($file, self::$DI['app']);
$this->setToken(self::$token); $this->setToken(self::$token);
@@ -1790,7 +1790,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$tmpname = tempnam(sys_get_temp_dir(), 'test_quarantine'); $tmpname = tempnam(sys_get_temp_dir(), 'test_quarantine');
copy(__DIR__ . '/../../../testfiles/iphone_pic.jpg', $tmpname); 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); self::$DI['app']['border-manager']->process($lazaretSession, $file, $callback, \Alchemy\Phrasea\Border\Manager::FORCE_LAZARET);
return $quarantineItem; return $quarantineItem;

View File

@@ -33,7 +33,7 @@ class ApplicationOverviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$media = self::$DI['app']['mediavorus']->guess($tmp); $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 = record_adapter::createFromFile($file, self::$DI['app']);
$record->generate_subdefs($record->get_databox(), self::$DI['app']); $record->generate_subdefs($record->get_databox(), self::$DI['app']);

View File

@@ -37,7 +37,7 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract
->method('getFile') ->method('getFile')
->will($this->returnValue(new \SplFileInfo(__FILE__))); ->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); $response = $this->object->check(self::$DI['app']['EM'], $File);

View File

@@ -33,7 +33,7 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
->method('getFile') ->method('getFile')
->will($this->returnValue(new \SplFileInfo(__FILE__))); ->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)); $object = new Dimension(self::$DI['app'], array('width' => 800));
$response = $object->check(self::$DI['app']['EM'], $File); $response = $object->check(self::$DI['app']['EM'], $File);

View File

@@ -49,7 +49,7 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract
->method('getFile') ->method('getFile')
->will($this->returnValue($spl)); ->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); $response = $this->object->check(self::$DI['app']['EM'], $File);

View File

@@ -42,7 +42,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testCheck() 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); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);

View File

@@ -29,7 +29,7 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract
public function testCheck() public function testCheck()
{ {
$media = self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'); $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); $response = $this->object->check(self::$DI['app']['EM'], $file);
$this->assertTrue($response->isOk()); $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))); $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'); $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); $response = $object->check(self::$DI['app']['EM'], $file);
$this->assertFalse($response->isOk()); $this->assertFalse($response->isOk());

View File

@@ -41,7 +41,7 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
$session = new \Entities\LazaretSession(); $session = new \Entities\LazaretSession();
self::$DI['app']['EM']->persist($session); 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'])); $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getSha256'), array($this->media, self::$DI['collection']));

View File

@@ -38,7 +38,7 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testCheck() 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); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);

View File

@@ -37,7 +37,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$this->media = self::$DI['app']['mediavorus']->guess($this->filename); $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); 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); $uuid = $borderFile->getUUID(true, false);
$this->assertTrue(\uuid::is_valid($uuid)); $this->assertTrue(\uuid::is_valid($uuid));
$this->assertEquals($uuid, $borderFile->getUUID()); $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); $newuuid = $borderFile->getUUID(true, true);
$this->assertTrue(\uuid::is_valid($newuuid)); $this->assertTrue(\uuid::is_valid($newuuid));
$this->assertNotEquals($uuid, $newuuid); $this->assertNotEquals($uuid, $newuuid);
$this->assertEquals($newuuid, $borderFile->getUUID()); $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(); $uuid = $borderFile->getUUID();
$this->assertTrue(\uuid::is_valid($uuid)); $this->assertTrue(\uuid::is_valid($uuid));
@@ -152,7 +152,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testOriginalNameAuto() 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()); $this->assertSame('iphone_pic.jpg', $object->getOriginalName());
} }
@@ -194,16 +194,16 @@ class FileTest extends \PhraseanetPHPUnitAbstract
public function testBuildFromPathfile() public function testBuildFromPathfile()
{ {
$media = self::$DI['app']['mediavorus']->guess($this->filename); $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); $this->assertEquals($file1, $file2);
$media = self::$DI['app']['mediavorus']->guess($this->filename); $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->assertEquals($file3, $file4);
$this->assertNotEquals($file1, $file4); $this->assertNotEquals($file1, $file4);
@@ -215,7 +215,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testBuildFromWrongPathfile() 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) protected function getMediaMock($type)
@@ -238,7 +238,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
{ {
$image = $this->getMediaMock(MediaInterface::TYPE_IMAGE); $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()); $this->assertEquals(new Image(), $file->getType());
} }
@@ -250,7 +250,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
{ {
$document = $this->getMediaMock(MediaInterface::TYPE_DOCUMENT); $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()); $this->assertEquals(new Document(), $file->getType());
} }
@@ -262,7 +262,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
{ {
$audio = $this->getMediaMock(MediaInterface::TYPE_AUDIO); $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()); $this->assertEquals(new Audio(), $file->getType());
} }
@@ -274,7 +274,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
{ {
$video = $this->getMediaMock(MediaInterface::TYPE_VIDEO); $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()); $this->assertEquals(new Video(), $file->getType());
} }
@@ -286,7 +286,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
{ {
$flash = $this->getMediaMock(MediaInterface::TYPE_FLASH); $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()); $this->assertEquals(new Flash(), $file->getType());
} }
@@ -298,7 +298,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
{ {
$noType = $this->getMediaMock(null); $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()); $this->assertNull($file->getType());
} }

View File

@@ -73,7 +73,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$records[] = $record; $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']); $shaChecker = new Checker\Sha256(self::$DI['app']);
$this->object->registerChecker($shaChecker); $this->object->registerChecker($shaChecker);
@@ -86,7 +86,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$records[] = $element; $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) { $postProcess = function($element, $visa, $code) use ($phpunit, &$records) {
$phpunit->assertInstanceOf('\\record_adapter', $element); $phpunit->assertInstanceOf('\\record_adapter', $element);
@@ -95,7 +95,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$records[] = $element; $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) { foreach ($records as $record) {
if ($record instanceof \record_adapter) { if ($record instanceof \record_adapter) {
@@ -114,8 +114,8 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$postProcessRecord = function($record) use (&$records) { $postProcessRecord = function($record) use (&$records) {
$records[] = $record; $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::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']['mediavorus']), $postProcessRecord)); $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) { foreach ($records as $record) {
if ($record instanceof \record_adapter) { if ($record instanceof \record_adapter) {
@@ -135,7 +135,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$records[] = $record; $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; $first = $odd = false;
$tofetch = array(); $tofetch = array();
foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) { foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) {
@@ -245,7 +245,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$lazaret = $element; $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; $odd = false;
$tofetchMeta = $tofetchField = array(); $tofetchMeta = $tofetchField = array();
foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) { foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) {
@@ -357,7 +357,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testLazaretAttributes() 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(); $objectNameTag = new \PHPExiftool\Driver\Tag\IPTC\ObjectName();
$monoValue = new \PHPExiftool\Driver\Value\Mono('title'); $monoValue = new \PHPExiftool\Driver\Value\Mono('title');
@@ -400,7 +400,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$manager->setPdfToText(self::$DI['app']['xpdf.pdf2text']); $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()); $count = count($file->getAttributes());
$manager->addMediaAttributesTester($file); $manager->addMediaAttributesTester($file);
@@ -448,7 +448,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$manager = new ManagerTester(self::$DI['app']); $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()); $count = count($file->getAttributes());
$manager->addMediaAttributesTester($file); $manager->addMediaAttributesTester($file);
@@ -495,7 +495,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$manager = new ManagerTester(self::$DI['app']); $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()); $count = count($file->getAttributes());
$manager->addMediaAttributesTester($file); $manager->addMediaAttributesTester($file);
@@ -546,15 +546,15 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$records[] = $record; $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->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
$this->assertTrue($visa->isValid()); $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); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
@@ -562,7 +562,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->object->registerChecker(new Checker\Sha256(self::$DI['app'])); $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); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);

View File

@@ -110,7 +110,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection(); $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']); \record_adapter::createFromFile($file, self::$DI['app']);
self::$DI['client']->request('GET', '/admin/collection/' . $collection->get_base_id() . '/informations/details/'); self::$DI['client']->request('GET', '/admin/collection/' . $collection->get_base_id() . '/informations/details/');
@@ -430,7 +430,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection(); $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']); \record_adapter::createFromFile($file, self::$DI['app']);
if ($collection->get_record_amount() === 0) { if ($collection->get_record_amount() === 0) {
@@ -827,7 +827,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection(); $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']); \record_adapter::createFromFile($file, self::$DI['app']);
if ($collection->get_record_amount() === 0) { if ($collection->get_record_amount() === 0) {

View File

@@ -570,7 +570,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$base = $this->createDatabox(); $base = $this->createDatabox();
$collection = \collection::create(self::$DI['app'], $base, self::$DI['app']['phraseanet.appbox'], 'TESTTODELETE'); $collection = \collection::create(self::$DI['app'], $base, self::$DI['app']['phraseanet.appbox'], 'TESTTODELETE');
self::$createdCollections[] = $collection; 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']); \record_adapter::createFromFile($file, self::$DI['app']);
if ($collection->get_record_amount() === 0) { if ($collection->get_record_amount() === 0) {

View File

@@ -754,7 +754,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
PhraseanetPHPUnitAbstract::$recordsInitialized[] = $i; PhraseanetPHPUnitAbstract::$recordsInitialized[] = $i;
// echo "\t\t\tcreating record $i step #1 ".(microtime(true)-$start)."\n"; // 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"; // echo "\t\t\tcreating record $i step #2 ".(microtime(true)-$start)."\n";
$record = record_adapter::createFromFile($file, $app); $record = record_adapter::createFromFile($file, $app);
@@ -779,7 +779,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access'; 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); return \record_adapter::createFromFile($file, $app);
}); });
@@ -788,7 +788,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access_by_status'; 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); return \record_adapter::createFromFile($file, $app);
}); });

View File

@@ -86,7 +86,7 @@ class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record_amount() public function testGet_record_amount()
{ {
self::$object->empty_collection(); 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']); record_adapter::createFromFile($file, self::$DI['app']);
$this->assertTrue(self::$object->get_record_amount() === 1); $this->assertTrue(self::$object->get_record_amount() === 1);
self::$object->empty_collection(); self::$object->empty_collection();
@@ -133,7 +133,7 @@ class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record_details() 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']); $record = record_adapter::createFromFile($file, self::$DI['app']);
$details = self::$object->get_record_details(); $details = self::$object->get_record_details();

View File

@@ -34,7 +34,7 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
{ {
parent::setUpBeforeClass(); 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 = record_adapter::createFromFile($file, self::$DI['app']);
self::$recordonbleu->generate_subdefs(self::$recordonbleu->get_databox(), self::$DI['app']); self::$recordonbleu->generate_subdefs(self::$recordonbleu->get_databox(), self::$DI['app']);