diff --git a/lib/classes/databox/subdef.php b/lib/classes/databox/subdef.php
index c3b8bca719..cd46f04714 100644
--- a/lib/classes/databox/subdef.php
+++ b/lib/classes/databox/subdef.php
@@ -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
*
diff --git a/tests/classes/databox/subdefTest.php b/tests/classes/databox/subdefTest.php
index 51148a9611..043e80bab0 100644
--- a/tests/classes/databox/subdefTest.php
+++ b/tests/classes/databox/subdefTest.php
@@ -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
image
';
- $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'
+
+
+ /home/datas/noweb/db_alch_phrasea/video/
+ image
+
+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);
+ }
}