Update Phrasea Border to the latest service

This commit is contained in:
Romain Neutron
2012-09-11 23:15:22 +02:00
parent cf7fcf490c
commit eb9600b19e
32 changed files with 357 additions and 274 deletions

View File

@@ -11,10 +11,12 @@
namespace Alchemy\Phrasea\Border\Attribute; namespace Alchemy\Phrasea\Border\Attribute;
use Alchemy\Phrasea\Application;
/** /**
* File attribute interface * File attribute interface
*/ */
interface Attribute interface AttributeInterface
{ {
const NAME_METADATA = 'metadata'; const NAME_METADATA = 'metadata';
const NAME_METAFIELD = 'metafield'; const NAME_METAFIELD = 'metafield';
@@ -43,7 +45,10 @@ interface Attribute
/** /**
* Build the current object with is string value * Build the current object with is string value
* *
* @param Application $app the application context
* @param string $string the serialized string
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public static function loadFromString($string); public static function loadFromString(Application $app, $string);
} }

View File

@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Border\Attribute; namespace Alchemy\Phrasea\Border\Attribute;
use Alchemy\Phrasea\Application;
/** /**
* This factory is intended to create Attribute based on their name and * This factory is intended to create Attribute based on their name and
* serialized values. This is mostly used when reading Lazaret tables * serialized values. This is mostly used when reading Lazaret tables
@@ -21,27 +23,28 @@ class Factory
/** /**
* Build a file package Attribute * Build a file package Attribute
* *
* @param string $name The name of the attribute, one of the * @param Application $app Application context
* @param string $name The name of the attribute, one of the
* Attribute::NAME_* constants * Attribute::NAME_* constants
* @param string $serialized The serialized value of the attribute * @param string $serialized The serialized value of the attribute
* (Attribute::asString result) * (Attribute::asString result)
* @return Attribute The attribute * @return AttributeInterface The attribute
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public static function getFileAttribute($name, $serialized) public static function getFileAttribute(Application $app, $name, $serialized)
{ {
switch ($name) { switch ($name) {
case Attribute::NAME_METADATA: case AttributeInterface::NAME_METADATA:
return Metadata::loadFromString($serialized); return Metadata::loadFromString($app, $serialized);
break; break;
case Attribute::NAME_STORY: case AttributeInterface::NAME_STORY:
return Story::loadFromString($serialized); return Story::loadFromString($app, $serialized);
break; break;
case Attribute::NAME_METAFIELD: case AttributeInterface::NAME_METAFIELD:
return MetaField::loadFromString($serialized); return MetaField::loadFromString($app, $serialized);
break; break;
case Attribute::NAME_STATUS: case AttributeInterface::NAME_STATUS:
return Status::loadFromString($serialized); return Status::loadFromString($app, $serialized);
break; break;
} }

View File

@@ -11,13 +11,15 @@
namespace Alchemy\Phrasea\Border\Attribute; namespace Alchemy\Phrasea\Border\Attribute;
use Alchemy\Phrasea\Application;
/** /**
* Phraseanet Border MetaField Attribute * Phraseanet Border MetaField Attribute
* *
* This attribute is used to store a value related to a fieldname for a file * This attribute is used to store a value related to a fieldname for a file
* prior to their record creation * prior to their record creation
*/ */
class MetaField implements Attribute class MetaField implements AttributeInterface
{ {
/** /**
* *
@@ -35,13 +37,13 @@ class MetaField implements Attribute
* Constructor * Constructor
* *
* @param \databox_field $databox_field The databox field * @param \databox_field $databox_field The databox field
* @param type $value A scalar value * @param string $value A scalar value
* *
* @throws \InvalidArgumentException When value is not scalar * @throws \InvalidArgumentException When value is not scalar
*/ */
public function __construct(\databox_field $databox_field, $value) public function __construct(\databox_field $databox_field, $value)
{ {
if ( ! is_scalar($value)) { if (!is_scalar($value)) {
throw new \InvalidArgumentException('Databox field only accept scalar values'); throw new \InvalidArgumentException('Databox field only accept scalar values');
} }
$this->databox_field = $databox_field; $this->databox_field = $databox_field;
@@ -101,20 +103,18 @@ class MetaField implements Attribute
* *
* @return MetaField * @return MetaField
*/ */
public static function loadFromString($string) public static function loadFromString(Application $app, $string)
{ {
if ( ! $datas = @unserialize($string)) { if (!$datas = @unserialize($string)) {
throw new \InvalidArgumentException('Unable to load metadata from string'); throw new \InvalidArgumentException('Unable to load metadata from string');
} }
try { try {
$appbox = \appbox::get_instance(\bootstrap::getCore()); return new static($app['phraseanet.appbox']
$databox = $appbox->get_databox($datas['sbas_id']); ->get_databox($datas['sbas_id'])
$field = $databox->get_meta_structure()->get_element($datas['id']); ->get_meta_structure()->get_element($datas['id']), $datas['value']);
} catch (\Exception_NotFound $e) { } catch (\Exception_NotFound $e) {
throw new \InvalidArgumentException('Field does not exist anymore'); throw new \InvalidArgumentException('Field does not exist anymore');
} }
return new static($field, $datas['value']);
} }
} }

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Attribute; namespace Alchemy\Phrasea\Border\Attribute;
use Alchemy\Phrasea\Application;
use PHPExiftool\Driver\Metadata\Metadata as ExiftoolMeta; use PHPExiftool\Driver\Metadata\Metadata as ExiftoolMeta;
/** /**
@@ -19,7 +20,7 @@ use PHPExiftool\Driver\Metadata\Metadata as ExiftoolMeta;
* This attribute is used to store a PHPExiftool metadatas with file prior to * This attribute is used to store a PHPExiftool metadatas with file prior to
* their record creation * their record creation
*/ */
class Metadata implements Attribute class Metadata implements AttributeInterface
{ {
protected $metadata; protected $metadata;
@@ -72,13 +73,13 @@ class Metadata implements Attribute
* *
* @return Metadata * @return Metadata
*/ */
public static function loadFromString($string) public static function loadFromString(Application $app, $string)
{ {
if ( ! $metadata = @unserialize($string)) { if ( ! $metadata = @unserialize($string)) {
throw new \InvalidArgumentException('Unable to load metadata from string'); throw new \InvalidArgumentException('Unable to load metadata from string');
} }
if ( ! $metadata instanceof ExiftoolMeta) { if (! $metadata instanceof ExiftoolMeta) {
throw new \InvalidArgumentException('Unable to load metadata from string'); throw new \InvalidArgumentException('Unable to load metadata from string');
} }

View File

@@ -11,7 +11,9 @@
namespace Alchemy\Phrasea\Border\Attribute; namespace Alchemy\Phrasea\Border\Attribute;
class Status implements Attribute use Alchemy\Phrasea\Application;
class Status implements AttributeInterface
{ {
protected $status; protected $status;
@@ -54,7 +56,7 @@ class Status implements Attribute
return $this->status; return $this->status;
} }
public static function loadFromString($string) public static function loadFromString(Application $app, $string)
{ {
return new static($string); return new static($string);
} }

View File

@@ -11,13 +11,15 @@
namespace Alchemy\Phrasea\Border\Attribute; namespace Alchemy\Phrasea\Border\Attribute;
use Alchemy\Phrasea\Application;
/** /**
* Phraseanet Border Story Attribute * Phraseanet Border Story Attribute
* *
* This attribute is used to store a destination story for a file, prior to * This attribute is used to store a destination story for a file, prior to
* their record creation * their record creation
*/ */
class Story implements Attribute class Story implements AttributeInterface
{ {
protected $story; protected $story;
@@ -74,12 +76,12 @@ class Story implements Attribute
* *
* @return Story * @return Story
*/ */
public static function loadFromString($string) public static function loadFromString(Application $app, $string)
{ {
$ids = explode('_', $string); $ids = explode('_', $string);
try { try {
$story = new \record_adapter($ids[0], $ids[1]); $story = new \record_adapter($app, $ids[0], $ids[1]);
} catch (\Exception_NotFound $e) { } catch (\Exception_NotFound $e) {
throw new \InvalidArgumentException('Unable to fetch a story from string'); throw new \InvalidArgumentException('Unable to fetch a story from string');
} }

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
/** /**
@@ -18,9 +19,15 @@ use Alchemy\Phrasea\Border\File;
*/ */
abstract class AbstractChecker implements CheckerInterface abstract class AbstractChecker implements CheckerInterface
{ {
protected $app;
protected $databoxes = array(); protected $databoxes = array();
protected $collections = array(); protected $collections = array();
public function __construct(Application $app)
{
$this->app = $app;
}
/** /**
* Restrict the checker to a set of databoxes. * Restrict the checker to a set of databoxes.
* Warning, you can not restrict on both databoxes and collections * Warning, you can not restrict on both databoxes and collections
@@ -40,7 +47,7 @@ abstract class AbstractChecker implements CheckerInterface
$this->databoxes = array(); $this->databoxes = array();
foreach ($this->toIterator($databoxes) as $databox) { foreach ($this->toIterator($databoxes) as $databox) {
if ( ! $databox instanceof \databox) { if (! $databox instanceof \databox) {
throw new \InvalidArgumentException('Restrict to databoxes only accept databoxes as argument'); throw new \InvalidArgumentException('Restrict to databoxes only accept databoxes as argument');
} }
$this->databoxes[] = $databox; $this->databoxes[] = $databox;
@@ -68,7 +75,7 @@ abstract class AbstractChecker implements CheckerInterface
$this->collections = array(); $this->collections = array();
foreach ($this->toIterator($collections) as $collection) { foreach ($this->toIterator($collections) as $collection) {
if ( ! $collection instanceof \collection) { if (! $collection instanceof \collection) {
throw new \InvalidArgumentException('Restrict to collections only accept collections as argument'); throw new \InvalidArgumentException('Restrict to collections only accept collections as argument');
} }
$this->collections[] = $collection; $this->collections[] = $collection;

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
@@ -22,13 +23,14 @@ class Colorspace extends AbstractChecker
const COLORSPACE_CMYK = 'cmyk'; const COLORSPACE_CMYK = 'cmyk';
const COLORSPACE_GRAYSCALE = 'grayscale'; const COLORSPACE_GRAYSCALE = 'grayscale';
public function __construct(array $options) public function __construct(Application $app, array $options)
{ {
if ( ! isset($options['colorspaces'])) { if ( ! isset($options['colorspaces'])) {
throw new \InvalidArgumentException('Missing "colorspaces" options'); throw new \InvalidArgumentException('Missing "colorspaces" options');
} }
$this->colorspaces = array_map('strtolower', (array) $options['colorspaces']); $this->colorspaces = array_map('strtolower', (array) $options['colorspaces']);
parent::__construct($app);
} }
public function check(EntityManager $em, File $file) public function check(EntityManager $em, File $file)

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
@@ -19,7 +20,7 @@ class Dimension extends AbstractChecker
protected $width; protected $width;
protected $height; protected $height;
public function __construct(array $options) public function __construct(Application $app, array $options)
{ {
if ( ! isset($options['width'])) { if ( ! isset($options['width'])) {
throw new \InvalidArgumentException('Missing "width" option'); throw new \InvalidArgumentException('Missing "width" option');
@@ -35,6 +36,7 @@ class Dimension extends AbstractChecker
$this->width = $options['width']; $this->width = $options['width'];
$this->height = $options['height']; $this->height = $options['height'];
parent::__construct($app);
} }
public function check(EntityManager $em, File $file) public function check(EntityManager $em, File $file)

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
@@ -18,13 +19,14 @@ class Extension extends AbstractChecker
{ {
protected $extensions; protected $extensions;
public function __construct(array $options) public function __construct(Application $app, array $options)
{ {
if ( ! isset($options['extensions'])) { if ( ! isset($options['extensions'])) {
throw new \InvalidArgumentException('Missing "extensions" options'); throw new \InvalidArgumentException('Missing "extensions" options');
} }
$this->extensions = array_map('strtolower', (array) $options['extensions']); $this->extensions = array_map('strtolower', (array) $options['extensions']);
parent::__construct($app);
} }
public function check(EntityManager $em, File $file) public function check(EntityManager $em, File $file)

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
@@ -26,13 +27,14 @@ class Filename extends AbstractChecker
* *
* @param boolean $sensitive Toggle case-sensitive mode, default : false * @param boolean $sensitive Toggle case-sensitive mode, default : false
*/ */
public function __construct(array $options = array()) public function __construct(Application $app, array $options = array())
{ {
if ( ! isset($options['sensitive'])) { if ( ! isset($options['sensitive'])) {
$options['sensitive'] = false; $options['sensitive'] = false;
} }
$this->sensitive = (boolean) $options['sensitive']; $this->sensitive = (boolean) $options['sensitive'];
parent::__construct($app);
} }
/** /**

View File

@@ -11,31 +11,35 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use MediaVorus\Media\MediaInterface;
class MediaType extends AbstractChecker class MediaType extends AbstractChecker
{ {
protected $mediaTypes; protected $mediaTypes;
const TYPE_AUDIO = \MediaVorus\Media\Media::TYPE_AUDIO; const TYPE_AUDIO = MediaInterface::TYPE_AUDIO;
const TYPE_DOCUMENT = \MediaVorus\Media\Media::TYPE_DOCUMENT; const TYPE_DOCUMENT = MediaInterface::TYPE_DOCUMENT;
const TYPE_FLASH = \MediaVorus\Media\Media::TYPE_FLASH; const TYPE_FLASH = MediaInterface::TYPE_FLASH;
const TYPE_IMAGE = \MediaVorus\Media\Media::TYPE_IMAGE; const TYPE_IMAGE = MediaInterface::TYPE_IMAGE;
const TYPE_VIDEO = \MediaVorus\Media\Media::TYPE_VIDEO; const TYPE_VIDEO = MediaInterface::TYPE_VIDEO;
public function __construct(array $options) public function __construct(Application $app, array $options)
{ {
if ( ! isset($options['mediatypes'])) { if ( ! isset($options['mediatypes'])) {
throw new \InvalidArgumentException('Missing "mediatypes" options'); throw new \InvalidArgumentException('Missing "mediatypes" options');
} }
$this->mediaTypes = (array) $options['mediatypes']; $this->mediaTypes = (array) $options['mediatypes'];
parent::__construct($app);
} }
public function check(EntityManager $em, File $file) public function check(EntityManager $em, File $file)
{ {
if (0 === count($this->mediaTypes)) { //if empty authorize all mediative // if empty authorize all mediative
if (0 === count($this->mediaTypes)) {
$boolean = true; $boolean = true;
} else { } else {
$boolean = in_array($file->getMedia()->getType(), $this->mediaTypes); $boolean = in_array($file->getMedia()->getType(), $this->mediaTypes);

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
@@ -21,13 +22,18 @@ use Doctrine\ORM\EntityManager;
class Sha256 extends AbstractChecker class Sha256 extends AbstractChecker
{ {
public function __construct(Application $app)
{
parent::__construct($app);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function check(EntityManager $em, File $file) public function check(EntityManager $em, File $file)
{ {
$boolean = ! count(\record_adapter::get_record_by_sha( $boolean = ! count(\record_adapter::get_record_by_sha(
$file->getCollection()->get_databox()->get_sbas_id(), $file->getSha256() $this->app, $file->getCollection()->get_databox()->get_sbas_id(), $file->getSha256()
)); ));
return new Response($boolean, $this); return new Response($boolean, $this);

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
@@ -20,13 +21,18 @@ use Doctrine\ORM\EntityManager;
class UUID extends AbstractChecker class UUID extends AbstractChecker
{ {
public function __construct(Application $app)
{
parent::__construct($app);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function check(EntityManager $em, File $file) public function check(EntityManager $em, File $file)
{ {
$boolean = ! count(\record_adapter::get_record_by_uuid( $boolean = ! count(\record_adapter::get_record_by_uuid(
$file->getCollection()->get_databox(), $file->getUUID() $this->app, $file->getCollection()->get_databox(), $file->getUUID()
)); ));
return new Response($boolean, $this); return new Response($boolean, $this);

View File

@@ -11,14 +11,21 @@
namespace Alchemy\Phrasea\Border; namespace Alchemy\Phrasea\Border;
use Alchemy\Phrasea\Media\Type as MediaType; use Alchemy\Phrasea\Media\Type\Audio;
use MediaVorus\Media\Media; use Alchemy\Phrasea\Media\Type\Document;
use Alchemy\Phrasea\Media\Type\Flash;
use Alchemy\Phrasea\Media\Type\Image;
use Alchemy\Phrasea\Media\Type\Video;
use MediaVorus\Media\MediaInterface;
use MediaVorus\MediaVorus; use MediaVorus\MediaVorus;
use MediaVorus\Exception\FileNotFoundException;
use PHPExiftool\Writer; use PHPExiftool\Writer;
use PHPExiftool\Driver\TagFactory; use PHPExiftool\Driver\TagFactory;
use PHPExiftool\Driver\Metadata\Metadata; use PHPExiftool\Driver\Metadata\Metadata;
use PHPExiftool\Driver\Metadata\MetadataBag; use PHPExiftool\Driver\Metadata\MetadataBag;
use PHPExiftool\Driver\Value\Mono as MonoValue; use PHPExiftool\Driver\Value\Mono as MonoValue;
use PHPExiftool\Exiftool;
use PHPExiftool\Exception\ExceptionInterface as PHPExiftoolException;
/** /**
* Phraseanet candidate File package * Phraseanet candidate File package
@@ -33,7 +40,7 @@ class File
/** /**
* *
* @var \MediaVorus\Media\Media * @var \MediaVorus\Media\MediaInterface
*/ */
protected $media; protected $media;
protected $uuid; protected $uuid;
@@ -45,13 +52,13 @@ class File
/** /**
* Constructor * Constructor
* *
* @param Media $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(Media $media, \collection $collection, $originalName = null) public function __construct(MediaInterface $media, \collection $collection, $originalName = null)
{ {
$this->media = $media; $this->media = $media;
$this->collection = $collection; $this->collection = $collection;
@@ -94,8 +101,8 @@ class File
'Canon:ImageUniqueID', 'Canon:ImageUniqueID',
); );
if ( ! $this->uuid) { if (! $this->uuid) {
$metadatas = $this->media->getEntity()->getMetadatas(); $metadatas = $this->media->getMetadatas();
$uuid = null; $uuid = null;
@@ -109,7 +116,7 @@ class File
} }
} }
if ( ! $uuid && $generate) { if (! $uuid && $generate) {
/** /**
* @todo Check if a file exists with the same checksum * @todo Check if a file exists with the same checksum
*/ */
@@ -120,7 +127,7 @@ class File
} }
if ($write) { if ($write) {
$writer = new Writer(); $writer = new Writer(new Exiftool());
$value = new MonoValue($this->uuid); $value = new MonoValue($this->uuid);
$metadatas = new MetadataBag(); $metadatas = new MetadataBag();
@@ -134,7 +141,7 @@ class File
*/ */
try { try {
$writer->write($this->getFile()->getRealPath(), $metadatas); $writer->write($this->getFile()->getRealPath(), $metadatas);
} catch (\PHPExiftool\Exception\Exception $e) { } catch (PHPExiftoolException $e) {
} }
} }
@@ -151,20 +158,20 @@ class File
public function getType() public function getType()
{ {
switch ($this->media->getType()) { switch ($this->media->getType()) {
case Media::TYPE_AUDIO: case MediaInterface::TYPE_AUDIO:
return new MediaType\Audio(); return new Audio();
break; break;
case Media::TYPE_DOCUMENT: case MediaInterface::TYPE_DOCUMENT:
return new MediaType\Document(); return new Document();
break; break;
case Media::TYPE_FLASH: case MediaInterface::TYPE_FLASH:
return new MediaType\Flash(); return new Flash();
break; break;
case Media::TYPE_IMAGE: case MediaInterface::TYPE_IMAGE:
return new MediaType\Image(); return new Image();
break; break;
case Media::TYPE_VIDEO: case MediaInterface::TYPE_VIDEO:
return new MediaType\Video(); return new Video();
break; break;
} }
@@ -178,7 +185,7 @@ class File
*/ */
public function getSha256() public function getSha256()
{ {
if ( ! $this->sha256) { if (! $this->sha256) {
$this->sha256 = $this->media->getHash('sha256'); $this->sha256 = $this->media->getHash('sha256');
} }
@@ -192,7 +199,7 @@ class File
*/ */
public function getMD5() public function getMD5()
{ {
if ( ! $this->md5) { if (! $this->md5) {
$this->md5 = $this->media->getHash('md5'); $this->md5 = $this->media->getHash('md5');
} }
@@ -220,9 +227,9 @@ class File
} }
/** /**
* Returns an instance of MediaVorus\Media\Media corresponding to the file * Returns an instance of MediaVorus\Media\MediaInterface corresponding to the file
* *
* @return MediaVorus\Media\Media * @return MediaVorus\Media\MediaInterface
*/ */
public function getMedia() public function getMedia()
{ {
@@ -240,7 +247,7 @@ class File
} }
/** /**
* Returns an array of Attribute\Attribute associated to the file * Returns an array of AttributeInterface associated to the file
* *
* @return array * @return array
*/ */
@@ -252,10 +259,10 @@ class File
/** /**
* Adds an attribute to the file package * Adds an attribute to the file package
* *
* @param Attribute\Attribute $attribute The attribute * @param AttributeInterface $attribute The attribute
* @return File * @return File
*/ */
public function addAttribute(Attribute\Attribute $attribute) public function addAttribute(AttributeInterface $attribute)
{ {
array_push($this->attributes, $attribute); array_push($this->attributes, $attribute);
@@ -267,19 +274,18 @@ class File
* *
* @param string $pathfile The path to the file * @param string $pathfile The path to the file
* @param \collection $collection The destination collection * @param \collection $collection The destination collection
* @param MediaVorus $mediavorus A MediaVorus object
* @param string $originalName An optionnal original name (if * @param string $originalName An optionnal original name (if
* different from the $pathfile filename) * different from the $pathfile filename)
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* *
* @return \Alchemy\Phrasea\Border\File * @return \Alchemy\Phrasea\Border\File
*/ */
public function buildFromPathfile($pathfile, \collection $collection, $originalName = null) public function buildFromPathfile($pathfile, \collection $collection, MediaVorus $mediavorus, $originalName = null)
{ {
$core = \bootstrap::getCore();
try { try {
$media = $core['mediavorus']->guess(new \SplFileInfo($pathfile)); $media = $mediavorus->guess($pathfile);
} catch (\MediaVorus\Exception\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));
} }

View File

@@ -11,18 +11,31 @@
namespace Alchemy\Phrasea\Border; namespace Alchemy\Phrasea\Border;
use Alchemy\Phrasea\Metadata\Tag as PhraseaTag; use Alchemy\Phrasea\Border\Checker\CheckerInterface;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
use Alchemy\Phrasea\Metadata\Tag\PdfText;
use Alchemy\Phrasea\Metadata\Tag\TfArchivedate;
use Alchemy\Phrasea\Metadata\Tag\TfBasename;
use Alchemy\Phrasea\Metadata\Tag\TfBits;
use Alchemy\Phrasea\Metadata\Tag\TfChannels;
use Alchemy\Phrasea\Metadata\Tag\TfDuration;
use Alchemy\Phrasea\Metadata\Tag\TfExtension;
use Alchemy\Phrasea\Metadata\Tag\TfFilename;
use Alchemy\Phrasea\Metadata\Tag\TfHeight;
use Alchemy\Phrasea\Metadata\Tag\TfMimetype;
use Alchemy\Phrasea\Metadata\Tag\TfQuarantine;
use Alchemy\Phrasea\Metadata\Tag\TfRecordid;
use Alchemy\Phrasea\Metadata\Tag\TfSize;
use Alchemy\Phrasea\Metadata\Tag\TfWidth;
use Alchemy\Phrasea\Border\Attribute\Metadata as MetadataAttr; use Alchemy\Phrasea\Border\Attribute\Metadata as MetadataAttr;
use Doctrine\ORM\EntityManager;
use Entities\LazaretAttribute; use Entities\LazaretAttribute;
use Entities\LazaretFile; use Entities\LazaretFile;
use Entities\LazaretSession; use Entities\LazaretSession;
use MediaAlchemyst\Exception\Exception as MediaAlchemystException; use MediaAlchemyst\Exception\Exception as MediaAlchemystException;
use MediaAlchemyst\Specification\Image as ImageSpec; use MediaAlchemyst\Specification\Image as ImageSpec;
use Monolog\Logger;
use PHPExiftool\Driver\Metadata\Metadata; use PHPExiftool\Driver\Metadata\Metadata;
use PHPExiftool\Driver\Value\Mono as MonoValue; use PHPExiftool\Driver\Value\Mono as MonoValue;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Exception\IOException;
use XPDF\PdfToText; use XPDF\PdfToText;
@@ -36,7 +49,7 @@ use XPDF\PdfToText;
class Manager class Manager
{ {
protected $checkers = array(); protected $checkers = array();
protected $em; protected $app;
protected $filesystem; protected $filesystem;
protected $pdfToText; protected $pdfToText;
@@ -48,13 +61,11 @@ class Manager
/** /**
* Constructor * Constructor
* *
* @param \Doctrine\ORM\EntityManager $em Entity manager * @param Application $app The application context
* @param \Monolog\Logger $logger A logger
*/ */
public function __construct(EntityManager $em, Filesystem $filesystem) public function __construct(Application $app)
{ {
$this->em = $em; $this->app = $app;
$this->filesystem = $filesystem;
} }
/** /**
@@ -63,7 +74,7 @@ class Manager
*/ */
public function __destruct() public function __destruct()
{ {
$this->em = $this->filesystem = null; $this->app = null;
} }
/** /**
@@ -135,7 +146,7 @@ class Manager
$visa = new Visa(); $visa = new Visa();
foreach ($this->checkers as $checker) { foreach ($this->checkers as $checker) {
$visa->addResponse($checker->check($this->em, $file)); $visa->addResponse($checker->check($this->app['EM'], $file));
} }
return $visa; return $visa;
@@ -144,10 +155,10 @@ class Manager
/** /**
* Registers a checker * Registers a checker
* *
* @param Checker\CheckerInterface $checker The checker to register * @param CheckerInterface $checker The checker to register
* @return Manager * @return Manager
*/ */
public function registerChecker(Checker\CheckerInterface $checker) public function registerChecker(CheckerInterface $checker)
{ {
$this->checkers[] = $checker; $this->checkers[] = $checker;
@@ -172,10 +183,10 @@ class Manager
/** /**
* Unregister a checker * Unregister a checker
* *
* @param Checker\CheckerInterface $checker The checker to unregister * @param CheckerInterface $checker The checker to unregister
* @return Manager * @return Manager
*/ */
public function unregisterChecker(Checker\CheckerInterface $checker) public function unregisterChecker(CheckerInterface $checker)
{ {
$checkers = $this->checkers; $checkers = $this->checkers;
foreach ($this->checkers as $offset => $registered) { foreach ($this->checkers as $offset => $registered) {
@@ -202,8 +213,8 @@ class Manager
/** /**
* Find an available Lazaret filename and creates the empty file. * Find an available Lazaret filename and creates the empty file.
* *
* @param string $filename The desired filename * @param string $filename The desired filename
* @param string $suffix A suffix to the filename * @param string $suffix A suffix to the filename
* @return string The available filename to use * @return string The available filename to use
*/ */
protected function bookLazaretPathfile($filename, $suffix = '') protected function bookLazaretPathfile($filename, $suffix = '')
@@ -212,14 +223,14 @@ class Manager
$infos = pathinfo($output); $infos = pathinfo($output);
$n = 0; $n = 0;
$this->filesystem->mkdir(__DIR__ . '/../../../../tmp/lazaret'); $this->app['filesystem']->mkdir(__DIR__ . '/../../../../tmp/lazaret');
while (true) { while (true) {
$output = sprintf('%s/%s-%d%s', $infos['dirname'], $infos['filename'], ++ $n, (isset($infos['extension']) ? '.' . $infos['extension'] : '')); $output = sprintf('%s/%s-%d%s', $infos['dirname'], $infos['filename'], ++ $n, (isset($infos['extension']) ? '.' . $infos['extension'] : ''));
try { try {
if ( ! $this->filesystem->exists($output)) { if ( ! $this->app['filesystem']->exists($output)) {
$this->filesystem->touch($output); $this->app['filesystem']->touch($output);
break; break;
} }
} catch (IOException $e) { } catch (IOException $e) {
@@ -238,35 +249,33 @@ class Manager
*/ */
protected function createRecord(File $file) protected function createRecord(File $file)
{ {
$element = \record_adapter::createFromFile($file, $this->filesystem); $element = \record_adapter::createFromFile($file, $this->app);
$date = new \DateTime(); $date = new \DateTime();
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfArchivedate(), new MonoValue($date->format('Y/m/d H:i:s')) new TfArchivedate(), new MonoValue($date->format('Y/m/d H:i:s'))
) )
) )
); );
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfRecordid(), new MonoValue($element->get_record_id()) new TfRecordid(), new MonoValue($element->get_record_id())
) )
) )
); );
$metadatas = array(); $metadatas = array();
$fileEntity = $file->getMedia()->getEntity();
/** /**
* @todo $key is not tagname but fieldname * @todo $key is not tagname but fieldname
*/ */
$fieldToKeyMap = array(); $fieldToKeyMap = array();
if ( ! $fieldToKeyMap) { if (! $fieldToKeyMap) {
foreach ($file->getCollection()->get_databox()->get_meta_structure() as $databox_field) { foreach ($file->getCollection()->get_databox()->get_meta_structure() as $databox_field) {
$tagname = $databox_field->get_tag()->getTagname(); $tagname = $databox_field->get_tag()->getTagname();
@@ -279,7 +288,7 @@ class Manager
} }
} }
foreach ($fileEntity->getMetadatas() as $metadata) { foreach ($file->getMedia()->getMetadatas() as $metadata) {
$key = $metadata->getTag()->getTagname(); $key = $metadata->getTag()->getTagname();
@@ -303,7 +312,7 @@ class Manager
* @todo implement METATAG aka metadata by fieldname (where as * @todo implement METATAG aka metadata by fieldname (where as
* current metadata is metadata by source. * current metadata is metadata by source.
*/ */
case Attribute\Attribute::NAME_METAFIELD: case AttributeInterface::NAME_METAFIELD:
$key = $attribute->getField()->get_name(); $key = $attribute->getField()->get_name();
@@ -314,7 +323,7 @@ class Manager
$metadatas[$key] = array_merge($metadatas[$key], array($attribute->getValue())); $metadatas[$key] = array_merge($metadatas[$key], array($attribute->getValue()));
break; break;
case Attribute\Attribute::NAME_METADATA: case AttributeInterface::NAME_METADATA:
$key = $attribute->getValue()->getTag()->getTagname(); $key = $attribute->getValue()->getTag()->getTagname();
@@ -330,12 +339,12 @@ class Manager
$metadatas[$k] = array_merge($metadatas[$k], $attribute->getValue()->getValue()->asArray()); $metadatas[$k] = array_merge($metadatas[$k], $attribute->getValue()->getValue()->asArray());
} }
break; break;
case Attribute\Attribute::NAME_STATUS: case AttributeInterface::NAME_STATUS:
$element->set_binary_status($element->get_status() | $attribute->getValue()); $element->set_binary_status($element->get_status() | $attribute->getValue());
break; break;
case Attribute\Attribute::NAME_STORY: case AttributeInterface::NAME_STORY:
$story = $attribute->getValue(); $story = $attribute->getValue();
@@ -418,7 +427,7 @@ class Manager
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfQuarantine(), new MonoValue($date->format('Y/m/d H:i:s')) new TfQuarantine(), new MonoValue($date->format('Y/m/d H:i:s'))
) )
) )
); );
@@ -426,17 +435,15 @@ class Manager
$lazaretPathname = $this->bookLazaretPathfile($file->getOriginalName()); $lazaretPathname = $this->bookLazaretPathfile($file->getOriginalName());
$lazaretPathnameThumb = $this->bookLazaretPathfile($file->getOriginalName(), 'thumb'); $lazaretPathnameThumb = $this->bookLazaretPathfile($file->getOriginalName(), 'thumb');
$this->filesystem->copy($file->getFile()->getRealPath(), $lazaretPathname, true); $this->app['filesystem']->copy($file->getFile()->getRealPath(), $lazaretPathname, true);
$spec = new ImageSpec(); $spec = new ImageSpec();
$spec->setResizeMode(ImageSpec::RESIZE_MODE_INBOUND_FIXEDRATIO); $spec->setResizeMode(ImageSpec::RESIZE_MODE_INBOUND_FIXEDRATIO);
$spec->setDimensions(375, 275); $spec->setDimensions(375, 275);
$core = \bootstrap::getCore();
try { try {
$core['media-alchemyst'] $this->app['media-alchemyst']
->open($file->getFile()->getPathname()) ->open($file->getFile()->getPathname())
->turnInto($lazaretPathnameThumb, $spec) ->turnInto($lazaretPathnameThumb, $spec)
->close(); ->close();
@@ -457,7 +464,7 @@ class Manager
$lazaretFile->setSession($session); $lazaretFile->setSession($session);
$this->em->persist($lazaretFile); $this->app['EM']->persist($lazaretFile);
foreach ($file->getAttributes() as $fileAttribute) { foreach ($file->getAttributes() as $fileAttribute) {
$attribute = new LazaretAttribute(); $attribute = new LazaretAttribute();
@@ -467,7 +474,7 @@ class Manager
$lazaretFile->addLazaretAttribute($attribute); $lazaretFile->addLazaretAttribute($attribute);
$this->em->persist($attribute); $this->app['EM']->persist($attribute);
} }
foreach ($visa->getResponses() as $response) { foreach ($visa->getResponses() as $response) {
@@ -479,11 +486,11 @@ class Manager
$lazaretFile->addLazaretCheck($check); $lazaretFile->addLazaretCheck($check);
$this->em->persist($check); $this->app['EM']->persist($check);
} }
} }
$this->em->flush(); $this->app['EM']->flush();
return $lazaretFile; return $lazaretFile;
} }
@@ -502,7 +509,7 @@ class Manager
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfWidth(), new MonoValue($file->getMedia()->getWidth()) new TfWidth(), new MonoValue($file->getMedia()->getWidth())
) )
) )
); );
@@ -511,7 +518,7 @@ class Manager
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfHeight(), new MonoValue($file->getMedia()->getHeight()) new TfHeight(), new MonoValue($file->getMedia()->getHeight())
) )
) )
); );
@@ -520,7 +527,7 @@ class Manager
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfChannels(), new MonoValue($file->getMedia()->getChannels()) new TfChannels(), new MonoValue($file->getMedia()->getChannels())
) )
) )
); );
@@ -529,7 +536,7 @@ class Manager
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfBits(), new MonoValue($file->getMedia()->getColorDepth()) new TfBits(), new MonoValue($file->getMedia()->getColorDepth())
) )
) )
); );
@@ -538,7 +545,7 @@ class Manager
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfDuration(), new MonoValue($file->getMedia()->getDuration()) new TfDuration(), new MonoValue($file->getMedia()->getDuration())
) )
) )
); );
@@ -554,7 +561,7 @@ class Manager
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\PdfText(), new MonoValue($text) new PdfText(), new MonoValue($text)
) )
) )
); );
@@ -569,29 +576,29 @@ class Manager
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfMimetype(), new MonoValue($file->getFile()->getMimeType())))); new TfMimetype(), new MonoValue($file->getFile()->getMimeType()))));
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfSize(), new MonoValue($file->getFile()->getSize())))); new TfSize(), new MonoValue($file->getFile()->getSize()))));
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfBasename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_BASENAME)) new TfBasename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_BASENAME))
) )
) )
); );
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfFilename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_FILENAME)) new TfFilename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_FILENAME))
) )
) )
); );
$file->addAttribute( $file->addAttribute(
new MetadataAttr( new MetadataAttr(
new Metadata( new Metadata(
new PhraseaTag\TfExtension(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_EXTENSION)) new TfExtension(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_EXTENSION))
) )
) )
); );

