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_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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();

View File

@@ -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']);

View File

@@ -102,11 +102,17 @@ 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)
{
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 */
$twig = $app['Core']->getTwig();
@@ -163,8 +169,6 @@ 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);
@@ -178,11 +182,6 @@ class Tooltip implements ControllerProviderInterface
, array('field' => $field)
)
);
}
catch (\Exception $e)
{
exit($e->getMessage());
}
})->assert('sbas_id', '\d+')->assert('field_id', '\d+');

View File

@@ -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()));

View File

@@ -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;

View File

@@ -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'))

View File

@@ -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;
/**

View File

@@ -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');
@@ -123,6 +131,7 @@ class MoveCollection extends RecordHelper
}
}
$collection = \collection::get_from_base_id($base_dest);
foreach ($this->selection as $record)

View File

@@ -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);

View File

@@ -77,8 +77,9 @@ class setup
$appConf->getServiceFile();
$installed = true;
}
catch(\Exception $e)
catch (\Exception $e)
{
}
return $installed;
}
@@ -89,7 +90,7 @@ class setup
&& 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());
}
@@ -814,6 +818,26 @@ class setup
}
try
{
$serviceFile = $appConf->getServiceFile();
unlink($serviceFile->getPathname());
}
catch (\Exception $e)
{
}
try
{
$connexionfFile = $appConf->getConnexionFile();
unlink($connexionfFile->getPathname());
}
catch (\Exception $e)
{
}
return;
}

View File

@@ -1,11 +1,7 @@
<?php
namespace Alchemy\Phrasea\Controller\Admin;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Admin/Fields.php';
/**
* Test class for Fields.
* 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__ . '/../../../../../Alchemy/Phrasea/Controller/Admin/Publications.php';
use Silex\WebTestCase;
use Symfony\Component\HttpFoundation\Response;

View File

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

View File

@@ -1,11 +1,7 @@
<?php
namespace Alchemy\Phrasea\Controller\Admin;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Admin/Users.php';
/**
* Test class for Users.
* 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__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/Basket.php';
use Alchemy\Phrasea\Helper;
use Alchemy\Phrasea\RouteProcessor as routeProcessor;

View File

@@ -12,6 +12,7 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
public static $account = null;
public static $api = null;
protected $client;
protected static $need_records = 1;
public static function setUpBeforeClass()
{
@@ -83,6 +84,14 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
$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()
{
$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());
}
}

View File

@@ -1,7 +1,5 @@
<?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
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
*/
protected $client;
/**
* If the controller tests require some records, specify it her
*
@@ -26,7 +25,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
* $need_records = 2;
*
*/
protected static $need_records = false;
protected static $need_records = 1;
/**
* The application loader
@@ -52,9 +51,20 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/
public function testRouteSlash()
{
$this->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());
}
}

View File

@@ -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);
}
}

View File

@@ -1,11 +1,7 @@
<?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/MoveCollection.php';
/**
* Test class for MoveCollection.
* 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
*/
protected $client;
/**
* If the controller tests require some records, specify it her
*
@@ -26,7 +23,7 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
* $need_records = 2;
*
*/
protected static $need_records = false;
protected static $need_records = 1;
/**
* The application loader
@@ -52,9 +49,21 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
*/
public function testRouteSlash()
{
$this->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());
}
}

View File

@@ -1,11 +1,7 @@
<?php
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/Printer.php';
/**
* Test class for Printer.
* 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
*/
protected $client;
/**
* If the controller tests require some records, specify it her
*
@@ -26,7 +23,7 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
* $need_records = 2;
*
*/
protected static $need_records = false;
protected static $need_records = 2;
/**
* The application loader
@@ -52,9 +49,43 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/
public function testRouteSlash()
{
$this->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());
}
}

View File

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

View File

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

View File

@@ -13,6 +13,7 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
protected $client;
protected static $need_records = 1;
protected static $need_subdefs = true;
protected static $need_story = 1;
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()
{
$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
namespace Alchemy\Phrasea\Controller\Prod;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Prod/UsrLists.php';
/**
* Test class for UsrLists.
* Generated by PHPUnit on 2012-01-11 at 18:24:30.

View File

@@ -55,7 +55,6 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->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();
}
@@ -105,7 +104,16 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
//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")
);
@@ -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
}
}

View File

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

View File

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

View File

@@ -1,11 +1,7 @@
<?php
namespace Alchemy\Phrasea\Controller\Utils;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
require_once __DIR__ . '/../../../../../Alchemy/Phrasea/Controller/Utils/ConnectionTest.php';
/**
* Test class for ConnectionTest.
* 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
*/
protected $client;
/**
* If the controller tests require some records, specify it her
*
@@ -50,11 +47,97 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
/**
* Default route test
*/
public function testRouteSlash()
public function testRouteMysql()
{
$this->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);
}
}

View File

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

View File

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

View File

@@ -38,9 +38,9 @@ class Bridge_AccountTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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());
}
}
@@ -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);
}

View File

@@ -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');
}
public function get_update_datas(Request $request)
return array();
}
elseif (self::$hasError)
{
self::$hasError = false;
return array('title' => 'too long');
}
}
public function get_update_datas(\Symfony\Component\HttpFoundation\Request $request)
{
return array();
}
}

View File

@@ -34,7 +34,7 @@
</div>
</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 />
{{ error_form.display_errors(name, constraint_errors) }}
</td>
@@ -48,7 +48,7 @@
</div>
</td>
<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 />
{{ error_form.display_errors(name, constraint_errors) }}
</td>
@@ -66,7 +66,7 @@
</div>
</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 />
{{ error_form.display_errors(name, constraint_errors) }}
</td>

View File

@@ -45,7 +45,7 @@
<label for='{{name}}'>{% trans 'Titre' %}</label>
</td>
<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 />
{{ error_form.display_errors(name, constraint_errors) }}
</td>
@@ -61,7 +61,7 @@
</label>
</td>
<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 />
{{ error_form.display_errors(name, constraint_errors) }}
</td>
@@ -74,7 +74,7 @@
<label for='{{ name }}'>{% trans 'Tags' %}</label>
</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 />
{{ error_form.display_errors(name, constraint_errors) }}
</td>

View File

@@ -34,7 +34,7 @@
</div>
</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 />
{{ error_form.display_errors(name, constraint_errors) }}
</label>
@@ -49,7 +49,7 @@
</div>
</td>
<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 />
{{ error_form.display_errors(name, constraint_errors) }}
</td>
@@ -78,7 +78,7 @@
</div>
</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 />
{{ error_form.display_errors(name, constraint_errors) }}
</td>