diff --git a/bin/console b/bin/console index e28be8ae91..03b4a2095a 100755 --- a/bin/console +++ b/bin/console @@ -54,7 +54,6 @@ try $app->add(new module_console_aboutLicense('about:license')); $app->add(new module_console_systemUpgrade('system:upgrade')); $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_systemClearCache('system:clearCache')); $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_schedulerStart('scheduler:start')); $app->add(new module_console_fileConfigCheck('check:config')); + $app->add(new module_console_systemConfigCheck('check:system')); $app->run(); } catch (Exception $e) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index c1f83a750a..ec25065f22 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -324,6 +324,7 @@ class Bridge implements ControllerProviderInterface , 'element_type' => $element_type , 'action' => $action , 'elements' => $elements + , 'adapter_action' => $action , 'error_message' => _('Request contains invalid datas') , 'constraint_errors' => $errors , 'notice_message' => $app['request']->get('notice') @@ -350,9 +351,9 @@ class Bridge implements ControllerProviderInterface break; case 'createcontainer': - try { + $container_type = $request->get('f_container_type'); $account->get_api()->create_container($container_type, $app['request']); @@ -417,6 +418,7 @@ class Bridge implements ControllerProviderInterface $app['require_connection']($account); $route = new RecordHelper\Bridge($app['Core'], $app['request']); + $route->grep_records($account->get_api()->acceptable_records()); $params = array( @@ -424,6 +426,7 @@ class Bridge implements ControllerProviderInterface , 'account' => $account , 'error_message' => $app['request']->get('error') , 'notice_message' => $app['request']->get('notice') + , 'adapter_action' => 'upload' ); $html = $twig->render( @@ -450,14 +453,12 @@ class Bridge implements ControllerProviderInterface /** * check constraints */ - $errors = array(); foreach ($route->get_elements() as $record) { $datas = $connector->get_upload_datas($request, $record); $errors = array_merge($errors, $connector->check_upload_constraints($datas, $record)); } - if (count($errors) > 0) { @@ -467,6 +468,7 @@ class Bridge implements ControllerProviderInterface , 'error_message' => _('Request contains invalid datas') , 'constraint_errors' => $errors , '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); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index 12543deb33..457cbf4489 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -15,6 +15,8 @@ use Silex\Application; use Silex\ControllerProviderInterface; use Silex\ControllerCollection; 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->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(); @@ -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->execute($request); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index 24376b32a4..1d54123bf4 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -39,12 +39,12 @@ class Feed implements ControllerProviderInterface /** * 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); $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)); @@ -55,13 +55,11 @@ class Feed implements ControllerProviderInterface /** * 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 { - $request = $app['request']; - - $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); + $user = $app["Core"]->getAuthenticatedUser(); $feed = new \Feed_Adapter($appbox, $request->get('feed_id')); $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 = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); + $user = $app["Core"]->getAuthenticatedUser(); $entry = \Feed_Entry_Adapter::load_from_id($appbox, $id); @@ -102,8 +98,8 @@ class Feed implements ControllerProviderInterface { 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)); @@ -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' => ''); try { $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); @@ -139,13 +134,17 @@ class Feed implements ControllerProviderInterface ->set_subtitle($subtitle); $items = explode(';', $request->get('sorted_lst')); + foreach ($items as $item_sort) { $item_sort_datas = explode('_', $item_sort); if (count($item_sort_datas) != 2) + { continue; + } $item = new \Feed_Entry_Item($appbox, $entry, $item_sort_datas[0]); + $item->set_ord($item_sort_datas[1]); } $appbox->get_connection()->commit(); @@ -159,7 +158,7 @@ class Feed implements ControllerProviderInterface $appbox->get_connection()->rollBack(); $datas['message'] = _('Feed entry not found'); } - catch (Exception $e) + catch (\Exception $e) { $appbox->get_connection()->rollBack(); $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' => ''); try { $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); @@ -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']; $page = (int) $request->get('page'); $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); $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 = $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); $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'); - $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); + $user = $app["Core"]->getAuthenticatedUser(); + $feeds = \Feed_Collection::load_all($appbox, $user); $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'); - $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); + $user = $app["Core"]->getAuthenticatedUser(); $feed = \Feed_Adapter::load_with_user($appbox, $user, $id); $registry = $appbox->get_registry(); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php index 8c6a566673..6239ae674a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php @@ -31,7 +31,7 @@ class MoveCollection implements ControllerProviderInterface { $controllers = new ControllerCollection(); - $controllers->post('/', function(Application $app) + $controllers->post('/', function(Application $app, Request $request) { $request = $app['request']; $move = new RecordHelper\MoveCollection($app['Core'], $app['request']); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php index 70971d2e6e..2edabb94d8 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php @@ -102,10 +102,16 @@ class Tooltip implements ControllerProviderInterface $record = new \record_adapter($sbas_id, $record_id, $number); $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()); - $search_engine->set_options($search_engine_options); + if (($search_engine_options = $option->unserialize($app['request']->get('options_serial'))) !== false) + { + $search_engine = new \searchEngine_adapter($app['appbox']->get_registry()); + $search_engine->set_options($search_engine_options); + } } /* @var $twig \Twig_Environment */ @@ -164,25 +170,18 @@ class Tooltip implements ControllerProviderInterface $controllers->post('/metas/DCESInfos/{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 */ - $twig = $app['Core']->getTwig(); + /* @var $twig \Twig_Environment */ + $twig = $app['Core']->getTwig(); - return new Response( - $twig->render( - 'common/databox_field_DCES.twig' - , array('field' => $field) - ) - ); - } - catch (\Exception $e) - { - exit($e->getMessage()); - } + return new Response( + $twig->render( + 'common/databox_field_DCES.twig' + , array('field' => $field) + ) + ); })->assert('sbas_id', '\d+')->assert('field_id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php index 0d3d3a5173..ca04edc546 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php @@ -313,7 +313,6 @@ class Installer implements ControllerProviderInterface catch (\Exception $e) { \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())); diff --git a/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php b/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php index a11f580ed0..1ee8ef4f26 100644 --- a/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php +++ b/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php @@ -96,7 +96,7 @@ class ConnectionTest implements ControllerProviderInterface , 'is_empty' => $empty , 'is_appbox' => $is_appbox , 'is_databox' => $is_databox - )), 200, array('application/json')); + )), 200, array('content-type' => 'application/json')); }); return $controllers; diff --git a/lib/Alchemy/Phrasea/Helper/Record/Edit.php b/lib/Alchemy/Phrasea/Helper/Record/Edit.php index e406a5e423..ff231a36a3 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Edit.php @@ -450,7 +450,7 @@ class Edit extends RecordHelper * @param http_request $request * @return action_edit */ - public function execute(Symfony\Component\HttpFoundation\Request $request) + public function execute(Request $request) { $appbox = \appbox::get_instance(); if ($request->get('act_option') == 'SAVEGRP' && $request->get('newrepresent')) diff --git a/lib/Alchemy/Phrasea/Helper/Record/Feed.php b/lib/Alchemy/Phrasea/Helper/Record/Feed.php index f0fa6b07cb..1a08e8bf83 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Feed.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Feed.php @@ -11,7 +11,8 @@ 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; /** diff --git a/lib/Alchemy/Phrasea/Helper/Record/MoveCollection.php b/lib/Alchemy/Phrasea/Helper/Record/MoveCollection.php index 15b0819a93..2e67f1926e 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/MoveCollection.php +++ b/lib/Alchemy/Phrasea/Helper/Record/MoveCollection.php @@ -100,10 +100,18 @@ class MoveCollection extends RecordHelper $appbox = \appbox::get_instance(); $user = $this->getCore()->getAuthenticatedUser(); + $baseId = $request->get('base_id'); + $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; - + + 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()) throw new Exception('This action is not possible'); @@ -122,7 +130,8 @@ class MoveCollection extends RecordHelper } } } - + + $collection = \collection::get_from_base_id($base_dest); foreach ($this->selection as $record) diff --git a/lib/classes/collection.class.php b/lib/classes/collection.class.php index 8acf39bdcb..681eecde27 100644 --- a/lib/classes/collection.class.php +++ b/lib/classes/collection.class.php @@ -65,7 +65,7 @@ class collection implements cache_cacheableInterface } catch (Exception $e) { - + } $connbas = $this->databox->get_connection(); @@ -200,9 +200,9 @@ class collection implements cache_cacheableInterface $stmt = $this->get_connection()->prepare($sql); $stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id())); $stmt->closeCursor(); - + $this->pub_wm = $publi; - + $this->delete_data_from_cache(); } @@ -223,9 +223,9 @@ class collection implements cache_cacheableInterface $stmt->closeCursor(); $this->name = $name; - + $this->delete_data_from_cache(); - + phrasea::reset_baseDatas(); return $this; @@ -304,7 +304,7 @@ class collection implements cache_cacheableInterface public function delete() { - while($this->get_record_amount() > 0) + while ($this->get_record_amount() > 0) { $this->empty_collection(); } @@ -350,8 +350,10 @@ class collection implements cache_cacheableInterface { $coll_id = phrasea::collFromBas($base_id); $sbas_id = phrasea::sbasFromBas($base_id); - if(!$sbas_id || !$coll_id) - throw new Exception_Databox_CollectionNotFound(); + if (!$sbas_id || !$coll_id) + { + throw new Exception_Databox_CollectionNotFound(sprintf("Collection could not be found")); + } $databox = databox::get_instance($sbas_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->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id())); $stmt->closeCursor(); - + $this->delete_data_from_cache(); return $this->prefs; diff --git a/lib/classes/setup.class.php b/lib/classes/setup.class.php index 9e197f6885..9cbf760ee0 100644 --- a/lib/classes/setup.class.php +++ b/lib/classes/setup.class.php @@ -77,19 +77,20 @@ class setup $appConf->getServiceFile(); $installed = true; } - catch(\Exception $e) + catch (\Exception $e) { + } return $installed; } - + public static function needUpgradeConfigurationFile() { - return (is_file(__DIR__ . "/../../config/connexion.inc") - && is_file(__DIR__ . "/../../config/config.inc")); + return (is_file(__DIR__ . "/../../config/connexion.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"); @@ -761,12 +762,14 @@ class setup 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"); if (!$structure) + { throw new Exception('Unable to load schema'); + } $appbox = $structure->appbox; $databox = $structure->databox; @@ -803,9 +806,10 @@ class setup } } + $appConf = new \Alchemy\Phrasea\Core\Configuration\Application(); + try { - $appConf = new \Alchemy\Phrasea\Core\Configuration\Application(); $configFile = $appConf->getConfigurationFile(); 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; } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Admin/FieldsTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Admin/FieldsTest.php index fce5498df2..8aea68e167 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Admin/FieldsTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Admin/FieldsTest.php @@ -1,11 +1,7 @@ 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() { $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() @@ -265,6 +284,9 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract $this->assertContains($redirect, $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->client->request('POST', $url, array("element_list" => "1_2;1_3;1_4")); + $this->assertTrue($this->client->getResponse()->isRedirect()); } public function testActionModifyElement() @@ -274,6 +296,67 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract $crawler = $this->client->request('GET', $url, array("elements_list" => "element123qcs789")); $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->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()); $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->client->request('POST', $url, array("elements_list" => "containerudt456shn")); + $this->assertTrue($this->client->getResponse()->isOk()); } 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())); $this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", $this->client->getResponse()->getContent()); $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) { - $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()); } } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/EditTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/EditTest.php index 6f4e00ff45..b8c984cadc 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/EditTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/EditTest.php @@ -1,7 +1,5 @@ markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->client->request('POST', '/records/edit/', array('lst' => self::$record_1->get_serialize_key())); + + $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()); } } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php index 12facef8a1..ef0b266a62 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php @@ -10,20 +10,37 @@ use Symfony\Component\HttpFoundation\Response; class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract { + /** + * + * @var Feed_Adapter + */ protected $feed; + + /** + * + * @var Feed_Entry_Adapter + */ protected $entry; + + /** + * + * @var Feed_Entry_Item + */ protected $item; + + /** + * + * @var Feed_Publisher_Adapter + */ protected $publisher; protected $client; - protected $feed_title = 'feed title'; protected $feed_subtitle = 'feed subtitle'; protected $entry_title = 'entry title'; protected $entry_subtitle = 'entry subtitle'; protected $entry_authorname = 'author name'; protected $entry_authormail = 'author.mail@example.com'; - - protected static $need_records = 1; + protected static $need_records = 2; protected static $need_subdefs = false; public static function setUpBeforeClass() @@ -39,12 +56,19 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract public function setUp() { parent::setUp(); + $appbox = appbox::get_instance(); + $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( $appbox , $this->feed @@ -54,6 +78,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract , $this->entry_authorname , $this->entry_authormail ); + $this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1); } @@ -84,232 +109,356 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract } } -// public function testEntryCreate() -// { -// $params = array( -// "feed_id" => $this->feed->get_id() -// , "title" => "salut" -// , "subtitle" => "coucou" -// , "author_name" => "robert" -// , "author_email" => "robert@kikoo.mail" -// , 'lst' => self::$record_1->get_serialize_key() -// ); -// -// $crawler = $this->client->request('POST', '/entry/create/', $params); -// $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->assertFalse($pageContent->error); -// $this->assertFalse($pageContent->message); -// } -// -// public function testEntryEditFailed() -// { -// $params = array( -// "feed_id" => 'unknow' -// , "title" => "salut" -// , "subtitle" => "coucou" -// , "author_name" => "robert" -// , "author_email" => "robert@kikoo.mail" -// , 'lst' => self::$record_1->get_serialize_key() -// ); -// -// $crawler = $this->client->request('POST', '/entry/create/', $params); -// $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($pageContent->error); -// $this->assertTrue(is_string($pageContent->message)); -// } -// -// public function testEntryEdit() -// { -// $appbox = appbox::get_instance(); -// -// $crawler = $this->client->request('GET', '/entry/' . $this->entry->get_id() . '/edit/'); -// $pageContent = $this->client->getResponse()->getContent(); -// 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='" . $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("//input[@value='" . $this->entry_authormail . "']")->count()); -// } -// -// public function testEntryUpdate() -// { -// $appbox = appbox::get_instance(); -// -// $params = array( -// "feed_id" => $this->feed->get_id() -// , "title" => "dog" -// , "subtitle" => "cat" -// , "author_name" => "bird" -// , "author_email" => "mouse" -// , 'lst' => self::$record_1->get_serialize_key() -// ); -// -// $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")); -// $pageContent = json_decode($this->client->getResponse()->getContent()); -// $this->assertTrue(is_object($pageContent)); -// $this->assertFalse($pageContent->error); -// $this->assertTrue(is_string($pageContent->message)); -// $this->assertTrue(is_string($pageContent->datas)); -// $this->assertRegExp("/entry_" . $this->entry->get_id() . "/", $pageContent->datas); -// } -// -// public function testEntryUpdateFailed() -// { -// $appbox = appbox::get_instance(); -// /** -// * I CREATE A FEED THAT IS NOT MINE -// * */ -// $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); -// -// $params = array( -// "feed_id" => $feed->get_id() -// , "title" => "dog" -// , "subtitle" => "cat" -// , "author_name" => "bird" -// , "author_email" => "mouse" -// , 'lst' => self::$record_1->get_serialize_key() -// ); -// -// $crawler = $this->client->request('POST', '/entry/' . $entry->get_id() . '/update/', $params); -// $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($pageContent->error); -// $this->assertTrue(is_string($pageContent->message)); -// -// $feed->delete(); -// } -// -// public function testDelete() -// { -// $appbox = appbox::get_instance(); -// -// $crawler = $this->client->request('POST', '/entry/' . $this->entry->get_id() . '/delete/'); -// $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->assertFalse($pageContent->error); -// $this->assertTrue(is_string($pageContent->message)); -// try -// { -// Feed_Entry_Adapter::load_from_id($appbox, $this->entry->get_id()); -// $this->fail("Failed to delete entry"); -// } -// catch (Exception $e) -// { -// -// } -// } -// -// public function testDeleteFailed() -// { -// $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', '/entry/' . $entry->get_id() . '/delete/'); -// $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($pageContent->error); -// $this->assertTrue(is_string($pageContent->message)); -// -// $feed->delete(); -// } -// -// public function testRoot() -// { -// $appbox = appbox::get_instance(); -// $crawler = $this->client->request('GET', '/'); -// $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', '/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', '/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', '/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); -// } + public function testEntryCreate() + { + $params = array( + "feed_id" => $this->feed->get_id() + , "title" => "salut" + , "subtitle" => "coucou" + , "author_name" => "robert" + , "author_email" => "robert@kikoo.mail" + , 'lst' => self::$record_1->get_serialize_key() + ); + + $crawler = $this->client->request('POST', '/feeds/entry/create/', $params); + $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->assertFalse($pageContent->error); + $this->assertFalse($pageContent->message); + } + + public function testEntryCreateError() + { + $params = array( + "feed_id" => 'unknow' + , "title" => "salut" + , "subtitle" => "coucou" + , "author_name" => "robert" + , "author_email" => "robert@kikoo.mail" + , 'lst' => self::$record_1->get_serialize_key() + ); + $crawler = $this->client->request('POST', '/feeds/entry/create/', $params); + $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($pageContent->error); + $this->assertTrue(is_string($pageContent->message)); + } + + public function testEntryEdit() + { + $appbox = appbox::get_instance(); + + $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/edit/'); + $pageContent = $this->client->getResponse()->getContent(); + + 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='" . $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("//input[@value='" . $this->entry_authormail . "']")->count()); + } + + public function testEntryEditUnauthorized() + { + $appbox = appbox::get_instance(); + + $feed = Feed_Adapter::create( + $appbox, self::$user_alt1, $this->feed_title, $this->feed_subtitle + ); + + $publisher = Feed_Publisher_Adapter::getPublisher( + $appbox, $feed, self::$user_alt1 + ); + + $entry = Feed_Entry_Adapter::create( + $appbox + , $feed + , $publisher + , $this->entry_title + , $this->entry_subtitle + , $this->entry_authorname + , $this->entry_authormail + ); + + + $crawler = $this->client->request('GET', '/feeds/entry/' . $entry->get_id() . '/edit/'); + + $response = $this->client->getResponse(); + + $this->assertFalse($response->isOk()); + + $feed->delete(); + } + + public function testEntryUpdate() + { + $appbox = appbox::get_instance(); + + $params = array( + "feed_id" => $this->feed->get_id() + , "title" => "dog" + , "subtitle" => "cat" + , "author_name" => "bird" + , "author_email" => "mouse" + , 'lst' => self::$record_1->get_serialize_key() + ); + + $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params); + $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->assertFalse($pageContent->error); + $this->assertTrue(is_string($pageContent->message)); + $this->assertTrue(is_string($pageContent->datas)); + $this->assertRegExp("/entry_" . $this->entry->get_id() . "/", $pageContent->datas); + } + + public function testEntryUpdateNotFound() + { + $appbox = appbox::get_instance(); + + $params = array( + "feed_id" => 9999999 + , "title" => "dog" + , "subtitle" => "cat" + , "author_name" => "bird" + , "author_email" => "mouse" + , 'lst' => self::$record_1->get_serialize_key() + ); + + $crawler = $this->client->request('POST', '/feeds/entry/UNKNOW/update/', $params); + + $response = $this->client->getResponse(); + + $pageContent = json_decode($response->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 testEntryUpdateFailed() + { + $appbox = appbox::get_instance(); + + $params = array( + "feed_id" => 9999999 + , "title" => "dog" + , "subtitle" => "cat" + , "author_name" => "bird" + , "author_email" => "mouse" + , 'sorted_lst' => self::$record_1->get_serialize_key() . ";" . self::$record_2->get_serialize_key() . ";12345;" . "unknow_unknow" + ); + + $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params); + + $response = $this->client->getResponse(); + + $this->assertTrue($response->isOk()); + $pageContent = json_decode($response->getContent()); + + $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 testEntryUpdateUnauthorized() + { + $appbox = appbox::get_instance(); + /** + * I CREATE A FEED THAT IS NOT MINE + * */ + $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); + + $params = array( + "feed_id" => $feed->get_id() + , "title" => "dog" + , "subtitle" => "cat" + , "author_name" => "bird" + , "author_email" => "mouse" + , 'lst' => self::$record_1->get_serialize_key() + ); + + $crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/update/', $params); + + $response = $this->client->getResponse(); + + $this->assertTrue($response->isOk()); + $pageContent = json_decode($response->getContent()); + + $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 testDelete() + { + $appbox = appbox::get_instance(); + + $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/delete/'); + + $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->assertFalse($pageContent->error); + $this->assertTrue(is_string($pageContent->message)); + + try + { + Feed_Entry_Adapter::load_from_id($appbox, $this->entry->get_id()); + $this->fail("Failed to delete entry"); + } + catch (Exception $e) + { + + } + } + + 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); + } } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/MoveCollectionTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/MoveCollectionTest.php index 2e2d0f0cb7..5cd1139880 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/MoveCollectionTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/MoveCollectionTest.php @@ -1,11 +1,7 @@ markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->client->request('POST', '/records/movecollection/', array('lst' => self::$record_1->get_serialize_key())); + + $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()); } } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PrinterTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PrinterTest.php index 396ae4fc6a..2458b55b1a 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PrinterTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PrinterTest.php @@ -1,11 +1,7 @@ markTestIncomplete( - 'This test has not been implemented yet.' + $records = array( + 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()); } } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PushTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PushTest.php index 17ca9f138b..71e4275500 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PushTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PushTest.php @@ -1,11 +1,7 @@ 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() { $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()); + } + } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/UsrListsTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/UsrListsTest.php index 8fdd4f223e..05fe552537 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/UsrListsTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/UsrListsTest.php @@ -1,11 +1,7 @@ assertEquals(200, $response->getStatusCode()); } - public function testAttachStoryToWZ() { $story = self::$story_1; @@ -73,7 +72,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 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(); } @@ -85,7 +84,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(302, $response->getStatusCode()); $em = self::$core->getEntityManager(); - /* @var $em \Doctrine\ORM\EntityManager */ + /* @var $em \Doctrine\ORM\EntityManager */ $query = $em->createQuery( 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w' ); @@ -93,24 +92,33 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $count = $query->getSingleScalarResult(); $this->assertEquals(1, $count); - + $query = $em->createQuery( 'SELECT w FROM \Entities\StoryWZ w' ); - + $storyWZ = $query->getResult(); $em->remove(array_shift($storyWZ)); - + $em->flush(); - - + + //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") ); - + $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()); } @@ -133,7 +141,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract //attach $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( 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w' @@ -158,7 +166,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(0, $count); //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 $this->client->request('POST', $route, array(), array(), array( @@ -167,4 +175,35 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $response = $this->client->getResponse(); $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 + } + } \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Setup/InstallerTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Setup/InstallerTest.php index b4bff75e3a..dcdaa09a17 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Setup/InstallerTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Setup/InstallerTest.php @@ -1,11 +1,7 @@ markTestIncomplete( - 'This test has not been implemented yet.' + $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" => $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); + } + } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Utils/PathFileTestTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Utils/PathFileTestTest.php index 31b2ad99ab..d28320e746 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Utils/PathFileTestTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Utils/PathFileTestTest.php @@ -1,11 +1,7 @@ get_connection()->prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); + $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"'; + $stmt = $appbox->get_connection()->prepare($sql); + $stmt->execute(); + $stmt->closeCursor(); - $this->api = Bridge_Api::create($appbox, 'Apitest'); - $this->dist_id = 'EZ1565loPP'; + $this->api = Bridge_Api::create($appbox, 'Apitest'); + $this->dist_id = 'EZ1565loPP'; $this->named = 'Fête à pinpins'; - $account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named); - $this->id = $account->get_id(); + $account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named); + $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) { - + } $this->api->delete(); @@ -144,9 +144,9 @@ class Bridge_AccountTest extends PhraseanetPHPUnitAuthenticatedAbstract $accounts = Bridge_Account::get_accounts_by_user(appbox::get_instance(), self::$user); $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); } diff --git a/lib/unitTest/Bridge/Bridge_datas.inc b/lib/unitTest/Bridge/Bridge_datas.inc index e6fec4eac5..4bbcba3310 100644 --- a/lib/unitTest/Bridge/Bridge_datas.inc +++ b/lib/unitTest/Bridge/Bridge_datas.inc @@ -76,17 +76,17 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface { } - + public function get_category() { } - + public function is_private() { } - + 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 { + const AUTH_TYPE = 'None'; + public static $hasError = false; + public static $hasException = false; + public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $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) { - + if (self::$hasException) + { + self::$hasException = false; + throw new \Exception("une erreur"); + } } 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() { - + $func = function($record) + { + return true; + }; + return $func; } 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) { - + 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() @@ -455,12 +480,26 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter 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(); } } diff --git a/templates/web/prod/actions/Bridge/Dailymotion/upload.twig b/templates/web/prod/actions/Bridge/Dailymotion/upload.twig index 8253429a2e..1ca32c9e27 100644 --- a/templates/web/prod/actions/Bridge/Dailymotion/upload.twig +++ b/templates/web/prod/actions/Bridge/Dailymotion/upload.twig @@ -34,7 +34,7 @@