Merge branch '3.6' of github.com:alchemy-fr/Phraseanet into 3.6

This commit is contained in:
Romain Neutron
2012-01-18 14:24:57 +01:00
45 changed files with 964 additions and 471 deletions

View File

@@ -54,7 +54,6 @@ try
$app->add(new module_console_aboutLicense('about:license')); $app->add(new module_console_aboutLicense('about:license'));
$app->add(new module_console_systemUpgrade('system:upgrade')); $app->add(new module_console_systemUpgrade('system:upgrade'));
$app->add(new module_console_systemMailCheck('system:mailCheck')); $app->add(new module_console_systemMailCheck('system:mailCheck'));
$app->add(new module_console_systemConfigCheck('system:configCheck'));
$app->add(new module_console_systemBackupDB('system:backupDB')); $app->add(new module_console_systemBackupDB('system:backupDB'));
$app->add(new module_console_systemClearCache('system:clearCache')); $app->add(new module_console_systemClearCache('system:clearCache'));
$app->add(new module_console_systemTemplateGenerator('system:templateGenerator')); $app->add(new module_console_systemTemplateGenerator('system:templateGenerator'));
@@ -64,6 +63,7 @@ try
$app->add(new module_console_schedulerStop('scheduler:stop')); $app->add(new module_console_schedulerStop('scheduler:stop'));
$app->add(new module_console_schedulerStart('scheduler:start')); $app->add(new module_console_schedulerStart('scheduler:start'));
$app->add(new module_console_fileConfigCheck('check:config')); $app->add(new module_console_fileConfigCheck('check:config'));
$app->add(new module_console_systemConfigCheck('check:system'));
$app->run(); $app->run();
} }
catch (Exception $e) catch (Exception $e)

View File

