mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Add orderable flat to subdef
This commit is contained in:
@@ -59,6 +59,11 @@ class databox_subdef
|
||||
*/
|
||||
private $requiresMetadataUpdate;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $orderable;
|
||||
|
||||
/**
|
||||
* @param SubdefType $type
|
||||
* @param SimpleXMLElement $sd
|
||||
@@ -76,6 +81,7 @@ class databox_subdef
|
||||
|
||||
$this->name = strtolower($sd->attributes()->name);
|
||||
$this->downloadable = p4field::isyes($sd->attributes()->downloadable);
|
||||
$this->orderable = isset($sd->attributes()->orderable) ? p4field::isyes($sd->attributes()->orderable) : true;
|
||||
$this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : '';
|
||||
|
||||
$this->requiresMetadataUpdate = p4field::isyes((string) $sd->meta);
|
||||
@@ -314,6 +320,14 @@ class databox_subdef
|
||||
return $this->downloadable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isOrderable()
|
||||
{
|
||||
return $this->orderable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of Alchemy\Phrasea\Media\Subdef\Subdef available for the current Media Type
|
||||
*
|
||||
|
@@ -15,7 +15,7 @@ class databox_subdefTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->translator = $this->getMock(TranslatorInterface::class);
|
||||
$this->translator = $this->getTranslatorMock();
|
||||
}
|
||||
|
||||
public function testImage()
|
||||
@@ -205,7 +205,7 @@ class databox_subdefTest extends \PHPUnit_Framework_TestCase
|
||||
<mediatype>image</mediatype>
|
||||
</subdef>';
|
||||
|
||||
$translator = $this->getMock(TranslatorInterface::class);
|
||||
$translator = $this->getTranslatorMock();
|
||||
|
||||
return [
|
||||
[new databox_subdef(new Type\Audio(), simplexml_load_string($xmlImage), $translator)],
|
||||
@@ -213,4 +213,47 @@ class databox_subdefTest extends \PHPUnit_Framework_TestCase
|
||||
[new databox_subdef(new Type\Video(), simplexml_load_string($xmlImage), $translator)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $expected
|
||||
* @param null|string $configValue
|
||||
* @dataProvider providesOrderableStatuses
|
||||
*/
|
||||
public function testOrderableStatus($expected, $configValue, $message)
|
||||
{
|
||||
$xmlTemplate = <<<'EOF'
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<subdef class="thumbnail" name="gifou" downloadable="false"%s>
|
||||
<path>/home/datas/noweb/db_alch_phrasea/video/</path>
|
||||
<mediatype>image</mediatype>
|
||||
</subdef>
|
||||
EOF;
|
||||
|
||||
if (null !== $configValue) {
|
||||
$configValue = ' orderable="' . $configValue . '"';
|
||||
}
|
||||
|
||||
$xml = sprintf($xmlTemplate, $configValue ?: '');
|
||||
|
||||
$sut = new databox_subdef(new Type\Image(), simplexml_load_string($xml), $this->translator);
|
||||
|
||||
$this->assertSame($expected, $sut->isOrderable(), $message);
|
||||
}
|
||||
|
||||
public function providesOrderableStatuses()
|
||||
{
|
||||
return [
|
||||
[true, null, 'No Orderable Status set should defaults to true'],
|
||||
[false, 'false', 'Orderable should be false'],
|
||||
[true, 'true', 'Orderable should be true'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_MockObject|TranslatorInterface
|
||||
*/
|
||||
private function getTranslatorMock()
|
||||
{
|
||||
return $this->getMock(TranslatorInterface::class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user