mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 22:13:13 +00:00
complete admin controller tests
This commit is contained in:
@@ -64,7 +64,6 @@ class Description implements ControllerProviderInterface
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$field = \databox_field::get_instance($databox, $id);
|
$field = \databox_field::get_instance($databox, $id);
|
||||||
|
|
||||||
$field->set_name($request->get('name_' . $id));
|
$field->set_name($request->get('name_' . $id));
|
||||||
$field->set_thumbtitle($request->get('thumbtitle_' . $id));
|
$field->set_thumbtitle($request->get('thumbtitle_' . $id));
|
||||||
$field->set_source($request->get('src_' . $id));
|
$field->set_source($request->get('src_' . $id));
|
||||||
@@ -113,7 +112,7 @@ class Description implements ControllerProviderInterface
|
|||||||
$field->set_regdesc();
|
$field->set_regdesc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -122,7 +121,7 @@ class Description implements ControllerProviderInterface
|
|||||||
|
|
||||||
if ($request->get('newfield'))
|
if ($request->get('newfield'))
|
||||||
{
|
{
|
||||||
\databox_field::create($databox, $request->get('newfield'));
|
$field = \databox_field::create($databox, $request->get('newfield'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($request->get('todelete_ids')))
|
if (is_array($request->get('todelete_ids')))
|
||||||
@@ -152,7 +151,7 @@ class Description implements ControllerProviderInterface
|
|||||||
$databox->get_connection()->commit();
|
$databox->get_connection()->commit();
|
||||||
|
|
||||||
return new RedirectResponse('/admin/databox/' . $sbas_id . '/description/');
|
return new RedirectResponse('/admin/databox/' . $sbas_id . '/description/');
|
||||||
});
|
})->assert('sbas_id', '\d+');
|
||||||
|
|
||||||
$controllers->get('/{sbas_id}/', function(Application $app, $sbas_id)
|
$controllers->get('/{sbas_id}/', function(Application $app, $sbas_id)
|
||||||
{
|
{
|
||||||
@@ -182,7 +181,7 @@ class Description implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
return new Response($Core->getTwig()->render('admin/databox/doc_structure.twig', $params));
|
return new Response($Core->getTwig()->render('admin/databox/doc_structure.twig', $params));
|
||||||
});
|
})->assert('sbas_id', '\d+');
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
, 'error' => $app['request']->get('error')
|
, 'error' => $app['request']->get('error')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
})->assert('id', '\d+');
|
||||||
|
|
||||||
|
|
||||||
$controllers->post('/feed/{id}/update/', function($id) use ($app, $appbox)
|
$controllers->post('/feed/{id}/update/', function($id) use ($app, $appbox)
|
||||||
@@ -108,7 +108,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
$feed->set_public($request->get('public'));
|
$feed->set_public($request->get('public'));
|
||||||
|
|
||||||
return $app->redirect('/admin/publications/list/');
|
return $app->redirect('/admin/publications/list/');
|
||||||
});
|
})->assert('id', '\d+');
|
||||||
|
|
||||||
|
|
||||||
$controllers->post('/feed/{id}/iconupload/', function($id) use ($app, $appbox)
|
$controllers->post('/feed/{id}/iconupload/', function($id) use ($app, $appbox)
|
||||||
@@ -150,7 +150,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
unlink($file->getPathname());
|
unlink($file->getPathname());
|
||||||
|
|
||||||
return new Response('FILEHREF:' . $feed->get_icon_url() . '?' . mt_rand(100000, 999999));
|
return new Response('FILEHREF:' . $feed->get_icon_url() . '?' . mt_rand(100000, 999999));
|
||||||
});
|
})->assert('id', '\d+');
|
||||||
|
|
||||||
$controllers->post('/feed/{id}/addpublisher/', function($id) use ($app, $appbox)
|
$controllers->post('/feed/{id}/addpublisher/', function($id) use ($app, $appbox)
|
||||||
{
|
{
|
||||||
@@ -168,7 +168,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error);
|
return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error);
|
||||||
});
|
})->assert('id', '\d+');
|
||||||
|
|
||||||
|
|
||||||
$controllers->post('/feed/{id}/removepublisher/', function($id) use ($app, $appbox)
|
$controllers->post('/feed/{id}/removepublisher/', function($id) use ($app, $appbox)
|
||||||
@@ -189,7 +189,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error);
|
return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error);
|
||||||
});
|
})->assert('id', '\d+');
|
||||||
|
|
||||||
$controllers->post('/feed/{id}/delete/', function($id) use ($app, $appbox)
|
$controllers->post('/feed/{id}/delete/', function($id) use ($app, $appbox)
|
||||||
{
|
{
|
||||||
|
@@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
@@ -44,13 +45,13 @@ class Subdefs implements ControllerProviderInterface
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
})->assert('sbas_id', '\d+');
|
||||||
|
|
||||||
$controllers->post('/{sbas_id}/', function(Application $app, $sbas_id)
|
$controllers->post('/{sbas_id}/', function(Application $app, Request $request, $sbas_id)
|
||||||
{
|
{
|
||||||
$delete_subdef = $request->get('delete_subdef');
|
$delete_subdef = $request->get('delete_subdef');
|
||||||
$toadd_subdef = $request->get('add_subdef');
|
$toadd_subdef = $request->get('add_subdef');
|
||||||
$Parmsubdefs = $request->get('subdefs');
|
$Parmsubdefs = $request->get('subdefs', array());
|
||||||
|
|
||||||
$databox = \databox::get_instance((int) $sbas_id);
|
$databox = \databox::get_instance((int) $sbas_id);
|
||||||
|
|
||||||
@@ -91,47 +92,46 @@ class Subdefs implements ControllerProviderInterface
|
|||||||
foreach ($Parmsubdefs as $post_sub)
|
foreach ($Parmsubdefs as $post_sub)
|
||||||
{
|
{
|
||||||
$post_sub_ex = explode('_', $post_sub);
|
$post_sub_ex = explode('_', $post_sub);
|
||||||
|
|
||||||
$group = $post_sub_ex[0];
|
$group = $post_sub_ex[0];
|
||||||
$name = $post_sub_ex[1];
|
$name = $post_sub_ex[1];
|
||||||
|
|
||||||
$parm_loc = $request->get_parms($post_sub . '_class', $post_sub . '_downloadable');
|
$class = $request->get($post_sub . '_class');
|
||||||
|
$downloadable = $request->get($post_sub . '_downloadable');
|
||||||
$class = $parm_loc[$post_sub . '_class'];
|
|
||||||
$downloadable = $parm_loc[$post_sub . '_downloadable'];
|
|
||||||
|
|
||||||
$defaults = array('path', 'baseurl', 'meta', 'mediatype');
|
$defaults = array('path', 'baseurl', 'meta', 'mediatype');
|
||||||
|
|
||||||
foreach ($defaults as $def)
|
foreach ($defaults as $def)
|
||||||
{
|
{
|
||||||
$parm_loc = $request->get_parms($post_sub . '_' . $def);
|
$parm_loc = $request->get($post_sub . '_' . $def);
|
||||||
|
|
||||||
if ($def == 'meta' && !$parm_loc[$post_sub . '_' . $def])
|
if ($def == 'meta' && !$parm_loc)
|
||||||
{
|
{
|
||||||
$parm_loc[$post_sub . '_' . $def] = "no";
|
$parm_loc = "no";
|
||||||
}
|
}
|
||||||
|
|
||||||
$options[$def] = $parm_loc[$post_sub . '_' . $def];
|
$options[$def] = $parm_loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parm_loc = $request->get_parms($post_sub . '_mediatype');
|
$mediatype = $request->get($post_sub . '_mediatype');
|
||||||
$mediatype = $parm_loc[$post_sub . '_mediatype'];
|
$media = $request->get($post_sub . '_' . $mediatype, array());
|
||||||
$parm_loc = $request->get_parms($post_sub . '_' . $mediatype);
|
|
||||||
|
|
||||||
if (isset($parm_loc[$post_sub . '_' . $mediatype]))
|
foreach ($media as $option => $value)
|
||||||
{
|
|
||||||
foreach ($parm_loc[$post_sub . '_' . $mediatype] as $option => $value)
|
|
||||||
{
|
{
|
||||||
if ($option == 'resolution' && $mediatype == 'image')
|
if ($option == 'resolution' && $mediatype == 'image')
|
||||||
|
{
|
||||||
$option = 'dpi';
|
$option = 'dpi';
|
||||||
$options[$option] = $value;
|
|
||||||
}
|
}
|
||||||
|
$options[$option] = $value;
|
||||||
}
|
}
|
||||||
$subdefs->set_subdef($group, $name, $class, $downloadable, $options);
|
$subdefs->set_subdef($group, $name, $class, $downloadable, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return \phrasea::redirect('/admin/subdefs/' . $databox->get_sbas_id() . '/');
|
return new RedirectResponse('/admin/subdefs/' . $databox->get_sbas_id() . '/');
|
||||||
});
|
})->assert('sbas_id', '\d+');
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -876,7 +876,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
return self::get_instance($databox, $id);
|
return self::get_instance($databox, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function generateName($name)
|
public static function generateName($name)
|
||||||
{
|
{
|
||||||
$unicode_processor = new unicode();
|
$unicode_processor = new unicode();
|
||||||
|
@@ -65,7 +65,6 @@ class databox_subdefsStructure implements IteratorAggregate
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!$sx_struct)
|
if (!$sx_struct)
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
$subdefgroup = $sx_struct->subdefs[0];
|
$subdefgroup = $sx_struct->subdefs[0];
|
||||||
@@ -129,8 +128,9 @@ class databox_subdefsStructure implements IteratorAggregate
|
|||||||
public function get_subdef($subdef_type, $subdef_name)
|
public function get_subdef($subdef_type, $subdef_name)
|
||||||
{
|
{
|
||||||
if (isset($this->AvSubdefs[$subdef_type]) && isset($this->AvSubdefs[$subdef_type][$subdef_name]))
|
if (isset($this->AvSubdefs[$subdef_type]) && isset($this->AvSubdefs[$subdef_type][$subdef_name]))
|
||||||
|
{
|
||||||
return $this->AvSubdefs[$subdef_type][$subdef_name];
|
return $this->AvSubdefs[$subdef_type][$subdef_name];
|
||||||
|
}
|
||||||
throw new Exception_Databox_SubdefNotFound();
|
throw new Exception_Databox_SubdefNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ class databox_subdefsStructure implements IteratorAggregate
|
|||||||
* @param string $class
|
* @param string $class
|
||||||
* @return databox_subdefsStructure
|
* @return databox_subdefsStructure
|
||||||
*/
|
*/
|
||||||
public function add_subdef($group, $name, $class)
|
public function add_subdef($groupname, $name, $class)
|
||||||
{
|
{
|
||||||
$dom_struct = $this->databox->get_dom_structure();
|
$dom_struct = $this->databox->get_dom_structure();
|
||||||
|
|
||||||
@@ -182,13 +182,13 @@ class databox_subdefsStructure implements IteratorAggregate
|
|||||||
$subdef->setAttribute('name', $name);
|
$subdef->setAttribute('name', $name);
|
||||||
|
|
||||||
$dom_xp = $this->databox->get_xpath_structure();
|
$dom_xp = $this->databox->get_xpath_structure();
|
||||||
$query = '//record/subdefs/subdefgroup[@name="' . $group . '"]';
|
$query = '//record/subdefs/subdefgroup[@name="' . $groupname . '"]';
|
||||||
$groups = $dom_xp->query($query);
|
$groups = $dom_xp->query($query);
|
||||||
|
|
||||||
if ($groups->length == 0)
|
if ($groups->length == 0)
|
||||||
{
|
{
|
||||||
$group = $dom_struct->createElement('subdefgroup');
|
$group = $dom_struct->createElement('subdefgroup');
|
||||||
$group->setAttribute('name', $group);
|
$group->setAttribute('name', $groupname);
|
||||||
$dom_xp->query('/record/subdefs')->item(0)->appendChild($group);
|
$dom_xp->query('/record/subdefs')->item(0)->appendChild($group);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -42,22 +42,247 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
/**
|
/**
|
||||||
* Default route test
|
* Default route test
|
||||||
*/
|
*/
|
||||||
public function testRouteSlash()
|
public function testRouteDescription()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
|
||||||
|
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
$databox = array_shift($appbox->get_databoxes());
|
$databox = array_shift($appbox->get_databoxes());
|
||||||
$fields = $databox->get_meta_structure();
|
$name = "testtest" . uniqid();
|
||||||
|
$field = \databox_field::create($databox, $name);
|
||||||
|
$id = $field->get_id();
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'field_ids' => array($id)
|
||||||
|
, 'name_' . $id => $name
|
||||||
|
, 'multi_' . $id => 1
|
||||||
|
, 'indexable_' . $id => 1
|
||||||
|
, 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories'
|
||||||
|
, 'required_' . $id => 0
|
||||||
|
, 'readonly_' . $id => 0
|
||||||
|
, 'type_' . $id => 'string'
|
||||||
|
, 'vocabulary_' . $id => 'User'
|
||||||
|
, 'regname' => $id
|
||||||
|
, 'regdate' => $id
|
||||||
|
, 'regdesc' => $id
|
||||||
|
));
|
||||||
|
|
||||||
$fieldIds = array();
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
|
$field->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPostDelete()
|
||||||
|
{
|
||||||
|
$appbox = appbox::get_instance();
|
||||||
|
$databox = array_shift($appbox->get_databoxes());
|
||||||
|
$name = "test" . uniqid();
|
||||||
|
$field = \databox_field::create($databox, $name);
|
||||||
|
$id = $field->get_id();
|
||||||
|
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'todelete_ids' => array($id)
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$field = \databox_field::get_instance($databox, $id);
|
||||||
|
$field->delete();
|
||||||
|
$this->fail("should raise an exception");
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPostCreate()
|
||||||
|
{
|
||||||
|
$appbox = appbox::get_instance();
|
||||||
|
$databox = array_shift($appbox->get_databoxes());
|
||||||
|
|
||||||
|
$name = 'test' . uniqid();
|
||||||
|
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'newfield' => $name
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
|
|
||||||
|
$fields = $databox->get_meta_structure();
|
||||||
|
$find = false;
|
||||||
|
|
||||||
foreach ($fields as $field)
|
foreach ($fields as $field)
|
||||||
{
|
{
|
||||||
$fieldIds[] = $field->get_id();
|
if ($field->get_name() === databox_field::generateName($name))
|
||||||
|
{
|
||||||
|
$field->delete();
|
||||||
|
$find = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->client->request("POST", "/description/" . $databox->get_sbas_id());
|
if (!$find)
|
||||||
|
{
|
||||||
|
$this->fail("should have create a new field");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPostDescriptionException()
|
||||||
|
{
|
||||||
|
$appbox = appbox::get_instance();
|
||||||
|
$databox = array_shift($appbox->get_databoxes());
|
||||||
|
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'todelete_ids' => array('unknow_id')
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
|
|
||||||
|
$name = "test" . uniqid();
|
||||||
|
$field = \databox_field::create($databox, $name);
|
||||||
|
$id = $field->get_id();
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'field_ids' => array($id)
|
||||||
|
, 'name_' . $id => $name
|
||||||
|
, 'multi_' . $id => 1
|
||||||
|
, 'indexable_' . $id => 1
|
||||||
|
, 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories'
|
||||||
|
, 'required_' . $id => 0
|
||||||
|
, 'readonly_' . $id => 0
|
||||||
|
, 'type_' . $id => 'string'
|
||||||
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
|
, 'regname' => $id
|
||||||
|
, 'regdate' => $id
|
||||||
|
, 'regdesc' => $id
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
|
$field->delete();
|
||||||
|
|
||||||
|
$name = "test" . uniqid();
|
||||||
|
$field = \databox_field::create($databox, $name);
|
||||||
|
$id = $field->get_id();
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'field_ids' => array($id)
|
||||||
|
, 'multi_' . $id => 1
|
||||||
|
, 'indexable_' . $id => 1
|
||||||
|
, 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories'
|
||||||
|
, 'required_' . $id => 0
|
||||||
|
, 'readonly_' . $id => 0
|
||||||
|
, 'type_' . $id => 'string'
|
||||||
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
|
, 'regname' => $id
|
||||||
|
, 'regdate' => $id
|
||||||
|
, 'regdesc' => $id
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
|
$field->delete();
|
||||||
|
|
||||||
|
$name = "test" . uniqid();
|
||||||
|
$field = \databox_field::create($databox, $name);
|
||||||
|
$field->set_multi(false);
|
||||||
|
$field->set_indexable(false);
|
||||||
|
$field->set_required(true);
|
||||||
|
$field->set_readonly(true);
|
||||||
|
$id = $field->get_id();
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'field_ids' => array($id)
|
||||||
|
, 'name_' . $id => $name
|
||||||
|
, 'multi_' . $id => 1
|
||||||
|
, 'indexable_' . $id => 1
|
||||||
|
, 'src_' . $id => 'unknow_Source'
|
||||||
|
, 'required_' . $id => 0
|
||||||
|
, 'readonly_' . $id => 0
|
||||||
|
, 'type_' . $id => 'string'
|
||||||
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
|
, 'regname' => $id
|
||||||
|
, 'regdate' => $id
|
||||||
|
, 'regdesc' => $id
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
|
$this->assertTrue($field->is_readonly());
|
||||||
|
$this->assertTrue($field->is_required());
|
||||||
|
$this->assertFalse($field->is_multi());
|
||||||
|
$this->assertFalse($field->is_indexable());
|
||||||
|
$field->delete();
|
||||||
|
|
||||||
|
|
||||||
|
$name = "test" . uniqid();
|
||||||
|
$field = \databox_field::create($databox, $name);
|
||||||
|
$id = $field->get_id();
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'field_ids' => array('unknow_id')
|
||||||
|
, 'name_' . $id => $name
|
||||||
|
, 'multi_' . $id => 1
|
||||||
|
, 'indexable_' . $id => 1
|
||||||
|
, 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories'
|
||||||
|
, 'required_' . $id => 0
|
||||||
|
, 'readonly_' . $id => 0
|
||||||
|
, 'type_' . $id => 'string'
|
||||||
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
|
, 'regname' => $id
|
||||||
|
, 'regdate' => $id
|
||||||
|
, 'regdesc' => $id
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
|
$field->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPostDescriptionRights()
|
||||||
|
{
|
||||||
|
$appbox = appbox::get_instance();
|
||||||
|
|
||||||
|
$session = $appbox->get_session();
|
||||||
|
$auth = new Session_Authentication_None(self::$user_alt1);
|
||||||
|
$session->authenticate($auth);
|
||||||
|
|
||||||
|
$databox = array_shift($appbox->get_databoxes());
|
||||||
|
$name = "test" . uniqid();
|
||||||
|
$field = \databox_field::create($databox, $name);
|
||||||
|
$id = $field->get_id();
|
||||||
|
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||||
|
'field_ids' => array($id)
|
||||||
|
, 'name_' . $id => $name
|
||||||
|
, 'multi_' . $id => 1
|
||||||
|
, 'indexable_' . $id => 1
|
||||||
|
, 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories'
|
||||||
|
, 'required_' . $id => 0
|
||||||
|
, 'readonly_' . $id => 0
|
||||||
|
, 'type_' . $id => 'string'
|
||||||
|
, 'vocabulary_' . $id => 'User'
|
||||||
|
, 'regname' => $id
|
||||||
|
, 'regdate' => $id
|
||||||
|
, 'regdesc' => $id
|
||||||
|
));
|
||||||
|
$this->assertTrue($this->client->getResponse()->isOk());
|
||||||
|
$this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent());
|
||||||
|
$field->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetDescriptionException()
|
||||||
|
{
|
||||||
|
$appbox = appbox::get_instance();
|
||||||
|
|
||||||
|
$session = $appbox->get_session();
|
||||||
|
$auth = new Session_Authentication_None(self::$user_alt1);
|
||||||
|
$session->authenticate($auth);
|
||||||
|
|
||||||
|
$databox = array_shift($appbox->get_databoxes());
|
||||||
|
|
||||||
|
$this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/");
|
||||||
|
$this->assertTrue($this->client->getResponse()->isOk());
|
||||||
|
$this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetDescription()
|
||||||
|
{
|
||||||
|
$appbox = appbox::get_instance();
|
||||||
|
$databox = array_shift($appbox->get_databoxes());
|
||||||
|
|
||||||
|
$this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/");
|
||||||
|
$this->assertTrue($this->client->getResponse()->isOk());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -9,11 +9,11 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
|
|||||||
class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As controllers use WebTestCase, it requires a client
|
* As controllers use WebTestCase, it requires a client
|
||||||
*/
|
*/
|
||||||
protected $client;
|
protected $client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the controller tests require some records, specify it her
|
* If the controller tests require some records, specify it her
|
||||||
*
|
*
|
||||||
@@ -42,11 +42,77 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
/**
|
/**
|
||||||
* Default route test
|
* Default route test
|
||||||
*/
|
*/
|
||||||
public function testRouteSlash()
|
public function testRouteGetSubdef()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete(
|
$appbox = appbox::get_instance();
|
||||||
'This test has not been implemented yet.'
|
$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