mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
Fix tests
This commit is contained in:
@@ -150,8 +150,8 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
. 'subdef[@name="' . $name . '"]'
|
||||
);
|
||||
|
||||
if ($nodes->length > 0) {
|
||||
$node = $nodes->item(0);
|
||||
for($i = 0; $i < $nodes->length; $i++) {
|
||||
$node = $nodes->item($i);
|
||||
$parent = $node->parentNode;
|
||||
$parent->removeChild($node);
|
||||
}
|
||||
|
@@ -5,21 +5,24 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
|
||||
class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
protected $client;
|
||||
protected $app;
|
||||
protected $databox;
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
|
||||
|
||||
$app['debug'] = true;
|
||||
unset($app['exception_handler']);
|
||||
|
||||
return $app;
|
||||
$this->app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
|
||||
|
||||
$this->app['debug'] = true;
|
||||
unset($this->app['exception_handler']);
|
||||
|
||||
return $this->app;
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->client = $this->createClient();
|
||||
$this->databox = array_shift($this->app['phraseanet.appbox']->get_databoxes());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,37 +30,38 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testRouteGetSubdef()
|
||||
{
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$this->client->request("GET", "/subdefs/" . $databox->get_sbas_id() . "/");
|
||||
$this->client->request("GET", "/subdefs/" . $this->databox->get_sbas_id() . "/");
|
||||
$this->assertTrue($this->client->getResponse()->isOk());
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'testname' . time() . mt_rand(10000, 99999);
|
||||
}
|
||||
|
||||
public function testPostRouteAddSubdef()
|
||||
{
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$this->client->request("POST", "/subdefs/" . $databox->get_sbas_id() . "/", array('add_subdef' => array(
|
||||
$name = $this->getName();
|
||||
$this->client->request("POST", "/subdefs/" . $this->databox->get_sbas_id() . "/", array('add_subdef' => array(
|
||||
'class' => 'thumbnail',
|
||||
'name' => 'aname',
|
||||
'name' => $name,
|
||||
'group' => 'image'
|
||||
)));
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
$subdefs->get_subdef("image", "aname");
|
||||
$subdefs->delete_subdef('image', 'aname');
|
||||
$subdefs = $this->databox->get_subdef_structure();
|
||||
$subdefs->get_subdef("image", $name);
|
||||
$subdefs->delete_subdef('image', $name);
|
||||
}
|
||||
|
||||
public function testPostRouteDeleteSubdef()
|
||||
{
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$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'));
|
||||
$subdefs = $this->databox->get_subdef_structure();
|
||||
$name = $this->getName();
|
||||
$subdefs->add_subdef("image", $name, "thumbnail");
|
||||
$this->client->request("POST", "/subdefs/" . $this->databox->get_sbas_id() . "/", array('delete_subdef' => 'image_' . $name));
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||
try {
|
||||
$subdefs->get_subdef("image", "name");
|
||||
$subdefs->get_subdef("image", $name);
|
||||
$this->fail("should raise an exception");
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -66,27 +70,27 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
public function testPostRouteAddSubdefWithNoParams()
|
||||
{
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$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() . "/"
|
||||
$subdefs = $this->databox->get_subdef_structure();
|
||||
$name = $this->getName();
|
||||
$subdefs->add_subdef("image", $name, "thumbnail");
|
||||
$this->client->request("POST", "/subdefs/" . $this->databox->get_sbas_id() . "/"
|
||||
, array('subdefs' => array(
|
||||
'image_name'
|
||||
'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
|
||||
, 'image_' . $name . '_class' => 'thumbnail'
|
||||
, '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");
|
||||
$subdefs = new databox_subdefsStructure( $this->databox);
|
||||
$subdef = $subdefs->get_subdef("image", $name);
|
||||
|
||||
/* @var $subdef \databox_subdef */
|
||||
$this->assertFalse($subdef->is_downloadable());
|
||||
@@ -100,6 +104,6 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->assertEquals(90, $options[\Alchemy\Phrasea\Media\Subdef\Image::OPTION_QUALITY]->getValue());
|
||||
$this->assertFalse($options[\Alchemy\Phrasea\Media\Subdef\Image::OPTION_STRIP]->getValue());
|
||||
|
||||
$subdefs->delete_subdef("image", "name");
|
||||
$subdefs->delete_subdef("image", $name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user