mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
Merge with master
This commit is contained in:
@@ -9,11 +9,11 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
|
||||
class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* As controllers use WebTestCase, it requires a client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* If the controller tests require some records, specify it her
|
||||
*
|
||||
@@ -42,11 +42,77 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
/**
|
||||
* Default route test
|
||||
*/
|
||||
public function testRouteSlash()
|
||||
public function testRouteGetSubdef()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
$appbox = appbox::get_instance();
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$this->client->request("GET", "/subdefs/" . $databox->get_sbas_id() . "/");
|
||||
$this->assertTrue($this->client->getResponse()->isOk());
|
||||
}
|
||||
|
||||
public function testPostRouteAddSubdef()
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$this->client->request("POST", "/subdefs/" . $databox->get_sbas_id() . "/", array('add_subdef' => array(
|
||||
'class' => 'a_class',
|
||||
'name' => 'a_name',
|
||||
'group' => 'image'
|
||||
)));
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
$subdefs->get_subdef("image", "a_name");
|
||||
$subdefs->delete_subdef('image', 'a_name');
|
||||
}
|
||||
|
||||
public function testPostRouteDeleteSubdef()
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
$subdefs->add_subdef("image", "name", "class");
|
||||
$this->client->request("POST", "/subdefs/" . $databox->get_sbas_id() . "/", array('delete_subdef' => 'group_name'));
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||
try
|
||||
{
|
||||
$subdefs->get_subdef("image", "name");
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testPostRouteAddSubdefWithNoParams()
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
$subdefs->add_subdef("image", "name", "class");
|
||||
$this->client->request("POST", "/subdefs/" . $databox->get_sbas_id() . "/", array('subdefs' => array(
|
||||
'image_name'
|
||||
)
|
||||
, 'image_name_class' => 'class'
|
||||
, 'image_name_downloadable' => 0
|
||||
, 'image_name_mediatype' => 'image'
|
||||
, 'image_name_image' => array(
|
||||
'size' => 400
|
||||
, 'resolution' => 83
|
||||
, 'strip' => 0
|
||||
, 'quality' => 90
|
||||
))
|
||||
);
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||
$subdef = $subdefs->get_subdef("image", "name");
|
||||
/* @var $subdef \databox_subdefAbstract */
|
||||
$this->assertFalse($subdef->is_downloadable());
|
||||
$options = $subdef->get_options();
|
||||
$this->assertEquals(400, $options["size"]);
|
||||
$this->assertEquals(83, $options["resolution"]);
|
||||
$this->assertEquals(90, $options["quality"]);
|
||||
$this->assertFalse($options["strip"]);
|
||||
$subdefs->delete_subdef("image", "name");
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user