mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge pull request #2393 from xrousset78800/PHRAS-1719/add-subset-presets-on-4-1
PHRAS-1719 Add presets selection on subdef admin page | Port to 4.1 PHRAS-1317
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Media\Subdef\Image;
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
* @group legacy
|
||||
@@ -13,9 +12,7 @@ use Alchemy\Phrasea\Media\Subdef\Image;
|
||||
class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
protected $client;
|
||||
|
||||
protected $databox_id;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -24,12 +21,10 @@ class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$databox = array_shift($databoxes);
|
||||
$this->databox_id = $databox->get_sbas_id();
|
||||
}
|
||||
|
||||
public function getSubdefName()
|
||||
{
|
||||
return 'testname' . time() . mt_rand(10000, 99999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default route test
|
||||
*/
|
||||
@@ -38,73 +33,63 @@ class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
self::$DI['client']->request("GET", "/admin/subdefs/" . $this->databox_id . "/");
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
}
|
||||
|
||||
public function testPostRouteAddSubdef()
|
||||
{
|
||||
$name = $this->getSubdefName();
|
||||
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/", ['add_subdef' => [
|
||||
'class' => 'thumbnail',
|
||||
'name' => $name,
|
||||
'group' => 'image'
|
||||
]]);
|
||||
'class' => 'thumbnail',
|
||||
'name' => $name,
|
||||
'group' => 'image'
|
||||
]]);
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
|
||||
$app = $this->getApplication();
|
||||
$subdefs = new \databox_subdefsStructure($app->findDataboxById($this->databox_id), $app['translator']);
|
||||
$subdefs->delete_subdef('image', $name);
|
||||
}
|
||||
|
||||
public function testPostRouteDeleteSubdef()
|
||||
{
|
||||
$subdefs = $this->getApplication()->findDataboxById($this->databox_id)->get_subdef_structure();
|
||||
$name = $this->getSubdefName();
|
||||
$subdefs->add_subdef("image", $name, "thumbnail");
|
||||
$subdefs->add_subdef("image", $name, "thumbnail", "image", "1280px JPG (preview Phraseanet)");
|
||||
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/", ['delete_subdef' => 'image_' . $name]);
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
try {
|
||||
$subdefs->get_subdef("image", $name);
|
||||
$this->fail("should raise an exception");
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testPostRouteAddSubdefWithNoParams()
|
||||
{
|
||||
$subdefs = $this->getApplication()->findDataboxById($this->databox_id)->get_subdef_structure();
|
||||
$name = $this->getSubdefName();
|
||||
$subdefs->add_subdef("image", $name, "thumbnail");
|
||||
$subdefs->add_subdef("image", $name, "thumbnail", "image", "1280px JPG (preview Phraseanet)");
|
||||
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/"
|
||||
, ['subdefs' => [
|
||||
'image_' . $name
|
||||
]
|
||||
, 'image_' . $name . '_class' => 'thumbnail'
|
||||
, 'image_' . $name . '_downloadable' => 0
|
||||
, 'image_' . $name . '_mediatype' => 'image'
|
||||
, 'image_' . $name . '_image' => [
|
||||
'size' => 400,
|
||||
'resolution' => 83,
|
||||
'strip' => 0,
|
||||
'quality' => 90,
|
||||
]]
|
||||
, 'image_' . $name . '_class' => 'thumbnail'
|
||||
, 'image_' . $name . '_downloadable' => 0
|
||||
, 'image_' . $name . '_mediatype' => 'image'
|
||||
, 'image_' . $name . '_image' => [
|
||||
'size' => 400,
|
||||
'resolution' => 83,
|
||||
'strip' => 0,
|
||||
'quality' => 90,
|
||||
]]
|
||||
);
|
||||
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
$app = $this->getApplication();
|
||||
$subdefs = new \databox_subdefsStructure($app->findDataboxById($this->databox_id), $app['translator']);
|
||||
$subdef = $subdefs->get_subdef("image", $name);
|
||||
|
||||
/* @var $subdef \databox_subdef */
|
||||
$this->assertFalse($subdef->isDownloadable());
|
||||
|
||||
$options = $subdef->getOptions();
|
||||
|
||||
$this->assertTrue(is_array($options));
|
||||
|
||||
$this->assertEquals(400, $options[Image::OPTION_SIZE]->getValue());
|
||||
$this->assertEquals(83, $options[Image::OPTION_RESOLUTION]->getValue());
|
||||
$this->assertEquals(90, $options[Image::OPTION_QUALITY]->getValue());
|
||||
$this->assertFalse($options[Image::OPTION_STRIP]->getValue());
|
||||
|
||||
$subdefs->delete_subdef("image", $name);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user