@@ -324,6 +324,7 @@ class Bridge implements ControllerProviderInterface
, 'element_type' => $element_type , 'element_type' => $element_type
, 'action' => $action , 'action' => $action
, 'elements' => $elements , 'elements' => $elements
, 'adapter_action' => $action
, 'error_message' => _('Request contains invalid datas') , 'error_message' => _('Request contains invalid datas')
, 'constraint_errors' => $errors , 'constraint_errors' => $errors
, 'notice_message' => $app['request']->get('notice') , 'notice_message' => $app['request']->get('notice')
@@ -350,9 +351,9 @@ class Bridge implements ControllerProviderInterface
break; break;
case 'createcontainer': case 'createcontainer':
try try
{ {
$container_type = $request->get('f_container_type'); $container_type = $request->get('f_container_type');
$account->get_api()->create_container($container_type, $app['request']); $account->get_api()->create_container($container_type, $app['request']);
@@ -417,6 +418,7 @@ class Bridge implements ControllerProviderInterface
$app['require_connection']($account); $app['require_connection']($account);
$route = new RecordHelper\Bridge($app['Core'], $app['request']); $route = new RecordHelper\Bridge($app['Core'], $app['request']);
$route->grep_records($account->get_api()->acceptable_records()); $route->grep_records($account->get_api()->acceptable_records());
$params = array( $params = array(
@@ -424,6 +426,7 @@ class Bridge implements ControllerProviderInterface
, 'account' => $account , 'account' => $account
, 'error_message' => $app['request']->get('error') , 'error_message' => $app['request']->get('error')
, 'notice_message' => $app['request']->get('notice') , 'notice_message' => $app['request']->get('notice')
, 'adapter_action' => 'upload'
); );
$html = $twig->render( $html = $twig->render(
@@ -450,14 +453,12 @@ class Bridge implements ControllerProviderInterface
/** /**
* check constraints * check constraints
*/ */
$errors = array();
foreach ($route->get_elements() as $record) foreach ($route->get_elements() as $record)
{ {
$datas = $connector->get_upload_datas($request, $record); $datas = $connector->get_upload_datas($request, $record);
$errors = array_merge($errors, $connector->check_upload_constraints($datas, $record)); $errors = array_merge($errors, $connector->check_upload_constraints($datas, $record));
} }
if (count($errors) > 0) if (count($errors) > 0)
{ {
@@ -467,6 +468,7 @@ class Bridge implements ControllerProviderInterface
, 'error_message' => _('Request contains invalid datas') , 'error_message' => _('Request contains invalid datas')
, 'constraint_errors' => $errors , 'constraint_errors' => $errors
, 'notice_message' => $app['request']->get('notice') , 'notice_message' => $app['request']->get('notice')
, 'adapter_action' => 'upload'
); );
$html = $twig->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.twig', $params); $html = $twig->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.twig', $params);

View File

@@ -15,6 +15,8 @@ use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Silex\ControllerCollection; use Silex\ControllerCollection;
use Alchemy\Phrasea\Helper\Record as RecordHelper; use Alchemy\Phrasea\Helper\Record as RecordHelper;
use Symfony\Component\HttpFoundation\Request,
Symfony\Component\HttpFoundation\Response;
/** /**
* *
@@ -29,9 +31,9 @@ class Edit implements ControllerProviderInterface
{ {
$controllers = new ControllerCollection(); $controllers = new ControllerCollection();
$controllers->post('/', function(Application $app) $controllers->post('/', function(Application $app, Request $request)
{ {
$handler = new RecordHelper\Edit($app['Core'], $app['request']); $handler = new RecordHelper\Edit($app['Core'], $request);
$handler->propose_editing(); $handler->propose_editing();
@@ -44,9 +46,8 @@ class Edit implements ControllerProviderInterface
} }
); );
$controllers->post('/apply/', function(Application $app) $controllers->post('/apply/', function(Application $app, Request $request)
{ {
$request = $app['request'];
$editing = new RecordHelper\Edit($app['Core'], $app['request']); $editing = new RecordHelper\Edit($app['Core'], $app['request']);
$editing->execute($request); $editing->execute($request);

View File

@@ -39,12 +39,12 @@ class Feed implements ControllerProviderInterface
/** /**
* I got a selection of docs, which publications are available forthese docs ? * I got a selection of docs, which publications are available forthese docs ?
*/ */
$controllers->post('/requestavailable/', function(Application $app) use ($appbox, $twig) $controllers->post('/requestavailable/', function(Application $app, Request $request) use ($appbox, $twig)
{ {
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = $app["Core"]->getAuthenticatedUser();
$feeds = \Feed_Collection::load_all($appbox, $user); $feeds = \Feed_Collection::load_all($appbox, $user);
$request = $app['request']; $request = $app['request'];
$publishing = new RecordHelper\Feed($app['Core'], $app['request']); $publishing = new RecordHelper\Feed($app['Core'], $request);
$datas = $twig->render('prod/actions/publish/publish.html', array('publishing' => $publishing, 'feeds' => $feeds)); $datas = $twig->render('prod/actions/publish/publish.html', array('publishing' => $publishing, 'feeds' => $feeds));
@@ -55,13 +55,11 @@ class Feed implements ControllerProviderInterface
/** /**
* I've selected a publication for my ocs, let's publish them * I've selected a publication for my ocs, let's publish them
*/ */
$controllers->post('/entry/create/', function(Application $app) use ($appbox, $twig) $controllers->post('/entry/create/', function(Application $app, Request $request) use ($appbox, $twig)
{ {
try try
{ {
$request = $app['request']; $user = $app["Core"]->getAuthenticatedUser();
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$feed = new \Feed_Adapter($appbox, $request->get('feed_id')); $feed = new \Feed_Adapter($appbox, $request->get('feed_id'));
$publisher = \Feed_Publisher_Adapter::getPublisher($appbox, $feed, $user); $publisher = \Feed_Publisher_Adapter::getPublisher($appbox, $feed, $user);
@@ -89,12 +87,10 @@ class Feed implements ControllerProviderInterface
}); });
$controllers->get('/entry/{id}/edit/', function($id) use ($app, $appbox, $twig) $controllers->get('/entry/{id}/edit/', function(Application $app, Request $request, $id) use ($appbox, $twig)
{ {
$request = $app['request']; $user = $app["Core"]->getAuthenticatedUser();
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id); $entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
@@ -102,8 +98,8 @@ class Feed implements ControllerProviderInterface
{ {
throw new \Exception_UnauthorizedAction(); throw new \Exception_UnauthorizedAction();
} }
$feeds = \Feed_Collection::load_all($appbox, $user);
$feeds = \Feed_Collection::load_all($appbox, $user);
$datas = $twig->render('prod/actions/publish/publish_edit.html', array('entry' => $entry, 'feeds' => $feeds)); $datas = $twig->render('prod/actions/publish/publish_edit.html', array('entry' => $entry, 'feeds' => $feeds));
@@ -111,15 +107,14 @@ class Feed implements ControllerProviderInterface
}); });
$controllers->post('/entry/{id}/update/', function($id) use ($app, $appbox, $twig) $controllers->post('/entry/{id}/update/', function(Application $app, Request $request, $id) use ($appbox, $twig)
{ {
$datas = array('error' => true, 'message' => '', 'datas' => ''); $datas = array('error' => true, 'message' => '', 'datas' => '');
try try
{ {
$appbox->get_connection()->beginTransaction(); $appbox->get_connection()->beginTransaction();
$request = $app['request'];
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = $app["Core"]->getAuthenticatedUser();
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id); $entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
@@ -139,13 +134,17 @@ class Feed implements ControllerProviderInterface
->set_subtitle($subtitle); ->set_subtitle($subtitle);
$items = explode(';', $request->get('sorted_lst')); $items = explode(';', $request->get('sorted_lst'));
foreach ($items as $item_sort) foreach ($items as $item_sort)
{ {
$item_sort_datas = explode('_', $item_sort); $item_sort_datas = explode('_', $item_sort);
if (count($item_sort_datas) != 2) if (count($item_sort_datas) != 2)
{
continue; continue;
}
$item = new \Feed_Entry_Item($appbox, $entry, $item_sort_datas[0]); $item = new \Feed_Entry_Item($appbox, $entry, $item_sort_datas[0]);
$item->set_ord($item_sort_datas[1]); $item->set_ord($item_sort_datas[1]);
} }
$appbox->get_connection()->commit(); $appbox->get_connection()->commit();
@@ -159,7 +158,7 @@ class Feed implements ControllerProviderInterface
$appbox->get_connection()->rollBack(); $appbox->get_connection()->rollBack();
$datas['message'] = _('Feed entry not found'); $datas['message'] = _('Feed entry not found');
} }
catch (Exception $e) catch (\Exception $e)
{ {
$appbox->get_connection()->rollBack(); $appbox->get_connection()->rollBack();
$datas['message'] = $e->getMessage(); $datas['message'] = $e->getMessage();
@@ -169,15 +168,14 @@ class Feed implements ControllerProviderInterface
}); });
$controllers->post('/entry/{id}/delete/', function($id) use ($app, $appbox, $twig) $controllers->post('/entry/{id}/delete/', function(Application $app, Request $request, $id) use ($appbox, $twig)
{ {
$datas = array('error' => true, 'message' => ''); $datas = array('error' => true, 'message' => '');
try try
{ {
$appbox->get_connection()->beginTransaction(); $appbox->get_connection()->beginTransaction();
$request = $app['request'];
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = $app["Core"]->getAuthenticatedUser();
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id); $entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
@@ -225,13 +223,14 @@ class Feed implements ControllerProviderInterface
// //
// }); // });
$controllers->get('/', function() use ($app, $appbox, $twig) $controllers->get('/', function(Application $app, Request $request) use ($appbox, $twig)
{ {
$request = $app['request']; $request = $app['request'];
$page = (int) $request->get('page'); $page = (int) $request->get('page');
$page = $page > 0 ? $page : 1; $page = $page > 0 ? $page : 1;
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = $app["Core"]->getAuthenticatedUser();
$feeds = \Feed_Collection::load_all($appbox, $user); $feeds = \Feed_Collection::load_all($appbox, $user);
$datas = $twig->render('prod/feeds/feeds.html' $datas = $twig->render('prod/feeds/feeds.html'
@@ -246,14 +245,12 @@ class Feed implements ControllerProviderInterface
}); });
$controllers->get('/feed/{id}/', function($id) use ($app, $appbox, $twig) $controllers->get('/feed/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig)
{ {
$request = $app['request'];
$page = (int) $request->get('page'); $page = (int) $request->get('page');
$page = $page > 0 ? $page : 1; $page = $page > 0 ? $page : 1;
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = $app["Core"]->getAuthenticatedUser();
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id); $feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
$feeds = \Feed_Collection::load_all($appbox, $user); $feeds = \Feed_Collection::load_all($appbox, $user);
@@ -264,14 +261,12 @@ class Feed implements ControllerProviderInterface
}); });
$controllers->get('/subscribe/aggregated/', function() use ($app, $appbox, $twig) $controllers->get('/subscribe/aggregated/', function(Application $app, Request $request) use ( $appbox, $twig)
{ {
$request = $app['request'];
$renew = ($request->get('renew') === 'true'); $renew = ($request->get('renew') === 'true');
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = $app["Core"]->getAuthenticatedUser();
$feeds = \Feed_Collection::load_all($appbox, $user); $feeds = \Feed_Collection::load_all($appbox, $user);
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
@@ -289,13 +284,10 @@ class Feed implements ControllerProviderInterface
}); });
$controllers->get('/subscribe/{id}/', function($id) use ($app, $appbox, $twig) $controllers->get('/subscribe/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig)
{ {
$request = $app['request'];
$renew = ($request->get('renew') === 'true'); $renew = ($request->get('renew') === 'true');
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = $app["Core"]->getAuthenticatedUser();
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id); $feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();

View File

@@ -31,7 +31,7 @@ class MoveCollection implements ControllerProviderInterface
{ {
$controllers = new ControllerCollection(); $controllers = new ControllerCollection();
$controllers->post('/', function(Application $app) $controllers->post('/', function(Application $app, Request $request)
{ {
$request = $app['request']; $request = $app['request'];
$move = new RecordHelper\MoveCollection($app['Core'], $app['request']); $move = new RecordHelper\MoveCollection($app['Core'], $app['request']);

View File

@@ -102,10 +102,16 @@ class Tooltip implements ControllerProviderInterface
$record = new \record_adapter($sbas_id, $record_id, $number); $record = new \record_adapter($sbas_id, $record_id, $number);
$search_engine = null; $search_engine = null;
if (($search_engine_options = unserialize($app['request']->get('options_serial'))) !== false) $option = new \searchEngine_options();
$options_serial = $app['request']->get('options_serial');
if ($options_serial)
{ {
$search_engine = new \searchEngine_adapter($app['appbox']->get_registry()); if (($search_engine_options = $option->unserialize($app['request']->get('options_serial'))) !== false)
$search_engine->set_options($search_engine_options); {
$search_engine = new \searchEngine_adapter($app['appbox']->get_registry());
$search_engine->set_options($search_engine_options);
}
} }
/* @var $twig \Twig_Environment */ /* @var $twig \Twig_Environment */
@@ -164,25 +170,18 @@ class Tooltip implements ControllerProviderInterface
$controllers->post('/metas/DCESInfos/{sbas_id}/{field_id}/' $controllers->post('/metas/DCESInfos/{sbas_id}/{field_id}/'
, function(Application $app, $sbas_id, $field_id) , function(Application $app, $sbas_id, $field_id)
{ {
try $databox = \databox::get_instance((int) $sbas_id);
{ $field = \databox_field::get_instance($databox, $field_id);
$databox = \databox::get_instance((int) $sbas_id);
$field = \databox_field::get_instance($databox, $field_id);
/* @var $twig \Twig_Environment */ /* @var $twig \Twig_Environment */
$twig = $app['Core']->getTwig(); $twig = $app['Core']->getTwig();
return new Response( return new Response(
$twig->render( $twig->render(
'common/databox_field_DCES.twig' 'common/databox_field_DCES.twig'
, array('field' => $field) , array('field' => $field)
) )
); );
}
catch (\Exception $e)
{
exit($e->getMessage());
}
})->assert('sbas_id', '\d+')->assert('field_id', '\d+'); })->assert('sbas_id', '\d+')->assert('field_id', '\d+');

View File

@@ -313,7 +313,6 @@ class Installer implements ControllerProviderInterface
catch (\Exception $e) catch (\Exception $e)
{ {
\setup::rollback($conn, $connbas); \setup::rollback($conn, $connbas);
exit($e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine());
} }
return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage())); return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage()));

View File

@@ -96,7 +96,7 @@ class ConnectionTest implements ControllerProviderInterface
, 'is_empty' => $empty , 'is_empty' => $empty
, 'is_appbox' => $is_appbox , 'is_appbox' => $is_appbox
, 'is_databox' => $is_databox , 'is_databox' => $is_databox
)), 200, array('application/json')); )), 200, array('content-type' => 'application/json'));
}); });
return $controllers; return $controllers;

View File

@@ -450,7 +450,7 @@ class Edit extends RecordHelper
* @param http_request $request * @param http_request $request
* @return action_edit * @return action_edit
*/ */
public function execute(Symfony\Component\HttpFoundation\Request $request) public function execute(Request $request)
{ {
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance();
if ($request->get('act_option') == 'SAVEGRP' && $request->get('newrepresent')) if ($request->get('act_option') == 'SAVEGRP' && $request->get('newrepresent'))

View File

@@ -11,7 +11,8 @@
namespace Alchemy\Phrasea\Helper\Record; namespace Alchemy\Phrasea\Helper\Record;
use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper; use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper,
Alchemy\Phrasea\Core;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
/** /**

View File

@@ -100,10 +100,18 @@ class MoveCollection extends RecordHelper
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance();
$user = $this->getCore()->getAuthenticatedUser(); $user = $this->getCore()->getAuthenticatedUser();
$baseId = $request->get('base_id');
$base_dest = $base_dest =
$user->ACL()->has_right_on_base($request->get('base_id'), 'canaddrecord') ? $user->ACL()->has_right_on_base($baseId, 'canaddrecord') ?
$request->get('base_id') : false; $request->get('base_id') : false;
if(!$user->ACL()->has_right_on_base($baseId, 'canaddrecord'))
{
throw new \Exception_Unauthorized(sprintf("%s do not have the permission to move records to %s", $user->get_login()));
}
if (!$this->is_possible()) if (!$this->is_possible())
throw new Exception('This action is not possible'); throw new Exception('This action is not possible');
@@ -122,7 +130,8 @@ class MoveCollection extends RecordHelper
} }
} }
} }
$collection = \collection::get_from_base_id($base_dest); $collection = \collection::get_from_base_id($base_dest);
foreach ($this->selection as $record) foreach ($this->selection as $record)

View File

@@ -65,7 +65,7 @@ class collection implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$connbas = $this->databox->get_connection(); $connbas = $this->databox->get_connection();
@@ -200,9 +200,9 @@ class collection implements cache_cacheableInterface
$stmt = $this->get_connection()->prepare($sql); $stmt = $this->get_connection()->prepare($sql);
$stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id())); $stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$this->pub_wm = $publi; $this->pub_wm = $publi;
$this->delete_data_from_cache(); $this->delete_data_from_cache();
} }
@@ -223,9 +223,9 @@ class collection implements cache_cacheableInterface
$stmt->closeCursor(); $stmt->closeCursor();
$this->name = $name; $this->name = $name;
$this->delete_data_from_cache(); $this->delete_data_from_cache();
phrasea::reset_baseDatas(); phrasea::reset_baseDatas();
return $this; return $this;
@@ -304,7 +304,7 @@ class collection implements cache_cacheableInterface
public function delete() public function delete()
{ {
while($this->get_record_amount() > 0) while ($this->get_record_amount() > 0)
{ {
$this->empty_collection(); $this->empty_collection();
} }
@@ -350,8 +350,10 @@ class collection implements cache_cacheableInterface
{ {
$coll_id = phrasea::collFromBas($base_id); $coll_id = phrasea::collFromBas($base_id);
$sbas_id = phrasea::sbasFromBas($base_id); $sbas_id = phrasea::sbasFromBas($base_id);
if(!$sbas_id || !$coll_id) if (!$sbas_id || !$coll_id)
throw new Exception_Databox_CollectionNotFound(); {
throw new Exception_Databox_CollectionNotFound(sprintf("Collection could not be found"));
}
$databox = databox::get_instance($sbas_id); $databox = databox::get_instance($sbas_id);
return self::get_from_coll_id($databox, $coll_id); return self::get_from_coll_id($databox, $coll_id);
@@ -404,7 +406,7 @@ class collection implements cache_cacheableInterface
$stmt = $this->get_connection()->prepare($sql); $stmt = $this->get_connection()->prepare($sql);
$stmt->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id())); $stmt->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$this->delete_data_from_cache(); $this->delete_data_from_cache();
return $this->prefs; return $this->prefs;

View File

@@ -77,19 +77,20 @@ class setup
$appConf->getServiceFile(); $appConf->getServiceFile();
$installed = true; $installed = true;
} }
catch(\Exception $e) catch (\Exception $e)
{ {
} }
return $installed; return $installed;
} }
public static function needUpgradeConfigurationFile() public static function needUpgradeConfigurationFile()
{ {
return (is_file(__DIR__ . "/../../config/connexion.inc") return (is_file(__DIR__ . "/../../config/connexion.inc")
&& is_file(__DIR__ . "/../../config/config.inc")); && is_file(__DIR__ . "/../../config/config.inc"));
} }
function create_global_values(registryInterface &$registry, $datas=array()) function create_global_values(registryInterface &$registry, $datas = array())
{ {
require(__DIR__ . "/../../lib/conf.d/_GV_template.inc"); require(__DIR__ . "/../../lib/conf.d/_GV_template.inc");
@@ -761,12 +762,14 @@ class setup
return $current; return $current;
} }
public static function rollback(connection_pdo $conn, connection_pdo $connbas =null) public static function rollback(connection_pdo $conn, connection_pdo $connbas = null)
{ {
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml"); $structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
if (!$structure) if (!$structure)
{
throw new Exception('Unable to load schema'); throw new Exception('Unable to load schema');
}
$appbox = $structure->appbox; $appbox = $structure->appbox;
$databox = $structure->databox; $databox = $structure->databox;
@@ -803,9 +806,10 @@ class setup
} }
} }
$appConf = new \Alchemy\Phrasea\Core\Configuration\Application();
try try
{ {
$appConf = new \Alchemy\Phrasea\Core\Configuration\Application();
$configFile = $appConf->getConfigurationFile(); $configFile = $appConf->getConfigurationFile();
unlink($configFile->getPathname()); unlink($configFile->getPathname());
} }
@@ -813,7 +817,27 @@ class setup
{ {
} }
try
{
$serviceFile = $appConf->getServiceFile();
unlink($serviceFile->getPathname());
}
catch (\Exception $e)
{
}
try
{
$connexionfFile = $appConf->getConnexionFile();
unlink($connexionfFile->getPathname());
}
catch (\Exception $e)
{
}
return; return;
} }

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Admin;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Admin/Fields.php';
/** /**
* Test class for Fields. * Test class for Fields.
* Generated by PHPUnit on 2012-01-11 at 18:25:03. * Generated by PHPUnit on 2012-01-11 at 18:25:03.

View File

@@ -2,8 +2,6 @@
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Admin/Publications.php';
use Silex\WebTestCase; use Silex\WebTestCase;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Admin;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Admin/Subdefs.php';
/** /**
* Test class for Subdefs. * Test class for Subdefs.
* Generated by PHPUnit on 2012-01-11 at 18:25:04. * Generated by PHPUnit on 2012-01-11 at 18:25:04.

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Admin;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Admin/Users.php';
/** /**
* Test class for Users. * Test class for Users.
* Generated by PHPUnit on 2012-01-11 at 18:25:04. * Generated by PHPUnit on 2012-01-11 at 18:25:04.

View File

@@ -11,8 +11,6 @@
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/Basket.php';
use Alchemy\Phrasea\Helper; use Alchemy\Phrasea\Helper;
use Alchemy\Phrasea\RouteProcessor as routeProcessor; use Alchemy\Phrasea\RouteProcessor as routeProcessor;

View File

@@ -12,6 +12,7 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
public static $account = null; public static $account = null;
public static $api = null; public static $api = null;
protected $client; protected $client;
protected static $need_records = 1;
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
@@ -83,6 +84,14 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue($this->client->getResponse()->isRedirect($test->get_auth_url())); $this->assertTrue($this->client->getResponse()->isRedirect($test->get_auth_url()));
} }
public function testCallBackFailed()
{
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$crawler = $this->client->request('GET', '/bridge/callback/unknow_api/');
$this->assertTrue($this->client->getResponse()->isOk());
}
public function testCallBackAccountAlreadyDefined() public function testCallBackAccountAlreadyDefined()
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
@@ -253,6 +262,16 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
{ {
} }
try
{
$crawler = $this->client->request('POST', $url, array("elements_list" => "1;2;3"));
$this->fail("expected Exception here");
}
catch (Exception $e)
{
}
} }
public function testActionModifyTooManyElements() public function testActionModifyTooManyElements()
@@ -265,6 +284,9 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertContains($redirect, $this->client->getResponse()->headers->get("location")); $this->assertContains($redirect, $this->client->getResponse()->headers->get("location"));
$this->assertContains("error=", $this->client->getResponse()->headers->get("location")); $this->assertContains("error=", $this->client->getResponse()->headers->get("location"));
$this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
$this->client->request('POST', $url, array("element_list" => "1_2;1_3;1_4"));
$this->assertTrue($this->client->getResponse()->isRedirect());
} }
public function testActionModifyElement() public function testActionModifyElement()
@@ -274,6 +296,67 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
$crawler = $this->client->request('GET', $url, array("elements_list" => "element123qcs789")); $crawler = $this->client->request('GET', $url, array("elements_list" => "element123qcs789"));
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
$this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
$this->assertTrue($this->client->getResponse()->isRedirect());
}
public function testActionModifyElementError()
{
self::$account->get_settings()->set("auth_token", "somethingNotNull");
Bridge_Api_Apitest::$hasError = true;
$url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
$this->assertTrue($this->client->getResponse()->isOk());
}
public function testActionModifyElementException()
{
self::$account->get_settings()->set("auth_token", "somethingNotNull");
Bridge_Api_Apitest::$hasException = true;
$url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
$this->assertTrue($this->client->getResponse()->isRedirect());
$this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
}
public function testActionDeleteElement()
{
self::$account->get_settings()->set("auth_token", "somethingNotNull");
$url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$this->client->request('GET', $url, array("elements_list" => "element123qcs789"));
$this->assertTrue($this->client->getResponse()->isOk());
Bridge_Api_Apitest::$hasException = true;
$url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
$this->assertTrue($this->client->getResponse()->isRedirect());
$this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
$url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
$this->assertTrue($this->client->getResponse()->isRedirect());
}
public function testActionCreateContainer()
{
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
$this->client->request('GET', $url);
$this->assertTrue($this->client->getResponse()->isOk());
Bridge_Api_Apitest::$hasException = true;
$url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$this->client->request('POST', $url);
$this->assertTrue($this->client->getResponse()->isRedirect());
$this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
$url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
$this->client->request('POST', $url, array('title' => 'test', 'description' => 'description'));
$this->assertTrue($this->client->getResponse()->isRedirect());
$this->assertRegexp('/success/', $this->client->getResponse()->headers->get('location'));
} }
/** /**
@@ -288,6 +371,9 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$pageContent = $this->client->getResponse()->getContent(); $pageContent = $this->client->getResponse()->getContent();
$this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
$this->client->request('POST', $url, array("elements_list" => "containerudt456shn"));
$this->assertTrue($this->client->getResponse()->isOk());
} }
public function testActionMoveInto() public function testActionMoveInto()
@@ -297,14 +383,45 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
$crawler = $this->client->request('GET', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type())); $crawler = $this->client->request('GET', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
$this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", $this->client->getResponse()->getContent()); $this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", $this->client->getResponse()->getContent());
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$this->client->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
$this->assertRegexp('/success/', $this->client->getResponse()->headers->get('location'));
$this->assertTrue($this->client->getResponse()->isRedirect());
Bridge_Api_Apitest::$hasException = true;
$this->client->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
$this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
$this->assertTrue($this->client->getResponse()->isRedirect());
} }
public function deconnected($crawler, $pageContent) public function deconnected($crawler, $pageContent)
{ {
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$this->assertContains("prod/bridge/login/" . mb_strtolower(self::$account->get_api()->get_connector()->get_name()) . "/", $pageContent);
}
$this->assertContains("prod/bridge/login/" . mb_strtolower(self::$account->get_api()->get_connector()->get_name())."/", $pageContent); public function testUpload()
{
self::$account->get_settings()->set("auth_token", "somethingNotNull");
$url = "/bridge/upload/";
$this->client->request('GET', $url, array("account_id" => self::$account->get_id()));
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
$records = array(
self::$record_1->get_serialize_key()
);
Bridge_Api_Apitest::$hasError = true;
$lst = implode(';', $records);
$this->client->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst));
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
$this->client->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst));
$response = $this->client->getResponse();
$this->assertTrue($response->isRedirect());
} }
} }

View File

@@ -1,7 +1,5 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/Edit.php'; require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/Edit.php';
@@ -17,6 +15,7 @@ class ControllerEditTest 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
* *
@@ -26,7 +25,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
* $need_records = 2; * $need_records = 2;
* *
*/ */
protected static $need_records = false; protected static $need_records = 1;
/** /**
* The application loader * The application loader
@@ -35,7 +34,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php'; return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php';
} }
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
@@ -52,9 +51,20 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testRouteSlash() public function testRouteSlash()
{ {
$this->markTestIncomplete( $this->client->request('POST', '/records/edit/', array('lst' => self::$record_1->get_serialize_key()));
'This test has not been implemented yet.'
); $response = $this->client->getResponse();
$this->assertTrue($response->isOk());
}
public function testApply()
{
$this->client->request('POST', '/records/edit/apply/', array('lst' => self::$record_1->get_serialize_key()));
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
} }
} }

View File

@@ -10,20 +10,37 @@ use Symfony\Component\HttpFoundation\Response;
class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
/**
*
* @var Feed_Adapter
*/
protected $feed; protected $feed;
/**
*
* @var Feed_Entry_Adapter
*/
protected $entry; protected $entry;
/**
*
* @var Feed_Entry_Item
*/
protected $item; protected $item;
/**
*
* @var Feed_Publisher_Adapter
*/
protected $publisher; protected $publisher;
protected $client; protected $client;
protected $feed_title = 'feed title'; protected $feed_title = 'feed title';
protected $feed_subtitle = 'feed subtitle'; protected $feed_subtitle = 'feed subtitle';
protected $entry_title = 'entry title'; protected $entry_title = 'entry title';
protected $entry_subtitle = 'entry subtitle'; protected $entry_subtitle = 'entry subtitle';
protected $entry_authorname = 'author name'; protected $entry_authorname = 'author name';
protected $entry_authormail = 'author.mail@example.com'; protected $entry_authormail = 'author.mail@example.com';
protected static $need_records = 2;
protected static $need_records = 1;
protected static $need_subdefs = false; protected static $need_subdefs = false;
public static function setUpBeforeClass() public static function setUpBeforeClass()
@@ -39,12 +56,19 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$this->client = $this->createClient(); $this->client = $this->createClient();
$this->feed = Feed_Adapter::create($appbox, self::$user, $this->feed_title, $this->feed_subtitle);
$this->feed = Feed_Adapter::create(
$appbox, self::$user, $this->feed_title, $this->feed_subtitle
);
$this->publisher = Feed_Publisher_Adapter::getPublisher(
$appbox, $this->feed, self::$user
);
$this->publisher = Feed_Publisher_Adapter::getPublisher($appbox, $this->feed, self::$user);
$this->entry = Feed_Entry_Adapter::create( $this->entry = Feed_Entry_Adapter::create(
$appbox $appbox
, $this->feed , $this->feed
@@ -54,6 +78,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
, $this->entry_authorname , $this->entry_authorname
, $this->entry_authormail , $this->entry_authormail
); );
$this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1); $this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1);
} }
@@ -84,232 +109,356 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
} }
} }
// public function testEntryCreate() public function testEntryCreate()
// { {
// $params = array( $params = array(
// "feed_id" => $this->feed->get_id() "feed_id" => $this->feed->get_id()
// , "title" => "salut" , "title" => "salut"
// , "subtitle" => "coucou" , "subtitle" => "coucou"
// , "author_name" => "robert" , "author_name" => "robert"
// , "author_email" => "robert@kikoo.mail" , "author_email" => "robert@kikoo.mail"
// , 'lst' => self::$record_1->get_serialize_key() , 'lst' => self::$record_1->get_serialize_key()
// ); );
//
// $crawler = $this->client->request('POST', '/entry/create/', $params); $crawler = $this->client->request('POST', '/feeds/entry/create/', $params);
// $this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
// $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
// $pageContent = json_decode($this->client->getResponse()->getContent()); $pageContent = json_decode($this->client->getResponse()->getContent());
// $this->assertTrue(is_object($pageContent)); $this->assertTrue(is_object($pageContent));
// $this->assertFalse($pageContent->error); $this->assertFalse($pageContent->error);
// $this->assertFalse($pageContent->message); $this->assertFalse($pageContent->message);
// } }
//
// public function testEntryEditFailed() public function testEntryCreateError()
// { {
// $params = array( $params = array(
// "feed_id" => 'unknow' "feed_id" => 'unknow'
// , "title" => "salut" , "title" => "salut"
// , "subtitle" => "coucou" , "subtitle" => "coucou"
// , "author_name" => "robert" , "author_name" => "robert"
// , "author_email" => "robert@kikoo.mail" , "author_email" => "robert@kikoo.mail"
// , 'lst' => self::$record_1->get_serialize_key() , 'lst' => self::$record_1->get_serialize_key()
// ); );
// $crawler = $this->client->request('POST', '/feeds/entry/create/', $params);
// $crawler = $this->client->request('POST', '/entry/create/', $params); $this->assertTrue($this->client->getResponse()->isOk());
// $this->assertTrue($this->client->getResponse()->isOk()); $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
// $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); $pageContent = json_decode($this->client->getResponse()->getContent());
// $pageContent = json_decode($this->client->getResponse()->getContent()); $this->assertTrue(is_object($pageContent));
// $this->assertTrue(is_object($pageContent)); $this->assertTrue($pageContent->error);
// $this->assertTrue($pageContent->error); $this->assertTrue(is_string($pageContent->message));
// $this->assertTrue(is_string($pageContent->message)); }
// }
// public function testEntryEdit()
// public function testEntryEdit() {
// { $appbox = appbox::get_instance();
// $appbox = appbox::get_instance();
// $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/edit/');
// $crawler = $this->client->request('GET', '/entry/' . $this->entry->get_id() . '/edit/'); $pageContent = $this->client->getResponse()->getContent();
// $pageContent = $this->client->getResponse()->getContent();
// foreach ($this->entry->get_content() as $content) foreach ($this->entry->get_content() as $content)
// $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $content->get_id() . "']")->count()); {
// $this->assertEquals(1, $crawler->filterXPath("//form[@action='/prod/feeds/entry/" . $this->entry->get_id() . "/update/']")->count()); $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $content->get_id() . "']")->count());
// $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_title . "']")->count()); }
// $this->assertEquals($this->entry_subtitle, $crawler->filterXPath("//textarea[@id='feed_add_subtitle']")->text());
// $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_authorname . "']")->count()); $this->assertEquals(1, $crawler->filterXPath("//form[@action='/prod/feeds/entry/" . $this->entry->get_id() . "/update/']")->count());
// $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_authormail . "']")->count()); $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_title . "']")->count());
// } $this->assertEquals($this->entry_subtitle, $crawler->filterXPath("//textarea[@id='feed_add_subtitle']")->text());
// $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_authorname . "']")->count());
// public function testEntryUpdate() $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_authormail . "']")->count());
// { }
// $appbox = appbox::get_instance();
// public function testEntryEditUnauthorized()
// $params = array( {
// "feed_id" => $this->feed->get_id() $appbox = appbox::get_instance();
// , "title" => "dog"
// , "subtitle" => "cat" $feed = Feed_Adapter::create(
// , "author_name" => "bird" $appbox, self::$user_alt1, $this->feed_title, $this->feed_subtitle
// , "author_email" => "mouse" );
// , 'lst' => self::$record_1->get_serialize_key()
// ); $publisher = Feed_Publisher_Adapter::getPublisher(
// $appbox, $feed, self::$user_alt1
// $crawler = $this->client->request('POST', '/entry/' . $this->entry->get_id() . '/update/', $params); );
// $this->assertTrue($this->client->getResponse()->isOk());
// $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); $entry = Feed_Entry_Adapter::create(
// $pageContent = json_decode($this->client->getResponse()->getContent()); $appbox
// $this->assertTrue(is_object($pageContent)); , $feed
// $this->assertFalse($pageContent->error); , $publisher
// $this->assertTrue(is_string($pageContent->message)); , $this->entry_title
// $this->assertTrue(is_string($pageContent->datas)); , $this->entry_subtitle
// $this->assertRegExp("/entry_" . $this->entry->get_id() . "/", $pageContent->datas); , $this->entry_authorname
// } , $this->entry_authormail
// );
// public function testEntryUpdateFailed()
// {
// $appbox = appbox::get_instance(); $crawler = $this->client->request('GET', '/feeds/entry/' . $entry->get_id() . '/edit/');
// /**
// * I CREATE A FEED THAT IS NOT MINE $response = $this->client->getResponse();
// * */
// $feed = Feed_Adapter::create($appbox, self::$user_alt1, "salut", 'coucou'); $this->assertFalse($response->isOk());
// $publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user_alt1);
// $entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, "hello", "coucou", "salut", "bonjour"); $feed->delete();
// $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1); }
//
// $params = array( public function testEntryUpdate()
// "feed_id" => $feed->get_id() {
// , "title" => "dog" $appbox = appbox::get_instance();
// , "subtitle" => "cat"
// , "author_name" => "bird" $params = array(
// , "author_email" => "mouse" "feed_id" => $this->feed->get_id()
// , 'lst' => self::$record_1->get_serialize_key() , "title" => "dog"
// ); , "subtitle" => "cat"
// , "author_name" => "bird"
// $crawler = $this->client->request('POST', '/entry/' . $entry->get_id() . '/update/', $params); , "author_email" => "mouse"
// $this->assertTrue($this->client->getResponse()->isOk()); , 'lst' => self::$record_1->get_serialize_key()
// $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); );
// $pageContent = json_decode($this->client->getResponse()->getContent());
// $this->assertTrue(is_object($pageContent)); $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params);
// $this->assertTrue($pageContent->error); $this->assertTrue($this->client->getResponse()->isOk());
// $this->assertTrue(is_string($pageContent->message)); $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
// $pageContent = json_decode($this->client->getResponse()->getContent());
// $feed->delete(); $this->assertTrue(is_object($pageContent));
// } $this->assertFalse($pageContent->error);
// $this->assertTrue(is_string($pageContent->message));
// public function testDelete() $this->assertTrue(is_string($pageContent->datas));
// { $this->assertRegExp("/entry_" . $this->entry->get_id() . "/", $pageContent->datas);
// $appbox = appbox::get_instance(); }
//
// $crawler = $this->client->request('POST', '/entry/' . $this->entry->get_id() . '/delete/'); public function testEntryUpdateNotFound()
// $this->assertTrue($this->client->getResponse()->isOk()); {
// $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); $appbox = appbox::get_instance();
// $pageContent = json_decode($this->client->getResponse()->getContent());
// $this->assertTrue(is_object($pageContent)); $params = array(
// $this->assertFalse($pageContent->error); "feed_id" => 9999999
// $this->assertTrue(is_string($pageContent->message)); , "title" => "dog"
// try , "subtitle" => "cat"
// { , "author_name" => "bird"
// Feed_Entry_Adapter::load_from_id($appbox, $this->entry->get_id()); , "author_email" => "mouse"
// $this->fail("Failed to delete entry"); , 'lst' => self::$record_1->get_serialize_key()
// } );
// catch (Exception $e)
// { $crawler = $this->client->request('POST', '/feeds/entry/UNKNOW/update/', $params);
//
// } $response = $this->client->getResponse();
// }
// $pageContent = json_decode($response->getContent());
// public function testDeleteFailed()
// { $this->assertTrue($response->isOk());
// $appbox = appbox::get_instance(); $this->assertEquals("application/json", $response->headers->get("content-type"));
// /** $this->assertTrue(is_object($pageContent));
// * I CREATE A FEED $this->assertTrue($pageContent->error);
// * */ $this->assertTrue(is_string($pageContent->message));
// $feed = Feed_Adapter::create($appbox, self::$user_alt1, "salut", 'coucou'); }
//
// $publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user_alt1); public function testEntryUpdateFailed()
// $entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, "hello", "coucou", "salut", "bonjour"); {
// $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1); $appbox = appbox::get_instance();
//
// $crawler = $this->client->request('POST', '/entry/' . $entry->get_id() . '/delete/'); $params = array(
// $this->assertTrue($this->client->getResponse()->isOk()); "feed_id" => 9999999
// $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); , "title" => "dog"
// $pageContent = json_decode($this->client->getResponse()->getContent()); , "subtitle" => "cat"
// $this->assertTrue(is_object($pageContent)); , "author_name" => "bird"
// $this->assertTrue($pageContent->error); , "author_email" => "mouse"
// $this->assertTrue(is_string($pageContent->message)); , 'sorted_lst' => self::$record_1->get_serialize_key() . ";" . self::$record_2->get_serialize_key() . ";12345;" . "unknow_unknow"
// );
// $feed->delete();
// } $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params);
//
// public function testRoot() $response = $this->client->getResponse();
// {
// $appbox = appbox::get_instance(); $this->assertTrue($response->isOk());
// $crawler = $this->client->request('GET', '/'); $pageContent = json_decode($response->getContent());
// $pageContent = $this->client->getResponse()->getContent();
// $this->assertTrue($this->client->getResponse()->isOk()); $this->assertEquals("application/json", $response->headers->get("content-type"));
// $feeds = Feed_Collection::load_all($appbox, self::$user); $this->assertTrue(is_object($pageContent));
// $this->assertTrue($pageContent->error);
// foreach ($feeds->get_feeds() as $one_feed) $this->assertTrue(is_string($pageContent->message));
// { }
// $path = "//div[@class='submenu']/a[@href='/prod/feeds/feed/" . $one_feed->get_id() . "/']";
// $msg = sprintf("user %s has access to feed %s", self::$user->get_id(), $one_feed->get_id()); public function testEntryUpdateUnauthorized()
// {
// if ($one_feed->has_access(self::$user)) $appbox = appbox::get_instance();
// { /**
// $this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg); * I CREATE A FEED THAT IS NOT MINE
// } * */
// else $feed = Feed_Adapter::create($appbox, self::$user_alt1, "salut", 'coucou');
// { $publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user_alt1);
// $this->fail('Feed_collection::load_all should return feed where I got access'); $entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, "hello", "coucou", "salut", "bonjour");
// } $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1);
// }
// } $params = array(
// "feed_id" => $feed->get_id()
// public function testGetFeed() , "title" => "dog"
// { , "subtitle" => "cat"
// $appbox = appbox::get_instance(); , "author_name" => "bird"
// , "author_email" => "mouse"
// $feeds = Feed_Collection::load_all($appbox, self::$user); , 'lst' => self::$record_1->get_serialize_key()
// );
// $crawler = $this->client->request('GET', '/feed/' . $this->feed->get_id() . "/");
// $pageContent = $this->client->getResponse()->getContent(); $crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/update/', $params);
// foreach ($feeds->get_feeds() as $one_feed)
// { $response = $this->client->getResponse();
// $path = "//div[@class='submenu']/a[@href='/prod/feeds/feed/" . $one_feed->get_id() . "/']";
// $msg = sprintf("user %s has access to feed %s", self::$user->get_id(), $one_feed->get_id()); $this->assertTrue($response->isOk());
// if ($one_feed->has_access(self::$user)) $pageContent = json_decode($response->getContent());
// {
// $this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg); $this->assertEquals("application/json", $response->headers->get("content-type"));
// } $this->assertTrue(is_object($pageContent));
// else $this->assertTrue($pageContent->error);
// { $this->assertTrue(is_string($pageContent->message));
// $this->fail('Feed_collection::load_all should return feed where I got access');
// } $feed->delete();
// } }
// }
// public function testDelete()
// public function testSuscribeAggregate() {
// { $appbox = appbox::get_instance();
// $appbox = appbox::get_instance();
// $feeds = Feed_Collection::load_all($appbox, self::$user); $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/delete/');
// $crawler = $this->client->request('GET', '/subscribe/aggregated/');
// $this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
// $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
// $pageContent = json_decode($this->client->getResponse()->getContent());
// $this->assertTrue(is_object($pageContent)); $pageContent = json_decode($this->client->getResponse()->getContent());
// $this->assertTrue(is_string($pageContent->texte));
// $suscribe_link = $feeds->get_aggregate()->get_user_link(registry::get_instance(), self::$user, Feed_Adapter::FORMAT_RSS, null, false)->get_href(); $this->assertTrue(is_object($pageContent));
// $this->assertContains($suscribe_link, $pageContent->texte); $this->assertFalse($pageContent->error);
// } $this->assertTrue(is_string($pageContent->message));
//
// public function testSuscribe() try
// { {
// $crawler = $this->client->request('GET', '/subscribe/' . $this->feed->get_id() . '/'); Feed_Entry_Adapter::load_from_id($appbox, $this->entry->get_id());
// $this->assertTrue($this->client->getResponse()->isOk()); $this->fail("Failed to delete entry");
// $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); }
// $pageContent = json_decode($this->client->getResponse()->getContent()); catch (Exception $e)
// $this->assertTrue(is_object($pageContent)); {
// $this->assertTrue(is_string($pageContent->texte));
// $suscribe_link = $this->feed->get_user_link(registry::get_instance(), self::$user, Feed_Adapter::FORMAT_RSS, null, false)->get_href(); }
// $this->assertContains($suscribe_link, $pageContent->texte); }
// }
public function testDeleteNotFound()
{
$appbox = appbox::get_instance();
$crawler = $this->client->request('POST', '/feeds/entry/UNKNOW/delete/');
$response = $this->client->getResponse();
$pageContent = json_decode($this->client->getResponse()->getContent());
$this->assertTrue($response->isOk());
$this->assertEquals("application/json", $response->headers->get("content-type"));
$this->assertTrue(is_object($pageContent));
$this->assertTrue($pageContent->error);
$this->assertTrue(is_string($pageContent->message));
}
public function testDeleteUnauthorized()
{
$appbox = appbox::get_instance();
/**
* I CREATE A FEED
* */
$feed = Feed_Adapter::create($appbox, self::$user_alt1, "salut", 'coucou');
$publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user_alt1);
$entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, "hello", "coucou", "salut", "bonjour");
$item = Feed_Entry_Item::create($appbox, $entry, self::$record_1);
$crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/delete/');
$response = $this->client->getResponse();
$pageContent = json_decode($this->client->getResponse()->getContent());
$this->assertTrue($response->isOk());
$this->assertEquals("application/json", $response->headers->get("content-type"));
$this->assertTrue(is_object($pageContent));
$this->assertTrue($pageContent->error);
$this->assertTrue(is_string($pageContent->message));
$feed->delete();
}
public function testRoot()
{
$appbox = appbox::get_instance();
$crawler = $this->client->request('GET', '/feeds/');
$pageContent = $this->client->getResponse()->getContent();
$this->assertTrue($this->client->getResponse()->isOk());
$feeds = Feed_Collection::load_all($appbox, self::$user);
foreach ($feeds->get_feeds() as $one_feed)
{
$path = "//div[@class='submenu']/a[@href='/prod/feeds/feed/" . $one_feed->get_id() . "/']";
$msg = sprintf("user %s has access to feed %s", self::$user->get_id(), $one_feed->get_id());
if ($one_feed->has_access(self::$user))
{
$this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
}
else
{
$this->fail('Feed_collection::load_all should return feed where I got access');
}
}
}
public function testGetFeed()
{
$appbox = appbox::get_instance();
$feeds = Feed_Collection::load_all($appbox, self::$user);
$crawler = $this->client->request('GET', '/feeds/feed/' . $this->feed->get_id() . "/");
$pageContent = $this->client->getResponse()->getContent();
foreach ($feeds->get_feeds() as $one_feed)
{
$path = "//div[@class='submenu']/a[@href='/prod/feeds/feed/" . $one_feed->get_id() . "/']";
$msg = sprintf("user %s has access to feed %s", self::$user->get_id(), $one_feed->get_id());
if ($one_feed->has_access(self::$user))
{
$this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
}
else
{
$this->fail('Feed_collection::load_all should return feed where I got access');
}
}
}
public function testSuscribeAggregate()
{
$appbox = appbox::get_instance();
$feeds = Feed_Collection::load_all($appbox, self::$user);
$crawler = $this->client->request('GET', '/feeds/subscribe/aggregated/');
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
$pageContent = json_decode($this->client->getResponse()->getContent());
$this->assertTrue(is_object($pageContent));
$this->assertTrue(is_string($pageContent->texte));
$suscribe_link = $feeds->get_aggregate()->get_user_link(registry::get_instance(), self::$user, Feed_Adapter::FORMAT_RSS, null, false)->get_href();
$this->assertContains($suscribe_link, $pageContent->texte);
}
public function testSuscribe()
{
$crawler = $this->client->request('GET', '/feeds/subscribe/' . $this->feed->get_id() . '/');
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
$pageContent = json_decode($this->client->getResponse()->getContent());
$this->assertTrue(is_object($pageContent));
$this->assertTrue(is_string($pageContent->texte));
$suscribe_link = $this->feed->get_user_link(registry::get_instance(), self::$user, Feed_Adapter::FORMAT_RSS, null, false)->get_href();
$this->assertContains($suscribe_link, $pageContent->texte);
}
} }

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/MoveCollection.php';
/** /**
* Test class for MoveCollection. * Test class for MoveCollection.
* Generated by PHPUnit on 2012-01-11 at 18:24:28. * Generated by PHPUnit on 2012-01-11 at 18:24:28.
@@ -17,6 +13,7 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
* 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
* *
@@ -26,7 +23,7 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
* $need_records = 2; * $need_records = 2;
* *
*/ */
protected static $need_records = false; protected static $need_records = 1;
/** /**
* The application loader * The application loader
@@ -35,7 +32,7 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
{ {
return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php'; return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php';
} }
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
@@ -52,9 +49,21 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
*/ */
public function testRouteSlash() public function testRouteSlash()
{ {
$this->markTestIncomplete( $this->client->request('POST', '/records/movecollection/', array('lst' => self::$record_1->get_serialize_key()));
'This test has not been implemented yet.'
); $response = $this->client->getResponse();
$this->assertTrue($response->isOk());
}
public function testApply()
{
$this->client->request('POST', '/records/movecollection/apply/', array('lst' => self::$record_1->get_serialize_key(), 'base_id' => self::$collection->get_base_id()));
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
} }
} }

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/Printer.php';
/** /**
* Test class for Printer. * Test class for Printer.
* Generated by PHPUnit on 2012-01-11 at 18:24:29. * Generated by PHPUnit on 2012-01-11 at 18:24:29.
@@ -17,6 +13,7 @@ class ControllerPrinterTest 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
* *
@@ -26,7 +23,7 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
* $need_records = 2; * $need_records = 2;
* *
*/ */
protected static $need_records = false; protected static $need_records = 2;
/** /**
* The application loader * The application loader
@@ -35,7 +32,7 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php'; return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php';
} }
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
@@ -52,9 +49,43 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testRouteSlash() public function testRouteSlash()
{ {
$this->markTestIncomplete( $records = array(
'This test has not been implemented yet.' self::$record_1->get_serialize_key(),
self::$record_2->get_serialize_key()
); );
$lst = implode(';', $records);
$crawler = $this->client->request('POST', '/printer/', array('lst' => $lst));
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
}
public function testRoutePrintPdf()
{
$this->markTestSkipped("Undefined variable: k_path_url \n /Users/nicolasl/workspace/phraseanet/lib/vendor/tcpdf/config/tcpdf_config.php:75");
$records = array(
self::$record_1->get_serialize_key(),
self::$record_2->get_serialize_key()
);
$lst = implode(';', $records);
$crawler = $this->client->request('POST', '/printer/print.pdf', array(
'lst' => $lst,
'lay' => \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEW
)
);
$response = $this->client->getResponse();
$this->assertEquals("application/pdf", $response->headers->get("content-type"));
$this->assertTrue($response->isOk());
} }
} }

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/Push.php';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-11 at 18:24:29. * Generated by PHPUnit on 2012-01-11 at 18:24:29.

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/Root.php';
/** /**
* Test class for Root. * Test class for Root.
* Generated by PHPUnit on 2012-01-11 at 18:24:30. * Generated by PHPUnit on 2012-01-11 at 18:24:30.

View File

@@ -13,6 +13,7 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
protected $client; protected $client;
protected static $need_records = 1; protected static $need_records = 1;
protected static $need_subdefs = true; protected static $need_subdefs = true;
protected static $need_story = 1;
public function setUp() public function setUp()
{ {
@@ -76,6 +77,28 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
} }
} }
public function testRouteCaptionSearchEngine()
{
$route_base = '/tooltip/caption/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/%s/';
$routes = array(
sprintf($route_base, 'answer')
, sprintf($route_base, 'lazaret')
, sprintf($route_base, 'preview')
, sprintf($route_base, 'basket')
, sprintf($route_base, 'overview')
);
foreach ($routes as $route)
{
$option = new \searchEngine_options();
$crawler = $this->client->request('POST', $route, array('options_serial' => $option->serialize()));
$this->assertTrue($this->client->getResponse()->isOk());
}
}
public function testRouteTCDatas() public function testRouteTCDatas()
{ {
$route = '/tooltip/tc_datas/' . self::$record_1->get_sbas_id() $route = '/tooltip/tc_datas/' . self::$record_1->get_sbas_id()
@@ -150,4 +173,24 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
} }
} }
public function testRouteStory()
{
$databox = self::$story_1->get_databox();
$route = '/tooltip/Story/' . $databox->get_sbas_id()
. '/' . self::$story_1->get_record_id() . '/';
$this->client->request('POST', $route);
$this->assertTrue($this->client->getResponse()->isOk());
}
public function testUser()
{
$route = '/tooltip/user/' . self::$user->get_id() . '/';
$this->client->request('POST', $route);
$this->assertTrue($this->client->getResponse()->isOk());
}
} }

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/UsrLists.php';
/** /**
* Test class for UsrLists. * Test class for UsrLists.
* Generated by PHPUnit on 2012-01-11 at 18:24:30. * Generated by PHPUnit on 2012-01-11 at 18:24:30.

View File

@@ -28,7 +28,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
protected $client; protected $client;
protected static $need_records = 1; protected static $need_records = 1;
protected static $need_story = true; protected static $need_story = true;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
@@ -55,7 +55,6 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
public function testAttachStoryToWZ() public function testAttachStoryToWZ()
{ {
$story = self::$story_1; $story = self::$story_1;
@@ -73,7 +72,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
try try
{ {
$this->client->request('POST', $route, array('stories'=> $story->get_serialize_key())); $this->client->request('POST', $route, array('stories' => $story->get_serialize_key()));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
} }
@@ -85,7 +84,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals(302, $response->getStatusCode()); $this->assertEquals(302, $response->getStatusCode());
$em = self::$core->getEntityManager(); $em = self::$core->getEntityManager();
/* @var $em \Doctrine\ORM\EntityManager */ /* @var $em \Doctrine\ORM\EntityManager */
$query = $em->createQuery( $query = $em->createQuery(
'SELECT COUNT(w.id) FROM \Entities\StoryWZ w' 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
); );
@@ -93,24 +92,33 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$count = $query->getSingleScalarResult(); $count = $query->getSingleScalarResult();
$this->assertEquals(1, $count); $this->assertEquals(1, $count);
$query = $em->createQuery( $query = $em->createQuery(
'SELECT w FROM \Entities\StoryWZ w' 'SELECT w FROM \Entities\StoryWZ w'
); );
$storyWZ = $query->getResult(); $storyWZ = $query->getResult();
$em->remove(array_shift($storyWZ)); $em->remove(array_shift($storyWZ));
$em->flush(); $em->flush();
//attach JSON //attach JSON
$this->client->request('POST', $route, array('stories'=> $story->get_serialize_key()), array(), array( $this->client->request('POST', $route, array('stories' => $story->get_serialize_key()), array(), array(
"HTTP_ACCEPT" => "application/json") "HTTP_ACCEPT" => "application/json")
); );
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertEquals(200, $response->getStatusCode());
//test already attached
$this->client->request('POST', $route, array('stories' => $story->get_serialize_key()), array(), array(
"HTTP_ACCEPT" => "application/json")
);
$response = $this->client->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
@@ -133,7 +141,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
//attach //attach
$attachRoute = sprintf("/WorkZone/attachStories/"); $attachRoute = sprintf("/WorkZone/attachStories/");
$this->client->request('POST', $attachRoute, array('stories'=> $story->get_serialize_key())); $this->client->request('POST', $attachRoute, array('stories' => $story->get_serialize_key()));
$query = self::$core->getEntityManager()->createQuery( $query = self::$core->getEntityManager()->createQuery(
'SELECT COUNT(w.id) FROM \Entities\StoryWZ w' 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
@@ -158,7 +166,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals(0, $count); $this->assertEquals(0, $count);
//attach //attach
$this->client->request('POST', $attachRoute, array('stories'=> $story->get_serialize_key())); $this->client->request('POST', $attachRoute, array('stories' => $story->get_serialize_key()));
//detach JSON //detach JSON
$this->client->request('POST', $route, array(), array(), array( $this->client->request('POST', $route, array(), array(), array(
@@ -167,4 +175,35 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
public function testBrowse()
{
$this->client->request("GET", "/WorkZone/Browse/");
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
}
public function testBrowseSearch()
{
$this->client->request("GET", "/WorkZone/Browse/Search/");
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
}
public function testBrowseBasket()
{
$basket = $this->insertOneBasket();
$this->client->request("GET", "/WorkZone/Browse/Basket/" . $basket->getId() . "/");
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
}
public function testDetachStoryFromWZNotFound()
{
$story = self::$story_1;
$route = sprintf("/WorkZone/detachStory/%s/%s/", $story->get_sbas_id(), 'unknow');
//story not yet Attched
}
} }

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Setup;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Setup/Installer.php';
/** /**
* Test class for Installer. * Test class for Installer.
* Generated by PHPUnit on 2012-01-11 at 18:21:34. * Generated by PHPUnit on 2012-01-11 at 18:21:34.

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Setup;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Setup/Upgrader.php';
/** /**
* Test class for Upgrader. * Test class for Upgrader.
* Generated by PHPUnit on 2012-01-11 at 18:21:35. * Generated by PHPUnit on 2012-01-11 at 18:21:35.

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Utils;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Utils/ConnectionTest.php';
/** /**
* Test class for ConnectionTest. * Test class for ConnectionTest.
* Generated by PHPUnit on 2012-01-11 at 18:20:20. * Generated by PHPUnit on 2012-01-11 at 18:20:20.
@@ -17,6 +13,7 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
* 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
* *
@@ -35,7 +32,7 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
{ {
return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Admin.php'; return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Admin.php';
} }
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
@@ -50,12 +47,98 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
/** /**
* Default route test * Default route test
*/ */
public function testRouteSlash() public function testRouteMysql()
{ {
$this->markTestIncomplete( $handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
'This test has not been implemented yet.' new \Alchemy\Phrasea\Core\Configuration\Application(),
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
); );
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
$chooseConnexion = $configuration->getPhraseanet()->get('database');
$connexion = $configuration->getConnexion($chooseConnexion);
$params = array(
"hostname" => $connexion->get('host'),
"port" => $connexion->get('port'),
"user" => $connexion->get('user'),
"password" => $connexion->get('password'),
"dbname" => $connexion->get('dbname')
);
$this->client->request("GET", "/tests/connection/mysql/", $params);
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
} }
public function testRouteMysqlFailed()
{
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
new \Alchemy\Phrasea\Core\Configuration\Application(),
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
);
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
$chooseConnexion = $configuration->getPhraseanet()->get('database');
$connexion = $configuration->getConnexion($chooseConnexion);
$params = array(
"hostname" => $connexion->get('host'),
"port" => $connexion->get('port'),
"user" => $connexion->get('user'),
"password" => "fakepassword",
"dbname" => $connexion->get('dbname')
);
$this->client->request("GET", "/tests/connection/mysql/", $params);
$response = $this->client->getResponse();
$content = json_decode($this->client->getResponse()->getContent());
$this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
$this->assertTrue($response->isOk());
$this->assertTrue(is_object($content));
$this->assertObjectHasAttribute('connection', $content);
$this->assertObjectHasAttribute('database', $content);
$this->assertObjectHasAttribute('is_empty', $content);
$this->assertObjectHasAttribute('is_appbox', $content);
$this->assertObjectHasAttribute('is_databox', $content);
$this->assertFalse($content->connection);
}
public function testRouteMysqlDbFailed()
{
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
new \Alchemy\Phrasea\Core\Configuration\Application(),
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
);
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
$chooseConnexion = $configuration->getPhraseanet()->get('database');
$connexion = $configuration->getConnexion($chooseConnexion);
$params = array(
"hostname" => $connexion->get('host'),
"port" => $connexion->get('port'),
"user" => $connexion->get('user'),
"password" => $connexion->get('password'),
"dbname" => "fake-DTABASE-name"
);
$this->client->request("GET", "/tests/connection/mysql/", $params);
$response = $this->client->getResponse();
$content = json_decode($this->client->getResponse()->getContent());
$this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
$this->assertTrue($response->isOk());
$this->assertTrue(is_object($content));
$this->assertObjectHasAttribute('connection', $content);
$this->assertObjectHasAttribute('database', $content);
$this->assertObjectHasAttribute('is_empty', $content);
$this->assertObjectHasAttribute('is_appbox', $content);
$this->assertObjectHasAttribute('is_databox', $content);
$this->assertFalse($content->database);
}
} }

