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;
use Alchemy\Phrasea\Application;
/**
* File attribute interface
*/
interface Attribute
interface AttributeInterface
{
const NAME_METADATA = 'metadata';
const NAME_METAFIELD = 'metafield';
@@ -43,7 +45,10 @@ interface Attribute
/**
* Build the current object with is string value
*
* @param Application $app the application context
* @param string $string the serialized string
*
* @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;
use Alchemy\Phrasea\Application;
/**
* This factory is intended to create Attribute based on their name and
* serialized values. This is mostly used when reading Lazaret tables
@@ -21,27 +23,28 @@ class Factory
/**
* Build a file package Attribute
*
* @param Application $app Application context
* @param string $name The name of the attribute, one of the
* Attribute::NAME_* constants
* @param string $serialized The serialized value of the attribute
* (Attribute::asString result)
* @return Attribute The attribute
* @return AttributeInterface The attribute
* @throws \InvalidArgumentException
*/
public static function getFileAttribute($name, $serialized)
public static function getFileAttribute(Application $app, $name, $serialized)
{
switch ($name) {
case Attribute::NAME_METADATA:
return Metadata::loadFromString($serialized);
case AttributeInterface::NAME_METADATA:
return Metadata::loadFromString($app, $serialized);
break;
case Attribute::NAME_STORY:
return Story::loadFromString($serialized);
case AttributeInterface::NAME_STORY:
return Story::loadFromString($app, $serialized);
break;
case Attribute::NAME_METAFIELD:
return MetaField::loadFromString($serialized);
case AttributeInterface::NAME_METAFIELD:
return MetaField::loadFromString($app, $serialized);
break;
case Attribute::NAME_STATUS:
return Status::loadFromString($serialized);
case AttributeInterface::NAME_STATUS:
return Status::loadFromString($app, $serialized);
break;
}

View File

@@ -11,13 +11,15 @@
namespace Alchemy\Phrasea\Border\Attribute;
use Alchemy\Phrasea\Application;
/**
* Phraseanet Border MetaField Attribute
*
* This attribute is used to store a value related to a fieldname for a file
* prior to their record creation
*/
class MetaField implements Attribute
class MetaField implements AttributeInterface
{
/**
*
@@ -35,13 +37,13 @@ class MetaField implements Attribute
* Constructor
*
* @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
*/
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');
}
$this->databox_field = $databox_field;
@@ -101,20 +103,18 @@ class MetaField implements Attribute
*
* @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');
}
try {
$appbox = \appbox::get_instance(\bootstrap::getCore());
$databox = $appbox->get_databox($datas['sbas_id']);
$field = $databox->get_meta_structure()->get_element($datas['id']);
return new static($app['phraseanet.appbox']
->get_databox($datas['sbas_id'])
->get_meta_structure()->get_element($datas['id']), $datas['value']);
} catch (\Exception_NotFound $e) {
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;
use Alchemy\Phrasea\Application;
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
* their record creation
*/
class Metadata implements Attribute
class Metadata implements AttributeInterface
{
protected $metadata;
@@ -72,13 +73,13 @@ class Metadata implements Attribute
*
* @return Metadata
*/
public static function loadFromString($string)
public static function loadFromString(Application $app, $string)
{
if ( ! $metadata = @unserialize($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');
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager;
@@ -26,13 +27,14 @@ class Filename extends AbstractChecker
*
* @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'])) {
$options['sensitive'] = false;
}
$this->sensitive = (boolean) $options['sensitive'];
parent::__construct($app);
}
/**

View File

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

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager;
@@ -21,13 +22,18 @@ use Doctrine\ORM\EntityManager;
class Sha256 extends AbstractChecker
{
public function __construct(Application $app)
{
parent::__construct($app);
}
/**
* {@inheritdoc}
*/
public function check(EntityManager $em, File $file)
{
$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);

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager;
@@ -20,13 +21,18 @@ use Doctrine\ORM\EntityManager;
class UUID extends AbstractChecker
{
public function __construct(Application $app)
{
parent::__construct($app);
}
/**
* {@inheritdoc}
*/
public function check(EntityManager $em, File $file)
{
$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);

View File

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

View File

@@ -11,18 +11,31 @@
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 Doctrine\ORM\EntityManager;
use Entities\LazaretAttribute;
use Entities\LazaretFile;
use Entities\LazaretSession;
use MediaAlchemyst\Exception\Exception as MediaAlchemystException;
use MediaAlchemyst\Specification\Image as ImageSpec;
use Monolog\Logger;
use PHPExiftool\Driver\Metadata\Metadata;
use PHPExiftool\Driver\Value\Mono as MonoValue;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOException;
use XPDF\PdfToText;
@@ -36,7 +49,7 @@ use XPDF\PdfToText;
class Manager
{
protected $checkers = array();
protected $em;
protected $app;
protected $filesystem;
protected $pdfToText;
@@ -48,13 +61,11 @@ class Manager
/**
* Constructor
*
* @param \Doctrine\ORM\EntityManager $em Entity manager
* @param \Monolog\Logger $logger A logger
* @param Application $app The application context
*/
public function __construct(EntityManager $em, Filesystem $filesystem)
public function __construct(Application $app)
{
$this->em = $em;
$this->filesystem = $filesystem;
$this->app = $app;
}
/**
@@ -63,7 +74,7 @@ class Manager
*/
public function __destruct()
{
$this->em = $this->filesystem = null;
$this->app = null;
}
/**
@@ -135,7 +146,7 @@ class Manager
$visa = new Visa();
foreach ($this->checkers as $checker) {
$visa->addResponse($checker->check($this->em, $file));
$visa->addResponse($checker->check($this->app['EM'], $file));
}
return $visa;
@@ -144,10 +155,10 @@ class Manager
/**
* Registers a checker
*
* @param Checker\CheckerInterface $checker The checker to register
* @param CheckerInterface $checker The checker to register
* @return Manager
*/
public function registerChecker(Checker\CheckerInterface $checker)
public function registerChecker(CheckerInterface $checker)
{
$this->checkers[] = $checker;
@@ -172,10 +183,10 @@ class Manager
/**
* Unregister a checker
*
* @param Checker\CheckerInterface $checker The checker to unregister
* @param CheckerInterface $checker The checker to unregister
* @return Manager
*/
public function unregisterChecker(Checker\CheckerInterface $checker)
public function unregisterChecker(CheckerInterface $checker)
{
$checkers = $this->checkers;
foreach ($this->checkers as $offset => $registered) {
@@ -212,14 +223,14 @@ class Manager
$infos = pathinfo($output);
$n = 0;
$this->filesystem->mkdir(__DIR__ . '/../../../../tmp/lazaret');
$this->app['filesystem']->mkdir(__DIR__ . '/../../../../tmp/lazaret');
while (true) {
$output = sprintf('%s/%s-%d%s', $infos['dirname'], $infos['filename'], ++ $n, (isset($infos['extension']) ? '.' . $infos['extension'] : ''));
try {
if ( ! $this->filesystem->exists($output)) {
$this->filesystem->touch($output);
if ( ! $this->app['filesystem']->exists($output)) {
$this->app['filesystem']->touch($output);
break;
}
} catch (IOException $e) {
@@ -238,35 +249,33 @@ class Manager
*/
protected function createRecord(File $file)
{
$element = \record_adapter::createFromFile($file, $this->filesystem);
$element = \record_adapter::createFromFile($file, $this->app);
$date = new \DateTime();
$file->addAttribute(
new MetadataAttr(
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(
new MetadataAttr(
new Metadata(
new PhraseaTag\TfRecordid(), new MonoValue($element->get_record_id())
new TfRecordid(), new MonoValue($element->get_record_id())
)
)
);
$metadatas = array();
$fileEntity = $file->getMedia()->getEntity();
/**
* @todo $key is not tagname but fieldname
*/
$fieldToKeyMap = array();
if ( ! $fieldToKeyMap) {
if (! $fieldToKeyMap) {
foreach ($file->getCollection()->get_databox()->get_meta_structure() as $databox_field) {
$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();
@@ -303,7 +312,7 @@ class Manager
* @todo implement METATAG aka metadata by fieldname (where as
* current metadata is metadata by source.
*/
case Attribute\Attribute::NAME_METAFIELD:
case AttributeInterface::NAME_METAFIELD:
$key = $attribute->getField()->get_name();
@@ -314,7 +323,7 @@ class Manager
$metadatas[$key] = array_merge($metadatas[$key], array($attribute->getValue()));
break;
case Attribute\Attribute::NAME_METADATA:
case AttributeInterface::NAME_METADATA:
$key = $attribute->getValue()->getTag()->getTagname();
@@ -330,12 +339,12 @@ class Manager
$metadatas[$k] = array_merge($metadatas[$k], $attribute->getValue()->getValue()->asArray());
}
break;
case Attribute\Attribute::NAME_STATUS:
case AttributeInterface::NAME_STATUS:
$element->set_binary_status($element->get_status() | $attribute->getValue());
break;
case Attribute\Attribute::NAME_STORY:
case AttributeInterface::NAME_STORY:
$story = $attribute->getValue();
@@ -418,7 +427,7 @@ class Manager
$file->addAttribute(
new MetadataAttr(
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());
$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->setResizeMode(ImageSpec::RESIZE_MODE_INBOUND_FIXEDRATIO);
$spec->setDimensions(375, 275);
$core = \bootstrap::getCore();
try {
$core['media-alchemyst']
$this->app['media-alchemyst']
->open($file->getFile()->getPathname())
->turnInto($lazaretPathnameThumb, $spec)
->close();
@@ -457,7 +464,7 @@ class Manager
$lazaretFile->setSession($session);
$this->em->persist($lazaretFile);
$this->app['EM']->persist($lazaretFile);
foreach ($file->getAttributes() as $fileAttribute) {
$attribute = new LazaretAttribute();
@@ -467,7 +474,7 @@ class Manager
$lazaretFile->addLazaretAttribute($attribute);
$this->em->persist($attribute);
$this->app['EM']->persist($attribute);
}
foreach ($visa->getResponses() as $response) {
@@ -479,11 +486,11 @@ class Manager
$lazaretFile->addLazaretCheck($check);
$this->em->persist($check);
$this->app['EM']->persist($check);
}
}
$this->em->flush();
$this->app['EM']->flush();
return $lazaretFile;
}
@@ -502,7 +509,7 @@ class Manager
$file->addAttribute(
new MetadataAttr(
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(
new MetadataAttr(
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(
new MetadataAttr(
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(
new MetadataAttr(
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(
new MetadataAttr(
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(
new MetadataAttr(
new Metadata(
new PhraseaTag\PdfText(), new MonoValue($text)
new PdfText(), new MonoValue($text)
)
)
);
@@ -569,29 +576,29 @@ class Manager
$file->addAttribute(
new MetadataAttr(
new Metadata(
new PhraseaTag\TfMimetype(), new MonoValue($file->getFile()->getMimeType()))));
new TfMimetype(), new MonoValue($file->getFile()->getMimeType()))));
$file->addAttribute(
new MetadataAttr(
new Metadata(
new PhraseaTag\TfSize(), new MonoValue($file->getFile()->getSize()))));
new TfSize(), new MonoValue($file->getFile()->getSize()))));
$file->addAttribute(
new MetadataAttr(
new Metadata(
new PhraseaTag\TfBasename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_BASENAME))
new TfBasename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_BASENAME))
)
)
);
$file->addAttribute(
new MetadataAttr(
new Metadata(
new PhraseaTag\TfFilename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_FILENAME))
new TfFilename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_FILENAME))
)
)
);
$file->addAttribute(
new MetadataAttr(
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;
use PHPExiftool\Driver\Tag\IPTC\UniqueDocumentID;
use PHPExiftool\Driver\Value\Mono;
use PHPExiftool\Driver\Metadata\Metadata;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
class FactoryTest extends \PhraseanetPHPUnitAbstract
{
/**
* @covers Alchemy\Phrasea\Border\Attribute\Attribute
* @covers Alchemy\Phrasea\Border\Attribute\Factory::getFileAttribute
*/
public function testGetFileAttributeMetadata()
{
$tag = new \PHPExiftool\Driver\Tag\IPTC\UniqueDocumentID();
$value = new \PHPExiftool\Driver\Value\Mono('Unique');
$tag = new UniqueDocumentID();
$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);
}
@@ -28,7 +33,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/
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()
{
$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);
}
@@ -52,13 +57,13 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
break;
}
if ( ! $databox_field) {
if (!$databox_field) {
$this->markTestSkipped('No databox field found');
}
$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);
}
@@ -68,7 +73,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/
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);
}
@@ -79,7 +84,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/
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;
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()
{
Factory::getFileAttribute('nothing', 'nothong');
Factory::getFileAttribute(self::$application, 'nothing', 'nothong');
}
}

View File

@@ -98,7 +98,7 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract
*/
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()
{
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_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;
class MetadataTest extends \PHPUnit_Framework_TestCase
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
class MetadataTest extends \PhraseanetPHPUnitAbstract
{
/**
* @var Metadata
@@ -14,7 +16,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
* @covers Alchemy\Phrasea\Border\Attribute\Attribute
* @covers Alchemy\Phrasea\Border\Attribute\Metadata::__construct
*/
protected function setUp()
public function setUp()
{
parent::setUp();
$tag = new \PHPExiftool\Driver\Tag\MXF\ObjectName();
@@ -28,7 +30,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
/**
* @covers Alchemy\Phrasea\Border\Attribute\Metadata::__destruct
*/
protected function tearDown()
public function tearDown()
{
$this->object = null;
parent::tearDown();
@@ -63,7 +65,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadFromString()
{
$loaded = Metadata::loadFromString($this->object->asString());
$loaded = Metadata::loadFromString(self::$application, $this->object->asString());
$this->assertEquals($this->object, $loaded);
}
@@ -76,7 +78,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
{
\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()
{
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';
class StatusTest extends \PHPUnit_Framework_TestCase
class StatusTest extends \PhraseanetPHPUnitAbstract
{
/**
* @var Status
@@ -89,6 +89,6 @@ class StatusTest extends \PHPUnit_Framework_TestCase
{
$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
*/
protected $object;
protected $story;
/**
* @covers Alchemy\Phrasea\Border\Attribute\Attribute
@@ -18,7 +19,8 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
public function 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()
{
$this->story->delete();
$this->object = null;
parent::tearDown();
}
@@ -44,7 +47,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
*/
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()
{
$loaded = Story::loadFromString($this->object->asString());
$loaded = Story::loadFromString(self::$application, $this->object->asString());
$this->assertEquals($this->object, $loaded);
}
@@ -80,7 +83,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
*/
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;
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;
use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\EntityManager;
require_once __DIR__ . "/../../../../PhraseanetPHPUnitAbstract.class.inc";
class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
class AbstractCheckerTest extends \PhraseanetPHPUnitAbstract
{
/**
* @var AbstractChecker
@@ -18,13 +19,14 @@ class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
{
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);
}
public function tearDown()
{
$this->file = null;
parent::tearDown();
}
/**
@@ -46,7 +48,8 @@ class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
public function getDataboxesCombinaison()
{
$databox = $collection = null;
$appbox = \appbox::get_instance(\bootstrap::getCore());
$app = new Application();
$appbox = $app['phraseanet.appbox'];
foreach ($appbox->get_databoxes() as $db) {
if ( ! $collection) {
@@ -97,7 +100,8 @@ class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
public function getCollectionsCombinaison()
{
$othercollection = $collection = null;
$appbox = \appbox::get_instance(\bootstrap::getCore());
$app = new Application();
$appbox = $app['phraseanet.appbox'];
foreach ($appbox->get_databoxes() as $db) {
if ( ! $collection) {
@@ -167,7 +171,8 @@ class AbstractCheckerTest extends \PHPUnit_Framework_TestCase
public function getDataboxAndCollection()
{
$databox = $collection = null;
$appbox = \appbox::get_instance(\bootstrap::getCore());
$app = new Application();
$appbox = $app['phraseanet.appbox'];
foreach ($appbox->get_databoxes() as $db) {
if ( ! $databox) {

View File

@@ -18,7 +18,7 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract
public function 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()
{
$spl = new \SplFileInfo(__DIR__ . '/../../../../testfiles/test001.CR2');
$media = $this->getMock('\\MediaVorus\\Media\\Image', array('getColorSpace'), array($spl));
$media = $this
->getMockBuilder('\\MediaVorus\\Media\\Image')
->disableOriginalConstructor()
->getMock();
$media->expects($this->once())
->method('getColorSpace')
->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);
$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->assertTrue($response->isOk());
@@ -55,6 +58,6 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract
*/
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()
{
$spl = new \SplFileInfo(__DIR__ . '/../../../../testfiles/test001.CR2');
$media = $this->getMock('\\MediaVorus\\Media\\Image', array('getWidth', 'getHeight'), array($spl));
$media = $this
->getMockBuilder('\\MediaVorus\\Media\\Image')
->disableOriginalConstructor()
->getMock();
$media->expects($this->any())
->method('getWidth')
@@ -28,36 +29,39 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
$media->expects($this->any())
->method('getHeight')
->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);
$object = new Dimension(array('width' => 800));
$response = $object->check(self::$core['EM'], $File);
$object = new Dimension(self::$application, array('width' => 800));
$response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertFalse($response->isOk());
$object = new Dimension(array('width' => 500));
$response = $object->check(self::$core['EM'], $File);
$object = new Dimension(self::$application, array('width' => 500));
$response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertFalse($response->isOk());
$object = new Dimension(array('width' => 400));
$response = $object->check(self::$core['EM'], $File);
$object = new Dimension(self::$application, array('width' => 400));
$response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertTrue($response->isOk());
$object = new Dimension(array('width' => 600, 'height' => 500));
$response = $object->check(self::$core['EM'], $File);
$object = new Dimension(self::$application, array('width' => 600, 'height' => 500));
$response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertFalse($response->isOk());
$object = new Dimension(array('width' => 600, 'height' => 400));
$response = $object->check(self::$core['EM'], $File);
$object = new Dimension(self::$application, array('width' => 600, 'height' => 400));
$response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertTrue($response->isOk());
$object = new Dimension(array('width' => 200, 'height' => 200));
$response = $object->check(self::$core['EM'], $File);
$object = new Dimension(self::$application, array('width' => 200, 'height' => 200));
$response = $object->check(self::$application['EM'], $File);
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertTrue($response->isOk());
}
@@ -78,7 +82,7 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
$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));
} catch (\InvalidArgumentException $e) {
@@ -114,6 +118,6 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract
*/
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()
{
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')
->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())
->method('getFile')
->will($this->returnValue($spl));
$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());
}
@@ -68,6 +70,6 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract
*/
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()
{
parent::setUp();
$this->object = new Filename;
$this->object = new Filename(self::$application);
$this->filename = __DIR__ . '/../../../../../tmp/test001.CR2';
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()
@@ -42,7 +42,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
*/
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);
@@ -62,7 +62,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
->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);
@@ -85,14 +85,14 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
->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->assertFalse($response->isOk());
$objectSensitive = new Filename(array('sensitive' => true));
$responseSensitive = $objectSensitive->check(self::$core['EM'], $mock);
$objectSensitive = new Filename(self::$application, array('sensitive' => true));
$responseSensitive = $objectSensitive->check(self::$application['EM'], $mock);
$this->assertTrue($responseSensitive->isOk());

View File

@@ -18,7 +18,7 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract
public function 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()
{
$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);
$response = $this->object->check(self::$core['EM'], $file);
$response = $this->object->check(self::$application['EM'], $file);
$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);
$response = $object->check(self::$core['EM'], $file);
$response = $object->check(self::$application['EM'], $file);
$this->assertFalse($response->isOk());
}
@@ -54,6 +54,6 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract
*/
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()
{
parent::setUp();
$this->object = new Sha256;
$this->object = new Sha256(self::$application);
$this->filename = __DIR__ . '/../../../../../tmp/test001.CR2';
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()
@@ -39,9 +39,9 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
public function testCheck()
{
$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));
@@ -51,7 +51,7 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
->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);
@@ -71,7 +71,7 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
->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);

View File

@@ -18,10 +18,10 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
public function setUp()
{
parent::setUp();
$this->object = new UUID;
$this->object = new UUID(self::$application);
$this->filename = __DIR__ . '/../../../../../tmp/test001.CR2';
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()
@@ -38,7 +38,7 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
*/
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);
@@ -58,7 +58,7 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
->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);

View File

@@ -22,7 +22,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$this->filename = __DIR__ . '/../../../../tmp/iphone_pic.jpg';
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');
}
@@ -60,20 +60,20 @@ class FileTest extends \PhraseanetPHPUnitAbstract
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);
$this->assertTrue(\uuid::is_valid($uuid));
$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);
$this->assertTrue(\uuid::is_valid($newuuid));
$this->assertNotEquals($uuid, $newuuid);
$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();
$this->assertTrue(\uuid::is_valid($uuid));
@@ -139,7 +139,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
*/
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());
}
@@ -180,18 +180,18 @@ class FileTest extends \PhraseanetPHPUnitAbstract
*/
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);
$file2 = File::buildFromPathfile($this->filename, self::$collection);
$file2 = File::buildFromPathfile($this->filename, self::$collection, self::$application['mediavorus']);
$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');
$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->assertNotEquals($file1, $file4);
@@ -203,7 +203,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
*/
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())
->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');
@@ -231,7 +231,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once())
->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');
@@ -247,7 +247,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once())
->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');
@@ -263,7 +263,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once())
->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');
@@ -279,7 +279,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract
$image->expects($this->once())
->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');