View File

@@ -2,22 +2,27 @@
namespace Alchemy\Phrasea\Border\Attribute; namespace Alchemy\Phrasea\Border\Attribute;
use PHPExiftool\Driver\Tag\IPTC\UniqueDocumentID;
use PHPExiftool\Driver\Value\Mono;
use PHPExiftool\Driver\Metadata\Metadata;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
class FactoryTest extends \PhraseanetPHPUnitAbstract class FactoryTest extends \PhraseanetPHPUnitAbstract
{ {
/** /**
* @covers Alchemy\Phrasea\Border\Attribute\Attribute * @covers Alchemy\Phrasea\Border\Attribute\Attribute
* @covers Alchemy\Phrasea\Border\Attribute\Factory::getFileAttribute * @covers Alchemy\Phrasea\Border\Attribute\Factory::getFileAttribute
*/ */
public function testGetFileAttributeMetadata() public function testGetFileAttributeMetadata()
{ {
$tag = new \PHPExiftool\Driver\Tag\IPTC\UniqueDocumentID(); $tag = new UniqueDocumentID();
$value = new \PHPExiftool\Driver\Value\Mono('Unique'); $value = new Mono('Unique');
$metadata = new \PHPExiftool\Driver\Metadata\Metadata($tag, $value); $metadata = new Metadata($tag, $value);
$attribute = Factory::getFileAttribute(Attribute::NAME_METADATA, serialize($metadata)); $attribute = Factory::getFileAttribute(self::$application, Attribute::NAME_METADATA, serialize($metadata));
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Metadata', $attribute); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Metadata', $attribute);
} }
@@ -28,7 +33,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testGetFileAttributeMetadataFail() public function testGetFileAttributeMetadataFail()
{ {
Factory::getFileAttribute(Attribute::NAME_METADATA, null); Factory::getFileAttribute(self::$application, Attribute::NAME_METADATA, null);
} }
/** /**
@@ -36,7 +41,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testGetFileAttributeStory() public function testGetFileAttributeStory()
{ {
$attribute = Factory::getFileAttribute(Attribute::NAME_STORY, static::$records['record_story_1']->get_serialize_key()); $attribute = Factory::getFileAttribute(self::$application, Attribute::NAME_STORY, static::$records['record_story_1']->get_serialize_key());
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Story', $attribute); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Story', $attribute);
} }
@@ -52,13 +57,13 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
break; break;
} }
if ( ! $databox_field) { if (!$databox_field) {
$this->markTestSkipped('No databox field found'); $this->markTestSkipped('No databox field found');
} }
$metafield = new MetaField($databox_field, 'value'); $metafield = new MetaField($databox_field, 'value');
$attribute = Factory::getFileAttribute(Attribute::NAME_METAFIELD, $metafield->asString()); $attribute = Factory::getFileAttribute(self::$application, Attribute::NAME_METAFIELD, $metafield->asString());
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\MetaField', $attribute); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\MetaField', $attribute);
} }
@@ -68,7 +73,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testGetFileAttributeStatus() public function testGetFileAttributeStatus()
{ {
$attribute = Factory::getFileAttribute(Attribute::NAME_STATUS, '000100'); $attribute = Factory::getFileAttribute(self::$application, Attribute::NAME_STATUS, '000100');
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Status', $attribute); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Status', $attribute);
} }
@@ -79,7 +84,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testGetFileAttributeStoryFailsRecord() public function testGetFileAttributeStoryFailsRecord()
{ {
Factory::getFileAttribute(Attribute::NAME_STORY, static::$records['record_1']->get_serialize_key()); Factory::getFileAttribute(self::$application, Attribute::NAME_STORY, static::$records['record_1']->get_serialize_key());
} }
/** /**
@@ -90,7 +95,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
{ {
\PHPUnit_Framework_Error_Warning::$enabled = false; \PHPUnit_Framework_Error_Warning::$enabled = false;
Factory::getFileAttribute(Attribute::NAME_STORY, self::$collection->get_databox()->get_sbas_id() . '_0'); Factory::getFileAttribute(self::$application, Attribute::NAME_STORY, self::$collection->get_databox()->get_sbas_id() . '_0');
} }
/** /**
@@ -99,6 +104,6 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testGetFileAttributeFail() public function testGetFileAttributeFail()
{ {
Factory::getFileAttribute('nothing', 'nothong'); Factory::getFileAttribute(self::$application, 'nothing', 'nothong');
} }
} }

View File

@@ -98,7 +98,7 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testLoadFromString() public function testLoadFromString()
{ {
$this->assertEquals($this->object, MetaField::loadFromString($this->object->asString())); $this->assertEquals($this->object, MetaField::loadFromString(self::$application, $this->object->asString()));
} }
/** /**
@@ -107,7 +107,7 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testLoadFromStringFail() public function testLoadFromStringFail()
{ {
MetaField::loadFromString('Elephant'); MetaField::loadFromString(self::$application, 'Elephant');
} }
/** /**
@@ -118,6 +118,6 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract
{ {
\PHPUnit_Framework_Error_Warning::$enabled = false; \PHPUnit_Framework_Error_Warning::$enabled = false;
\PHPUnit_Framework_Error_Notice::$enabled = false; \PHPUnit_Framework_Error_Notice::$enabled = false;
MetaField::loadFromString(serialize(array('Elephant', 'sbas_id' => self::$collection->get_sbas_id(), 'id' => 0))); MetaField::loadFromString(self::$application, serialize(array('Elephant', 'sbas_id' => self::$collection->get_sbas_id(), 'id' => 0)));
} }
} }

View File

@@ -2,7 +2,9 @@
namespace Alchemy\Phrasea\Border\Attribute; namespace Alchemy\Phrasea\Border\Attribute;
class MetadataTest extends \PHPUnit_Framework_TestCase require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
class MetadataTest extends \PhraseanetPHPUnitAbstract
{ {
/** /**
* @var Metadata * @var Metadata
@@ -14,7 +16,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
* @covers Alchemy\Phrasea\Border\Attribute\Attribute * @covers Alchemy\Phrasea\Border\Attribute\Attribute
* @covers Alchemy\Phrasea\Border\Attribute\Metadata::__construct * @covers Alchemy\Phrasea\Border\Attribute\Metadata::__construct
*/ */
protected function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$tag = new \PHPExiftool\Driver\Tag\MXF\ObjectName(); $tag = new \PHPExiftool\Driver\Tag\MXF\ObjectName();
@@ -28,7 +30,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
/** /**
* @covers Alchemy\Phrasea\Border\Attribute\Metadata::__destruct * @covers Alchemy\Phrasea\Border\Attribute\Metadata::__destruct
*/ */
protected function tearDown() public function tearDown()
{ {
$this->object = null; $this->object = null;
parent::tearDown(); parent::tearDown();
@@ -63,7 +65,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
*/ */
public function testLoadFromString() public function testLoadFromString()
{ {
$loaded = Metadata::loadFromString($this->object->asString()); $loaded = Metadata::loadFromString(self::$application, $this->object->asString());
$this->assertEquals($this->object, $loaded); $this->assertEquals($this->object, $loaded);
} }
@@ -76,7 +78,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
{ {
\PHPUnit_Framework_Error_Notice::$enabled = false; \PHPUnit_Framework_Error_Notice::$enabled = false;
Metadata::loadFromString('Hello String'); Metadata::loadFromString(self::$application, 'Hello String');
} }
/** /**
@@ -85,6 +87,6 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
*/ */
public function testLoadFromStringWrongObject() public function testLoadFromStringWrongObject()
{ {
Metadata::loadFromString(serialize(new \stdClass())); Metadata::loadFromString(self::$application, serialize(new \stdClass()));
} }
} }

View File

@@ -4,7 +4,7 @@ namespace Alchemy\Phrasea\Border\Attribute;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
class StatusTest extends \PHPUnit_Framework_TestCase class StatusTest extends \PhraseanetPHPUnitAbstract
{ {
/** /**
* @var Status * @var Status
@@ -89,6 +89,6 @@ class StatusTest extends \PHPUnit_Framework_TestCase
{ {
$status = new Status(12345); $status = new Status(12345);
$this->assertEquals($status, Status::loadFromString($status->asString())); $this->assertEquals($status, Status::loadFromString(self::$application, $status->asString()));
} }
} }

View File

@@ -10,6 +10,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
* @var Story * @var Story
*/ */
protected $object; protected $object;
protected $story;
/** /**
* @covers Alchemy\Phrasea\Border\Attribute\Attribute * @covers Alchemy\Phrasea\Border\Attribute\Attribute
@@ -18,7 +19,8 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new Story(static::$records['record_story_1']); $this->story = \record_adapter::createStory(self::$application, self::$collection);;
$this->object = new Story($this->story);
} }
/** /**
@@ -26,6 +28,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function tearDown() public function tearDown()
{ {
$this->story->delete();
$this->object = null; $this->object = null;
parent::tearDown(); parent::tearDown();
} }
@@ -44,7 +47,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testGetValue() public function testGetValue()
{ {
$this->assertSame(static::$records['record_story_1'], $this->object->getValue()); $this->assertSame($this->story, $this->object->getValue());
} }
/** /**
@@ -60,7 +63,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testLoadFromString() public function testLoadFromString()
{ {
$loaded = Story::loadFromString($this->object->asString()); $loaded = Story::loadFromString(self::$application, $this->object->asString());
$this->assertEquals($this->object, $loaded); $this->assertEquals($this->object, $loaded);
} }
@@ -80,7 +83,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testLoadFromStringWrongElement() public function testLoadFromStringWrongElement()
{ {
Story::loadFromString(static::$records['record_1']->get_serialize_key()); Story::loadFromString(self::$application, static::$records['record_1']->get_serialize_key());
} }
/** /**
@@ -91,6 +94,6 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
{ {
\PHPUnit_Framework_Error_Warning::$enabled = false; \PHPUnit_Framework_Error_Warning::$enabled = false;
Story::loadFromString(self::$collection->get_databox()->get_sbas_id() . '_0'); Story::loadFromString(self::$application, self::$collection->get_databox()->get_sbas_id() . '_0');
} }
} }

View File

@@ -3,11 +3,12 @@
namespace Alchemy\Phrasea\Border\Checker; namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
require_once __DIR__ . "/../../../../PhraseanetPHPUnitAbstract.class.inc"; require_once __DIR__ . "/../../../../PhraseanetPHPUnitAbstract.class.inc";
class AbstractCheckerTest extends \PHPUnit_Framework_TestCase class AbstractCheckerTest extends \PhraseanetPHPUnitAbstract
{ {
/** /**
* @var AbstractChecker * @var AbstractChecker
@@ -18,13 +19,14 @@ class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
{ {
parent::setUp(); parent::setUp();
$this->object = new AbstractCheckerTester(); $this->object = new AbstractCheckerTester(self::$application);
$this->file = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getCollection'), array(), 'CheckerTesterMock' . mt_rand(), false); $this->file = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getCollection'), array(), 'CheckerTesterMock' . mt_rand(), false);
} }
public function tearDown() public function tearDown()
{ {
$this->file = null; $this->file = null;
parent::tearDown();
} }
/** /**
@@ -46,7 +48,8 @@ class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
public function getDataboxesCombinaison() public function getDataboxesCombinaison()
{ {
$databox = $collection = null; $databox = $collection = null;
$appbox = \appbox::get_instance(\bootstrap::getCore()); $app = new Application();
$appbox = $app['phraseanet.appbox'];
foreach ($appbox->get_databoxes() as $db) { foreach ($appbox->get_databoxes() as $db) {
if ( ! $collection) { if ( ! $collection) {
@@ -97,7 +100,8 @@ class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
public function getCollectionsCombinaison() public function getCollectionsCombinaison()
{ {
$othercollection = $collection = null; $othercollection = $collection = null;
$appbox = \appbox::get_instance(\bootstrap::getCore()); $app = new Application();
$appbox = $app['phraseanet.appbox'];
foreach ($appbox->get_databoxes() as $db) { foreach ($appbox->get_databoxes() as $db) {
if ( ! $collection) { if ( ! $collection) {
@@ -167,7 +171,8 @@ class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
public function getDataboxAndCollection() public function getDataboxAndCollection()
{ {
$databox = $collection = null; $databox = $collection = null;
$appbox = \appbox::get_instance(\bootstrap::getCore()); $app = new Application();
$appbox = $app['phraseanet.appbox'];
foreach ($appbox->get_databoxes() as $db) { foreach ($appbox->get_databoxes() as $db) {
if ( ! $databox) { if ( ! $databox) {

View File

@@ -18,7 +18,7 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new Colorspace(array('colorspaces' => array('RGB', 'cmyk'))); $this->object = new Colorspace(self::$application, array('colorspaces' => array('RGB', 'cmyk')));
} }
/** /**
@@ -26,17 +26,20 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testCheck() public function testCheck()
{ {
$spl = new \SplFileInfo(__DIR__ . '/../../../../testfiles/test001.CR2'); $media = $this
->getMockBuilder('\\MediaVorus\\Media\\Image')
$media = $this->getMock('\\MediaVorus\\Media\\Image', array('getColorSpace'), array($spl)); ->disableOriginalConstructor()
->getMock();
$media->expects($this->once()) $media->expects($this->once())
->method('getColorSpace') ->method('getColorSpace')
->will($this->returnValue('RGB')); ->will($this->returnValue('RGB'));
$media->expects($this->any())
->method('getFile')
->will($this->returnValue(new \SplFileInfo(__FILE__)));
$File = new \Alchemy\Phrasea\Border\File($media, self::$collection); $File = new \Alchemy\Phrasea\Border\File($media, self::$collection);
$response = $this->object->check(self::$core['EM'], $File); $response = $this->object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
@@ -50,11 +53,11 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract
$this->assertInternalType('string', $this->object->getMessage()); $this->assertInternalType('string', $this->object->getMessage());
} }
/** /**
* @expectedException InvalidArgumentException * @expectedException InvalidArgumentException
*/ */
public function testContructorInvalidArgumentException() public function testContructorInvalidArgumentException()
{ {
new Colorspace(array(array('RGB', 'cmyk'))); new Colorspace(self::$application, array(array('RGB', 'cmyk')));
} }
} }

View File

@@ -18,9 +18,10 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testCheckSameDims() public function testCheckSameDims()
{ {
$spl = new \SplFileInfo(__DIR__ . '/../../../../testfiles/test001.CR2'); $media = $this
->getMockBuilder('\\MediaVorus\\Media\\Image')
$media = $this->getMock('\\MediaVorus\\Media\\Image', array('getWidth', 'getHeight'), array($spl)); ->disableOriginalConstructor()
->getMock();
$media->expects($this->any()) $media->expects($this->any())
->method('getWidth') ->method('getWidth')
@@ -28,36 +29,39 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
$media->expects($this->any()) $media->expects($this->any())
->method('getHeight') ->method('getHeight')
->will($this->returnValue('400')); ->will($this->returnValue('400'));
$media->expects($this->any())
->method('getFile')
->will($this->returnValue(new \SplFileInfo(__FILE__)));
$File = new \Alchemy\Phrasea\Border\File($media, self::$collection); $File = new \Alchemy\Phrasea\Border\File($media, self::$collection);
$object = new Dimension(array('width' => 800)); $object = new Dimension(self::$application, array('width' => 800));
$response = $object->check(self::$core['EM'], $File); $response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertFalse($response->isOk()); $this->assertFalse($response->isOk());
$object = new Dimension(array('width' => 500)); $object = new Dimension(self::$application, array('width' => 500));
$response = $object->check(self::$core['EM'], $File); $response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertFalse($response->isOk()); $this->assertFalse($response->isOk());
$object = new Dimension(array('width' => 400)); $object = new Dimension(self::$application, array('width' => 400));
$response = $object->check(self::$core['EM'], $File); $response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$object = new Dimension(array('width' => 600, 'height' => 500)); $object = new Dimension(self::$application, array('width' => 600, 'height' => 500));
$response = $object->check(self::$core['EM'], $File); $response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertFalse($response->isOk()); $this->assertFalse($response->isOk());
$object = new Dimension(array('width' => 600, 'height' => 400)); $object = new Dimension(self::$application, array('width' => 600, 'height' => 400));
$response = $object->check(self::$core['EM'], $File); $response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$object = new Dimension(array('width' => 200, 'height' => 200)); $object = new Dimension(self::$application, array('width' => 200, 'height' => 200));
$response = $object->check(self::$core['EM'], $File); $response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
} }
@@ -78,7 +82,7 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
$height = $dimensions['height']; $height = $dimensions['height'];
} }
new Dimension(array('width' => $width,'height' => $height)); new Dimension(self::$application, array('width' => $width,'height' => $height));
$this->fail(sprintf('Exception raised with dimensions %s and %s', $width, $height)); $this->fail(sprintf('Exception raised with dimensions %s and %s', $width, $height));
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
@@ -114,6 +118,6 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testContructorInvalidArgumentException() public function testContructorInvalidArgumentException()
{ {
new Dimension(array('witdh' => 38)); new Dimension(self::$application, array('witdh' => 38));
} }
} }