View File

@@ -1,11 +1,7 @@
<?php <?php
namespace Alchemy\Phrasea\Controller\Utils;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Utils/PathFileTest.php';
/** /**
* Test class for PathFileTest. * Test class for PathFileTest.
* Generated by PHPUnit on 2012-01-11 at 18:20:21. * Generated by PHPUnit on 2012-01-11 at 18:20:21.

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace Alchemy\Phrasea\Helper\Record;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-12 at 12:16:06. * Generated by PHPUnit on 2012-01-12 at 12:16:06.
*/ */
class BridgeTest extends \PhraseanetPHPUnitAuthenticatedAbstract class HelperBridgeTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
/** /**

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace Alchemy\Phrasea\Helper\Record;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-12 at 12:16:06. * Generated by PHPUnit on 2012-01-12 at 12:16:06.
*/ */
class EditTest extends \PhraseanetPHPUnitAuthenticatedAbstract class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
/** /**

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace Alchemy\Phrasea\Helper\Record;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-12 at 12:16:06. * Generated by PHPUnit on 2012-01-12 at 12:16:06.
*/ */
class FeedTest extends \PhraseanetPHPUnitAuthenticatedAbstract class HelperFeedTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
/** /**

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace Alchemy\Phrasea\Helper\Record;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-12 at 12:16:06. * Generated by PHPUnit on 2012-01-12 at 12:16:06.
*/ */
class HelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
/** /**

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace Alchemy\Phrasea\Helper\Record;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-12 at 12:16:06. * Generated by PHPUnit on 2012-01-12 at 12:16:06.
*/ */
class MoveCollectionTest extends \PhraseanetPHPUnitAuthenticatedAbstract class HelperMoveCollectionTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
/** /**

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace Alchemy\Phrasea\Helper\Record;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-12 at 12:16:06. * Generated by PHPUnit on 2012-01-12 at 12:16:06.
*/ */
class PrinterTest extends \PhraseanetPHPUnitAuthenticatedAbstract class HelperPrinterTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
/** /**

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace Alchemy\Phrasea\Helper\Record;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-12 at 12:16:06. * Generated by PHPUnit on 2012-01-12 at 12:16:06.
*/ */
class PushTest extends \PhraseanetPHPUnitAuthenticatedAbstract class HelperPushTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
/** /**

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace Alchemy\Phrasea\Helper\Record;
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
/** /**
* Test class for Push. * Test class for Push.
* Generated by PHPUnit on 2012-01-12 at 12:16:06. * Generated by PHPUnit on 2012-01-12 at 12:16:06.
*/ */
class TooltipTest extends \PhraseanetPHPUnitAuthenticatedAbstract class HelperTooltipTest extends \PhraseanetPHPUnitAuthenticatedAbstract
{ {
/** /**

View File

@@ -23,24 +23,24 @@ class Bridge_AccountTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
try try
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"'; $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(); $stmt->execute();
$stmt->closeCursor(); $stmt->closeCursor();
$this->api = Bridge_Api::create($appbox, 'Apitest'); $this->api = Bridge_Api::create($appbox, 'Apitest');
$this->dist_id = 'EZ1565loPP'; $this->dist_id = 'EZ1565loPP';
$this->named = 'Fête à pinpins'; $this->named = 'Fête à pinpins';
$account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named); $account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named);
$this->id = $account->get_id(); $this->id = $account->get_id();
$this->object = new Bridge_Account($appbox, $this->api, $this->id); $this->object = new Bridge_Account($appbox, $this->api, $this->id);
} }
catch(Exception $e) catch (Exception $e)
{ {
var_dump($e->getMessage(), $e->getFile(), $e->getLine());exit; $this->fail($e->getMessage());
} }
} }
@@ -56,7 +56,7 @@ class Bridge_AccountTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
catch (Bridge_Exception_AccountNotFound $e) catch (Bridge_Exception_AccountNotFound $e)
{ {
} }
$this->api->delete(); $this->api->delete();
@@ -144,9 +144,9 @@ class Bridge_AccountTest extends PhraseanetPHPUnitAuthenticatedAbstract
$accounts = Bridge_Account::get_accounts_by_user(appbox::get_instance(), self::$user); $accounts = Bridge_Account::get_accounts_by_user(appbox::get_instance(), self::$user);
$this->assertTrue(is_array($accounts)); $this->assertTrue(is_array($accounts));
$this->assertTrue(count($accounts)>0); $this->assertTrue(count($accounts) > 0);
foreach($accounts as $account) foreach ($accounts as $account)
{ {
$this->assertInstanceOf('Bridge_Account', $account); $this->assertInstanceOf('Bridge_Account', $account);
} }

View File

@@ -76,17 +76,17 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface
{ {
} }
public function get_category() public function get_category()
{ {
} }
public function is_private() public function is_private()
{ {
} }
public function get_rating() public function get_rating()
{ {
@@ -174,8 +174,12 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface
class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Interface class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Interface
{ {
const AUTH_TYPE = 'None'; const AUTH_TYPE = 'None';
public static $hasError = false;
public static $hasException = false;
public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $auth) public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $auth)
{ {
parent::__construct($registry, $auth); parent::__construct($registry, $auth);
@@ -384,19 +388,31 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
} }
public function create_container($container_type, Request $request) public function create_container($container_type, \Symfony\Component\HttpFoundation\Request $request)
{ {
if (self::$hasException)
{
self::$hasException = false;
throw new \Exception("une erreur");
}
} }
public function add_element_to_container($element_type, $element_id, $destination, $container_id) public function add_element_to_container($element_type, $element_id, $destination, $container_id)
{ {
if (self::$hasException)
{
self::$hasException = false;
throw new \Exception("une erreur");
}
} }
public function delete_object($object, $object_id) public function delete_object($object, $object_id)
{ {
if (self::$hasException)
{
self::$hasException = false;
throw new \Exception("une erreur");
}
} }
/** /**
@@ -405,7 +421,11 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
*/ */
public function acceptable_records() public function acceptable_records()
{ {
$func = function($record)
{
return true;
};
return $func;
} }
public function get_element_status(Bridge_Element $element) public function get_element_status(Bridge_Element $element)
@@ -440,12 +460,17 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
public function check_upload_constraints(array $datas, record_adapter $record) public function check_upload_constraints(array $datas, record_adapter $record)
{ {
if (self::$hasError)
{
self::$hasError = false;
return array('title' => 'too long');
}
return array();
} }
public function get_upload_datas(Request $request, record_adapter $record) public function get_upload_datas(\Symfony\Component\HttpFoundation\Request $request, record_adapter $record)
{ {
return array();
} }
public function is_multiple_upload() public function is_multiple_upload()
@@ -455,12 +480,26 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
public function check_update_constraints(Array $datas) public function check_update_constraints(Array $datas)
{ {
if (!self::$hasError)
{
if (self::$hasException)
{
self::$hasException = false;
throw new \Exception('une erreur');
}
return array();
}
elseif (self::$hasError)
{
self::$hasError = false;
return array('title' => 'too long');
}
} }
public function get_update_datas(Request $request) public function get_update_datas(\Symfony\Component\HttpFoundation\Request $request)
{ {
return array();
} }
} }