View File

@@ -45,10 +45,10 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
public function setUp()
{
parent::setUp();
$this->object = new Manager(self::$core['EM'], new Filesystem());
$this->object = new Manager(self::$application);
$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()
{
$records = array();
$postProcessRecord = function($record) use(&$records) {
$records[] = $record;
};
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection), $postProcessRecord));
$shaChecker = new Checker\Sha256();
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']), $postProcessRecord));
$shaChecker = new Checker\Sha256(self::$application);
$this->object->registerChecker($shaChecker);
$phpunit = $this;
@@ -84,7 +85,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$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) {
$phpunit->assertInstanceOf('\\record_adapter', $element);
@@ -93,7 +94,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$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) {
if ($record instanceof \record_adapter) {
@@ -112,8 +113,8 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$postProcessRecord = function($record) use(&$records) {
$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::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$collection), $postProcessRecord));
$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, self::$application['mediavorus']), $postProcessRecord));
foreach ($records as $record) {
if ($record instanceof \record_adapter) {
@@ -133,7 +134,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$records[] = $record;
};
$file = File::buildFromPathfile(self::$file1, self::$collection);
$file = File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']);
$first = $odd = false;
$tofetch = array();
foreach (self::$collection->get_databox()->get_meta_structure() as $databox_field) {
@@ -240,7 +241,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$lazaret = $element;
};
$file = File::buildFromPathfile(self::$file1, self::$collection);
$file = File::buildFromPathfile(self::$file1, self::$collection, self::$application['mediavorus']);
$odd = false;
$tofetchMeta = $tofetchField = array();
foreach (self::$collection->get_databox()->get_meta_structure() as $databox_field) {
@@ -296,7 +297,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
/* @var $lazaret \Entities\LazaretFile */
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->getValue()->get_serialize_key() == self::$records['record_story_1']->get_serialize_key()) {
@@ -354,7 +355,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/
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();
$monoValue = new \PHPExiftool\Driver\Value\Mono('title');
@@ -368,14 +369,15 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$file->addAttribute(new Attribute\Metadata($multiData));
$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);
/* @var $element \Entities\LazaretFile */
foreach ($element->getAttributes() as $attribute) {
$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);
}
};
@@ -388,15 +390,15 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/
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');
}
$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());
$manager->addMediaAttributesTester($file);
@@ -442,9 +444,9 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/
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());
$manager->addMediaAttributesTester($file);
@@ -489,9 +491,9 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/
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());
$manager->addMediaAttributesTester($file);
@@ -542,24 +544,24 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
$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->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->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);
@@ -580,9 +582,9 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{
$this->assertEquals(array(), $this->object->getCheckers());
$shaChecker = new Checker\Sha256();
$shaChecker = new Checker\Sha256(self::$application);
$this->object->registerChecker($shaChecker);
$uuidChecker = new Checker\UUID();
$uuidChecker = new Checker\UUID(self::$application);
$this->object->registerChecker($uuidChecker);
$this->assertEquals(array($shaChecker, $uuidChecker), $this->object->getCheckers());
@@ -596,8 +598,8 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{
$this->assertEquals(array(), $this->object->getCheckers());
$shaChecker = new Checker\Sha256();
$uuidChecker = new Checker\UUID();
$shaChecker = new Checker\Sha256(self::$application);
$uuidChecker = new Checker\UUID(self::$application);
$this->object->registerCheckers(array($shaChecker, $uuidChecker));
$this->assertEquals(array($shaChecker, $uuidChecker), $this->object->getCheckers());
@@ -610,9 +612,9 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{
$this->assertEquals(array(), $this->object->getCheckers());
$shaChecker = new Checker\Sha256();
$uuidChecker = new Checker\UUID();
$filenameChecker = new Checker\Filename();
$shaChecker = new Checker\Sha256(self::$application);
$uuidChecker = new Checker\UUID(self::$application);
$filenameChecker = new Checker\Filename(self::$application);
$this->object->registerCheckers(array($shaChecker, $uuidChecker, $filenameChecker));
$this->assertEquals(array($shaChecker, $uuidChecker, $filenameChecker), $this->object->getCheckers());
@@ -626,7 +628,7 @@ class ManagerTest extends \PhraseanetPHPUnitAuthenticatedAbstract
*/
public function testBookLazaretPathfile()
{
$manager = new ManagerTester(self::$core['EM'], new Filesystem());
$manager = new ManagerTester(self::$application);
$file1 = $manager->bookLazaretPathfileTester('babebibobu.txt');
$file2 = $manager->bookLazaretPathfileTester('babebibobu.txt');

View File

@@ -2,7 +2,7 @@
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());
$response = new Checker\Response(true, new Checker\Filename());
$response = new Checker\Response(true, new Checker\Filename(self::$application));
$visa->addResponse($response);
$response2 = new Checker\Response(false, new Checker\Filename());
$response2 = new Checker\Response(false, new Checker\Filename(self::$application));
$visa->addResponse($response2);
$this->assertSame(array($response, $response2), $visa->getResponses());
@@ -42,12 +42,12 @@ class VisaTest extends \PHPUnit_Framework_TestCase
$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);
$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);
$this->assertFalse($visa->isValid());