View File

@@ -18,7 +18,7 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new Extension(array('extensions' => array('jpg', 'png', 'tiff'))); $this->object = new Extension(self::$application, array('extensions' => array('jpg', 'png', 'tiff')));
} }
/** /**
@@ -41,15 +41,17 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract
->method('getExtension') ->method('getExtension')
->will($this->returnValue($extension)); ->will($this->returnValue($extension));
$media = $this->getMock('\\MediaVorus\Media\Image', array('getFile'), array($spl)); $media = $this
->getMockBuilder('\\MediaVorus\\Media\\Image')
->disableOriginalConstructor()
->getMock();
$media->expects($this->any()) $media->expects($this->any())
->method('getFile') ->method('getFile')
->will($this->returnValue($spl)); ->will($this->returnValue($spl));
$File = new \Alchemy\Phrasea\Border\File($media, self::$collection); $File = new \Alchemy\Phrasea\Border\File($media, self::$collection);
$response = $this->object->check(self::$core['EM'], $File); $response = $this->object->check(self::$application['EM'], $File);
$this->assertEquals($result, $response->isOk()); $this->assertEquals($result, $response->isOk());
} }
@@ -68,6 +70,6 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testContructorInvalidArgumentException() public function testContructorInvalidArgumentException()
{ {
new Dimension(array(array('jpg', 'png', 'tiff'))); new Dimension(self::$application, array(array('jpg', 'png', 'tiff')));
} }
} }

View File

@@ -22,10 +22,10 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new Filename; $this->object = new Filename(self::$application);
$this->filename = __DIR__ . '/../../../../../tmp/test001.CR2'; $this->filename = __DIR__ . '/../../../../../tmp/test001.CR2';
copy(__DIR__ . '/../../../../testfiles/test001.CR2', $this->filename); copy(__DIR__ . '/../../../../testfiles/test001.CR2', $this->filename);
$this->media = self::$core['mediavorus']->guess(new \SplFileInfo($this->filename)); $this->media = self::$application['mediavorus']->guess($this->filename);
} }
public function tearDown() public function tearDown()
@@ -42,7 +42,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testCheck() public function testCheck()
{ {
$response = $this->object->check(self::$core['EM'], new File($this->media, self::$collection)); $response = $this->object->check(self::$application['EM'], new File($this->media, self::$collection));
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
@@ -62,7 +62,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
->will($this->returnValue(\random::generatePassword(32))) ->will($this->returnValue(\random::generatePassword(32)))
; ;
$response = $this->object->check(self::$core['EM'], $mock); $response = $this->object->check(self::$application['EM'], $mock);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
@@ -85,14 +85,14 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
->will($this->returnValue(strtoupper($this->media->getFile()->getFilename()))) ->will($this->returnValue(strtoupper($this->media->getFile()->getFilename())))
; ;
$response = $this->object->check(self::$core['EM'], $mock); $response = $this->object->check(self::$application['EM'], $mock);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertFalse($response->isOk()); $this->assertFalse($response->isOk());
$objectSensitive = new Filename(array('sensitive' => true)); $objectSensitive = new Filename(self::$application, array('sensitive' => true));
$responseSensitive = $objectSensitive->check(self::$core['EM'], $mock); $responseSensitive = $objectSensitive->check(self::$application['EM'], $mock);
$this->assertTrue($responseSensitive->isOk()); $this->assertTrue($responseSensitive->isOk());

View File

@@ -18,7 +18,7 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new MediaType(array('mediatypes' => array(MediaType::TYPE_IMAGE))); $this->object = new MediaType(self::$application, array('mediatypes' => array(MediaType::TYPE_IMAGE)));
} }
/** /**
@@ -26,17 +26,17 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testCheck() public function testCheck()
{ {
$media = self::$core['mediavorus']->guess(new \SplFileInfo(__DIR__ . '/../../../../testfiles/test001.CR2')); $media = self::$application['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2');
$file = new \Alchemy\Phrasea\Border\File($media, self::$collection); $file = new \Alchemy\Phrasea\Border\File($media, self::$collection);
$response = $this->object->check(self::$core['EM'], $file); $response = $this->object->check(self::$application['EM'], $file);
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$object = new MediaType(array('mediatypes' => array(MediaType::TYPE_VIDEO, MediaType::TYPE_AUDIO))); $object = new MediaType(self::$application, array('mediatypes' => array(MediaType::TYPE_VIDEO, MediaType::TYPE_AUDIO)));
$media = self::$core['mediavorus']->guess(new \SplFileInfo(__DIR__ . '/../../../../testfiles/test001.CR2')); $media = self::$application['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2');
$file = new \Alchemy\Phrasea\Border\File($media, self::$collection); $file = new \Alchemy\Phrasea\Border\File($media, self::$collection);
$response = $object->check(self::$core['EM'], $file); $response = $object->check(self::$application['EM'], $file);
$this->assertFalse($response->isOk()); $this->assertFalse($response->isOk());
} }
@@ -54,6 +54,6 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testContructorInvalidArgumentException() public function testContructorInvalidArgumentException()
{ {
new MediaType(array(array(MediaType::TYPE_IMAGE))); new MediaType(self::$application, array(array(MediaType::TYPE_IMAGE)));
} }
} }

View File

@@ -18,10 +18,10 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new Sha256; $this->object = new Sha256(self::$application);
$this->filename = __DIR__ . '/../../../../../tmp/test001.CR2'; $this->filename = __DIR__ . '/../../../../../tmp/test001.CR2';
copy(__DIR__ . '/../../../../testfiles/test001.CR2', $this->filename); copy(__DIR__ . '/../../../../testfiles/test001.CR2', $this->filename);
$this->media = self::$core['mediavorus']->guess(new \SplFileInfo($this->filename)); $this->media = self::$application['mediavorus']->guess($this->filename);
} }
public function tearDown() public function tearDown()
@@ -39,9 +39,9 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
public function testCheck() public function testCheck()
{ {
$session = new \Entities\LazaretSession(); $session = new \Entities\LazaretSession();
self::$core['EM']->persist($session); self::$application['EM']->persist($session);
self::$core['border-manager']->process($session, File::buildFromPathfile($this->media->getFile()->getPathname(), self::$collection), null, \Alchemy\Phrasea\Border\Manager::FORCE_RECORD); self::$application['border-manager']->process($session, File::buildFromPathfile($this->media->getFile()->getPathname(), self::$collection, self::$application['mediavorus']), null, \Alchemy\Phrasea\Border\Manager::FORCE_RECORD);
$mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getSha256'), array($this->media, self::$collection)); $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getSha256'), array($this->media, self::$collection));
@@ -51,7 +51,7 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
->will($this->returnValue($this->media->getHash('sha256', __DIR__ . '/../../../../testfiles/test001.CR2'))) ->will($this->returnValue($this->media->getHash('sha256', __DIR__ . '/../../../../testfiles/test001.CR2')))
; ;
$response = $this->object->check(self::$core['EM'], $mock); $response = $this->object->check(self::$application['EM'], $mock);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
@@ -71,7 +71,7 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
->will($this->returnValue(\random::generatePassword(3))) ->will($this->returnValue(\random::generatePassword(3)))
; ;
$response = $this->object->check(self::$core['EM'], $mock); $response = $this->object->check(self::$application['EM'], $mock);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);

View File

@@ -18,10 +18,10 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new UUID; $this->object = new UUID(self::$application);
$this->filename = __DIR__ . '/../../../../../tmp/test001.CR2'; $this->filename = __DIR__ . '/../../../../../tmp/test001.CR2';
copy(__DIR__ . '/../../../../testfiles/test001.CR2', $this->filename); copy(__DIR__ . '/../../../../testfiles/test001.CR2', $this->filename);
$this->media = self::$core['mediavorus']->guess(new \SplFileInfo($this->filename)); $this->media = self::$application['mediavorus']->guess($this->filename);
} }
public function tearDown() public function tearDown()
@@ -38,7 +38,7 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testCheck() public function testCheck()
{ {
$response = $this->object->check(self::$core['EM'], new File($this->media, self::$collection)); $response = $this->object->check(self::$application['EM'], new File($this->media, self::$collection));
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
@@ -58,7 +58,7 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
->will($this->returnValue(\random::generatePassword(3))) ->will($this->returnValue(\random::generatePassword(3)))
; ;
$response = $this->object->check(self::$core['EM'], $mock); $response = $this->object->check(self::$application['EM'], $mock);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);

View File

@@ -22,7 +22,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$this->filename = __DIR__ . '/../../../../tmp/iphone_pic.jpg'; $this->filename = __DIR__ . '/../../../../tmp/iphone_pic.jpg';
copy(__DIR__ . '/../../../testfiles/iphone_pic.jpg', $this->filename); copy(__DIR__ . '/../../../testfiles/iphone_pic.jpg', $this->filename);
$this->media = self::$core['mediavorus']->guess(new \SplFileInfo($this->filename)); $this->media = self::$application['mediavorus']->guess($this->filename);
$this->object = new File($this->media, self::$collection, 'originalName.txt'); $this->object = new File($this->media, self::$collection, 'originalName.txt');
} }
@@ -60,20 +60,20 @@ class FileTest extends \PhraseanetPHPUnitAbstract
copy(__DIR__ . '/../../../testfiles/p4logo.jpg', $file); copy(__DIR__ . '/../../../testfiles/p4logo.jpg', $file);
$borderFile = new File(self::$core['mediavorus']->guess(new \SplFileInfo($file)), self::$collection); $borderFile = new File(self::$application['mediavorus']->guess($file), self::$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::$core['mediavorus']->guess(new \SplFileInfo($file)), self::$collection); $borderFile = new File(self::$application['mediavorus']->guess($file), self::$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::$core['mediavorus']->guess(new \SplFileInfo($file)), self::$collection); $borderFile = new File(self::$application['mediavorus']->guess($file), self::$collection);
$uuid = $borderFile->getUUID(); $uuid = $borderFile->getUUID();
$this->assertTrue(\uuid::is_valid($uuid)); $this->assertTrue(\uuid::is_valid($uuid));
@@ -139,7 +139,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testOriginalNameAuto() public function testOriginalNameAuto()
{ {
$object = new File(self::$core['mediavorus']->guess(new \SplFileInfo($this->filename)), self::$collection); $object = new File(self::$application['mediavorus']->guess($this->filename), self::$collection);
$this->assertSame('iphone_pic.jpg', $object->getOriginalName()); $this->assertSame('iphone_pic.jpg', $object->getOriginalName());
} }
@@ -180,18 +180,18 @@ class FileTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testBuildFromPathfile() public function testBuildFromPathfile()
{ {
$media = self::$core['mediavorus']->guess(new \SplFileInfo($this->filename)); $media = self::$application['mediavorus']->guess($this->filename);
$file1 = new File($media, self::$collection); $file1 = new File($media, self::$collection);
$file2 = File::buildFromPathfile($this->filename, self::$collection); $file2 = File::buildFromPathfile($this->filename, self::$collection, self::$application['mediavorus']);
$this->assertEquals($file1, $file2); $this->assertEquals($file1, $file2);
$media = self::$core['mediavorus']->guess(new \SplFileInfo($this->filename)); $media = self::$application['mediavorus']->guess($this->filename);
$file3 = new File($media, self::$collection, 'coco lapin'); $file3 = new File($media, self::$collection, 'coco lapin');
$file4 = File::buildFromPathfile($this->filename, self::$collection, 'coco lapin'); $file4 = File::buildFromPathfile($this->filename, self::$collection, self::$application['mediavorus'], 'coco lapin');
$this->assertEquals($file3, $file4); $this->assertEquals($file3, $file4);
$this->assertNotEquals($file1, $file4); $this->assertNotEquals($file1, $file4);
@@ -203,7 +203,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
*/ */
public function testBuildFromWrongPathfile() public function testBuildFromWrongPathfile()
{ {
File::buildFromPathfile('unexistent.file', self::$collection); File::buildFromPathfile('unexistent.file', self::$collection, self::$application['mediavorus']);
} }
/** /**
@@ -215,7 +215,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once()) $image->expects($this->once())
->method('getType') ->method('getType')
->will($this->returnValue(\MediaVorus\Media\Media::TYPE_IMAGE)); ->will($this->returnValue(\MediaVorus\Media\MediaInterface::TYPE_IMAGE));
$file = new File($image, self::$collection, 'hello'); $file = new File($image, self::$collection, 'hello');
@@ -231,7 +231,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once()) $image->expects($this->once())
->method('getType') ->method('getType')
->will($this->returnValue(\MediaVorus\Media\Media::TYPE_DOCUMENT)); ->will($this->returnValue(\MediaVorus\Media\MediaInterface::TYPE_DOCUMENT));
$file = new File($image, self::$collection, 'hello'); $file = new File($image, self::$collection, 'hello');
@@ -247,7 +247,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once()) $image->expects($this->once())
->method('getType') ->method('getType')
->will($this->returnValue(\MediaVorus\Media\Media::TYPE_AUDIO)); ->will($this->returnValue(\MediaVorus\Media\MediaInterface::TYPE_AUDIO));
$file = new File($image, self::$collection, 'hello'); $file = new File($image, self::$collection, 'hello');
@@ -263,7 +263,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once()) $image->expects($this->once())
->method('getType') ->method('getType')
->will($this->returnValue(\MediaVorus\Media\Media::TYPE_VIDEO)); ->will($this->returnValue(\MediaVorus\Media\MediaInterface::TYPE_VIDEO));
$file = new File($image, self::$collection, 'hello'); $file = new File($image, self::$collection, 'hello');
@@ -279,7 +279,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once()) $image->expects($this->once())
->method('getType') ->method('getType')
->will($this->returnValue(\MediaVorus\Media\Media::TYPE_FLASH)); ->will($this->returnValue(\MediaVorus\Media\MediaInterface::TYPE_FLASH));
$file = new File($image, self::$collection, 'hello'); $file = new File($image, self::$collection, 'hello');

View File

@@ -45,10 +45,10 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new Manager(self::$core['EM'], new Filesystem()); $this->object = new Manager(self::$application);
$this->session = new \Entities\LazaretSession(); $this->session = new \Entities\LazaretSession();
self::$core['EM']->persist($this->session); self::$application['EM']->persist($this->session);
} }
/** /**
@@ -65,14 +65,15 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/ */
public function testProcess() public function testProcess()
{ {
$records = array(); $records = array();
$postProcessRecord = function($record) use(&$records) { $postProcessRecord = function($record) use(&$records) {
$records[] = $record; $records[] = $record;
}; };
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection), $postProcessRecord)); $this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']), $postProcessRecord));
$shaChecker = new Checker\Sha256(); $shaChecker = new Checker\Sha256(self::$application);
$this->object->registerChecker($shaChecker); $this->object->registerChecker($shaChecker);
$phpunit = $this; $phpunit = $this;
@@ -84,7 +85,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$records[] = $element; $records[] = $element;
}; };
$this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection), $postProcess)); $this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']), $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);
@@ -93,7 +94,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$records[] = $element; $records[] = $element;
}; };
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection), $postProcess, Manager::FORCE_RECORD)); $this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']), $postProcess, Manager::FORCE_RECORD));
foreach ($records as $record) { foreach ($records as $record) {
if ($record instanceof \record_adapter) { if ($record instanceof \record_adapter) {
@@ -112,8 +113,8 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$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::$collection), NULL, Manager::FORCE_LAZARET)); $this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']), NULL, Manager::FORCE_LAZARET));
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection), $postProcessRecord)); $this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']), $postProcessRecord));
foreach ($records as $record) { foreach ($records as $record) {
if ($record instanceof \record_adapter) { if ($record instanceof \record_adapter) {
@@ -133,7 +134,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$records[] = $record; $records[] = $record;
}; };
$file = File::buildFromPathfile(self::$file1, self::$collection); $file = File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']);
$first = $odd = false; $first = $odd = false;
$tofetch = array(); $tofetch = array();
foreach (self::$collection->get_databox()->get_meta_structure() as $databox_field) { foreach (self::$collection->get_databox()->get_meta_structure() as $databox_field) {
@@ -240,7 +241,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$lazaret = $element; $lazaret = $element;
}; };
$file = File::buildFromPathfile(self::$file1, self::$collection); $file = File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']);
$odd = false; $odd = false;
$tofetchMeta = $tofetchField = array(); $tofetchMeta = $tofetchField = array();
foreach (self::$collection->get_databox()->get_meta_structure() as $databox_field) { foreach (self::$collection->get_databox()->get_meta_structure() as $databox_field) {
@@ -296,7 +297,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
/* @var $lazaret \Entities\LazaretFile */ /* @var $lazaret \Entities\LazaretFile */
foreach ($lazaret->getAttributes() as $attr) { foreach ($lazaret->getAttributes() as $attr) {
$attribute = Attribute\Factory::getFileAttribute($attr->getName(), $attr->getValue()); $attribute = Attribute\Factory::getFileAttribute(self::$application, $attr->getName(), $attr->getValue());
if ($attribute->getName() == Attribute\Attribute::NAME_STORY) { if ($attribute->getName() == Attribute\Attribute::NAME_STORY) {
if ($attribute->getValue()->get_serialize_key() == self::$records['record_story_1']->get_serialize_key()) { if ($attribute->getValue()->get_serialize_key() == self::$records['record_story_1']->get_serialize_key()) {
@@ -354,7 +355,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/ */
public function testLazaretAttributes() public function testLazaretAttributes()
{ {
$file = File::buildFromPathfile(self::$file1, self::$collection); $file = File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']);
$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');
@@ -368,14 +369,15 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$file->addAttribute(new Attribute\Metadata($multiData)); $file->addAttribute(new Attribute\Metadata($multiData));
$phpunit = $this; $phpunit = $this;
$application = self::$application;
$postProcess = function($element, $visa, $code) use ($phpunit) { $postProcess = function($element, $visa, $code) use ($phpunit, $application) {
$phpunit->assertInstanceOf('\\Entities\\LazaretFile', $element); $phpunit->assertInstanceOf('\\Entities\\LazaretFile', $element);
/* @var $element \Entities\LazaretFile */ /* @var $element \Entities\LazaretFile */
foreach ($element->getAttributes() as $attribute) { foreach ($element->getAttributes() as $attribute) {
$phpunit->assertEquals('metadata', $attribute->getName()); $phpunit->assertEquals('metadata', $attribute->getName());
$value = Attribute\Factory::getFileAttribute($attribute->getName(), $attribute->getValue()); $value = Attribute\Factory::getFileAttribute($application, $attribute->getName(), $attribute->getValue());
$phpunit->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Metadata', $value); $phpunit->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Metadata', $value);
} }
}; };
@@ -388,15 +390,15 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/ */
public function testAddMediaAttributesPDF() public function testAddMediaAttributesPDF()
{ {
$manager = new ManagerTester(self::$core['EM'], new Filesystem()); $manager = new ManagerTester(self::$application);
if(null === self::$core['pdf-to-text']) { if(null === self::$application['xpdf.pdf2text']) {
$this->markTestSkipped('Pdf To Text could not be instantiate'); $this->markTestSkipped('Pdf To Text could not be instantiate');
} }
$manager->setPdfToText(self::$core['pdf-to-text']); $manager->setPdfToText(self::$application['xpdf.pdf2text']);
$file = File::buildFromPathfile(__DIR__ . '/../../../testfiles/HelloWorld.pdf', self::$collection); $file = File::buildFromPathfile(__DIR__ . '/../../../testfiles/HelloWorld.pdf', self::$collection, self::$application['mediavorus']);
$count = count($file->getAttributes()); $count = count($file->getAttributes());
$manager->addMediaAttributesTester($file); $manager->addMediaAttributesTester($file);
@@ -442,9 +444,9 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/ */
public function testAddMediaAttributesAudio() public function testAddMediaAttributesAudio()
{ {
$manager = new ManagerTester(self::$core['EM'], new Filesystem()); $manager = new ManagerTester(self::$application);
$file = File::buildFromPathfile(__DIR__ . '/../../../testfiles/test012.wav', self::$collection); $file = File::buildFromPathfile(__DIR__ . '/../../../testfiles/test012.wav', self::$collection, self::$application['mediavorus']);
$count = count($file->getAttributes()); $count = count($file->getAttributes());
$manager->addMediaAttributesTester($file); $manager->addMediaAttributesTester($file);
@@ -489,9 +491,9 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/ */
public function testAddMediaAttributes() public function testAddMediaAttributes()
{ {
$manager = new ManagerTester(self::$core['EM'], new Filesystem()); $manager = new ManagerTester(self::$application);
$file = File::buildFromPathfile(self::$file1, self::$collection); $file = File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']);
$count = count($file->getAttributes()); $count = count($file->getAttributes());
$manager->addMediaAttributesTester($file); $manager->addMediaAttributesTester($file);
@@ -542,24 +544,24 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$records[] = $record; $records[] = $record;
}; };
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$collection)); $visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']));
$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::$collection), $postProcessRecord); $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']), $postProcessRecord);
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$collection)); $visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']));
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
$this->assertTrue($visa->isValid()); $this->assertTrue($visa->isValid());
$this->object->registerChecker(new Checker\Sha256()); $this->object->registerChecker(new Checker\Sha256(self::$application));
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$collection)); $visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']));
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
@@ -580,9 +582,9 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
$this->assertEquals(array(), $this->object->getCheckers()); $this->assertEquals(array(), $this->object->getCheckers());
$shaChecker = new Checker\Sha256(); $shaChecker = new Checker\Sha256(self::$application);
$this->object->registerChecker($shaChecker); $this->object->registerChecker($shaChecker);
$uuidChecker = new Checker\UUID(); $uuidChecker = new Checker\UUID(self::$application);
$this->object->registerChecker($uuidChecker); $this->object->registerChecker($uuidChecker);
$this->assertEquals(array($shaChecker, $uuidChecker), $this->object->getCheckers()); $this->assertEquals(array($shaChecker, $uuidChecker), $this->object->getCheckers());
@@ -596,8 +598,8 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
$this->assertEquals(array(), $this->object->getCheckers()); $this->assertEquals(array(), $this->object->getCheckers());
$shaChecker = new Checker\Sha256(); $shaChecker = new Checker\Sha256(self::$application);
$uuidChecker = new Checker\UUID(); $uuidChecker = new Checker\UUID(self::$application);
$this->object->registerCheckers(array($shaChecker, $uuidChecker)); $this->object->registerCheckers(array($shaChecker, $uuidChecker));
$this->assertEquals(array($shaChecker, $uuidChecker), $this->object->getCheckers()); $this->assertEquals(array($shaChecker, $uuidChecker), $this->object->getCheckers());
@@ -610,9 +612,9 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
$this->assertEquals(array(), $this->object->getCheckers()); $this->assertEquals(array(), $this->object->getCheckers());
$shaChecker = new Checker\Sha256(); $shaChecker = new Checker\Sha256(self::$application);
$uuidChecker = new Checker\UUID(); $uuidChecker = new Checker\UUID(self::$application);
$filenameChecker = new Checker\Filename(); $filenameChecker = new Checker\Filename(self::$application);
$this->object->registerCheckers(array($shaChecker, $uuidChecker, $filenameChecker)); $this->object->registerCheckers(array($shaChecker, $uuidChecker, $filenameChecker));
$this->assertEquals(array($shaChecker, $uuidChecker, $filenameChecker), $this->object->getCheckers()); $this->assertEquals(array($shaChecker, $uuidChecker, $filenameChecker), $this->object->getCheckers());
@@ -626,7 +628,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/ */
public function testBookLazaretPathfile() public function testBookLazaretPathfile()
{ {
$manager = new ManagerTester(self::$core['EM'], new Filesystem()); $manager = new ManagerTester(self::$application);
$file1 = $manager->bookLazaretPathfileTester('babebibobu.txt'); $file1 = $manager->bookLazaretPathfileTester('babebibobu.txt');
$file2 = $manager->bookLazaretPathfileTester('babebibobu.txt'); $file2 = $manager->bookLazaretPathfileTester('babebibobu.txt');

View File

@@ -2,7 +2,7 @@
namespace Alchemy\Phrasea\Border; namespace Alchemy\Phrasea\Border;
class VisaTest extends \PHPUnit_Framework_TestCase class VisaTest extends \PhraseanetPHPUnitAbstract
{ {
/** /**
@@ -25,9 +25,9 @@ class VisaTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(), $visa->getResponses()); $this->assertEquals(array(), $visa->getResponses());
$response = new Checker\Response(true, new Checker\Filename()); $response = new Checker\Response(true, new Checker\Filename(self::$application));
$visa->addResponse($response); $visa->addResponse($response);
$response2 = new Checker\Response(false, new Checker\Filename()); $response2 = new Checker\Response(false, new Checker\Filename(self::$application));
$visa->addResponse($response2); $visa->addResponse($response2);
$this->assertSame(array($response, $response2), $visa->getResponses()); $this->assertSame(array($response, $response2), $visa->getResponses());
@@ -42,12 +42,12 @@ class VisaTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($visa->isValid()); $this->assertTrue($visa->isValid());
$response = new Checker\Response(true, new Checker\Filename()); $response = new Checker\Response(true, new Checker\Filename(self::$application));
$visa->addResponse($response); $visa->addResponse($response);
$this->assertTrue($visa->isValid()); $this->assertTrue($visa->isValid());
$response2 = new Checker\Response(false, new Checker\Filename()); $response2 = new Checker\Response(false, new Checker\Filename(self::$application));
$visa->addResponse($response2); $visa->addResponse($response2);
$this->assertFalse($visa->isValid()); $this->assertFalse($visa->isValid());