View File

@@ -34,7 +34,7 @@
</div> </div>
</td> </td>
<td> <td>
<input class="required_field" type='text' name='{{name}}' value="{{ caption.get_dc_field('Title').get_value()|default(record.get_title()) }}"/> <input class="required_field" type='text' name='{{name}}' value="{{ caption.get_dc_field('Title') is not none ? caption.get_dc_field('Title').get_value()|default(record.get_title()) : record.get_title() }}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>
@@ -48,7 +48,7 @@
</div> </div>
</td> </td>
<td class='column_right'> <td class='column_right'>
<textarea class="required_field" name="{{name}}" rows="5">{{ caption.get_dc_field('Description').get_value() }}</textarea> <textarea class="required_field" name="{{name}}" rows="5">{{ caption.get_dc_field('Description') is not none ? caption.get_dc_field('Description').get_value() : "" }}</textarea>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>
@@ -66,7 +66,7 @@
</div> </div>
</td> </td>
<td> <td>
<input class='required_field' type='text' name='{{name}}' value="{{ caption.get_dc_field('Subject').get_value(true, ' ') }}"/> <input class='required_field' type='text' name='{{name}}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_value(true, ' ') : ''}}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>

View File

@@ -45,7 +45,7 @@
<label for='{{name}}'>{% trans 'Titre' %}</label> <label for='{{name}}'>{% trans 'Titre' %}</label>
</td> </td>
<td style="width:180px;"> <td style="width:180px;">
<input class="required_field" style="width:150px;" type='text' name='{{name}}' value="{{ caption.get_dc_field('Title').get_value()|default(record.get_title()) }}"/> <input class="required_field" style="width:150px;" type='text' name='{{name}}' value="{{ caption.get_dc_field('Title') is not none ? caption.get_dc_field('Title').get_value()|default(record.get_title()) : record.get_title() }}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>
@@ -61,7 +61,7 @@
</label> </label>
</td> </td>
<td class='column_right'> <td class='column_right'>
<textarea class="required_field" name="{{ name }}" rows="5" style="width:150px;">{{ caption.get_dc_field('Description').get_value() }}</textarea> <textarea class="required_field" name="{{ name }}" rows="5" style="width:150px;">{{ caption.get_dc_field('Description') is not none ? caption.get_dc_field('Description').get_value() : "" }}</textarea>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>
@@ -74,7 +74,7 @@
<label for='{{ name }}'>{% trans 'Tags' %}</label> <label for='{{ name }}'>{% trans 'Tags' %}</label>
</td> </td>
<td> <td>
<input class='required_field' type='text' style="width:150px;" name='{{ name }}' value="{{ caption.get_dc_field('Subject').get_value(true, ' ') }}"/> <input class='required_field' type='text' style="width:150px;" name='{{ name }}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_value(true, ' ') : '' }}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>

View File

@@ -34,7 +34,7 @@
</div> </div>
</td> </td>
<td> <td>
<input class="required_field" type='text' name='{{name}}' value="{{ caption.get_dc_field('Title').get_value()|default(record.get_title()) }}"/> <input class="required_field" type='text' name='{{name}}' value="{{ caption.get_dc_field('Title') is not none ? caption.get_dc_field('Title').get_value()|default(record.get_title()) : record.get_title() }}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</label> </label>
@@ -49,7 +49,7 @@
</div> </div>
</td> </td>
<td class='column_right'> <td class='column_right'>
<textarea class="required_field" name="{{ name }}" rows="5">{{ caption.get_dc_field('Description').get_value() }}</textarea> <textarea class="required_field" name="{{ name }}" rows="5">{{ caption.get_dc_field('Description') is not none ? caption.get_dc_field('Description').get_value() : ""}}</textarea>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>
@@ -78,7 +78,7 @@
</div> </div>
</td> </td>
<td> <td>
<input class='required_field' type='text' name='{{ name }}' value="{{ caption.get_dc_field('Subject').get_value(true, ' ') }}"/> <input class='required_field' type='text' name='{{ name }}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_value(true, ' ') : ""}}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>