mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge branch '3.8'
Conflicts: lib/Alchemy/Phrasea/Controller/Prod/Records.php lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php tests/Alchemy/Tests/Phrasea/Application/ApiTestCase.php tests/classes/PhraseanetPHPUnitAbstract.php
This commit is contained in:
@@ -268,7 +268,11 @@ class Users implements ControllerProviderInterface
|
||||
$datas['data'] = $user->get_id();
|
||||
} catch (\Exception $e) {
|
||||
$datas['error'] = true;
|
||||
$datas['message'] = $e->getMessage();
|
||||
if ($request->request->get('template') == '1') {
|
||||
$datas['message'] = _('Unable to create template, the name is already used.');
|
||||
} else {
|
||||
$datas['message'] = _('Unable to create the user.');
|
||||
}
|
||||
}
|
||||
|
||||
return $app->json($datas);
|
||||
|
||||
@@ -31,10 +31,6 @@ class Records implements ControllerProviderInterface
|
||||
|
||||
$app['firewall']->addMandatoryAuthentication($controllers);
|
||||
|
||||
$controllers->before(function (Request $request) use ($app) {
|
||||
$app['firewall']->requireNotGuest();
|
||||
});
|
||||
|
||||
$controllers->match('/', 'controller.prod.records:getRecord')
|
||||
->bind('record_details')
|
||||
->method('GET|POST');
|
||||
|
||||
@@ -427,7 +427,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$stmt->closeCursor();
|
||||
|
||||
$fields = [];
|
||||
if ($row && ($sx = simplexml_load_string($row['xml']))) {
|
||||
if ($row && ($sx = @simplexml_load_string($row['xml']))) {
|
||||
foreach ($sx->fields->children() as $fn => $fv) {
|
||||
if (!array_key_exists($fn, $fields)) {
|
||||
$fields[$fn] = [];
|
||||
@@ -462,7 +462,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $row) {
|
||||
if (!($sx = simplexml_load_string($row['xml']))) {
|
||||
if (!($sx = @simplexml_load_string($row['xml']))) {
|
||||
continue;
|
||||
}
|
||||
$t_desc = [];
|
||||
|
||||
@@ -593,9 +593,6 @@
|
||||
$(document).ready(function(){
|
||||
var dialog = p4.Dialog.get(1);
|
||||
var tabs = $('.tabs', dialog.getDomElement());
|
||||
if (tabs.data('ui-tabs')) {
|
||||
tabs.tabs('active',1);
|
||||
}
|
||||
|
||||
$('a.TOUview').bind('click', function(){
|
||||
var options = {
|
||||
@@ -658,9 +655,7 @@
|
||||
$('input[name="destmail"]', $('#sendmail')).val("{{app['authentication'].getUser().get_email()}}");
|
||||
|
||||
var tabs = $('.tabs', dialog.getDomElement());
|
||||
if (tabs.data('ui-tabs')) {
|
||||
tabs.tabs('active',1);
|
||||
}
|
||||
tabs.tabs("option", "active", 1);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -2104,7 +2104,11 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
||||
$this->assertArrayHasKey("label", $permalink);
|
||||
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $permalink['label']);
|
||||
$this->assertArrayHasKey("updated_on", $permalink);
|
||||
$this->assertEquals($subdef->get_permalink()->get_last_modified()->format(DATE_ATOM), $permalink['updated_on']);
|
||||
|
||||
$expected = $subdef->get_permalink()->get_last_modified();
|
||||
$found = \DateTime::createFromFormat(DATE_ATOM, $permalink['updated_on']);
|
||||
|
||||
$this->assertLessThanOrEqual(1, $expected->diff($found)->format('U'));
|
||||
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $permalink['updated_on']);
|
||||
$this->assertDateAtom($permalink['updated_on']);
|
||||
$this->assertArrayHasKey("page_url", $permalink);
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace Alchemy\Tests\Phrasea\Controller\Prod;
|
||||
|
||||
use Alchemy\Phrasea\Border\File;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||
use Entities\Basket;
|
||||
use Entities\BasketElement;
|
||||
|
||||
/**
|
||||
* @todo Test Alchemy\Phrasea\Controller\Prod\Export::exportMail
|
||||
@@ -73,6 +75,49 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testGetRecordDetailAsGuest()
|
||||
{
|
||||
$inviteUsrid = \User_Adapter::get_usr_id_from_login(self::$DI['app'], 'invite');
|
||||
$invite_user = \User_Adapter::getInstance($inviteUsrid, self::$DI['app']);
|
||||
|
||||
$this->authenticate(self::$DI['app'], $invite_user);
|
||||
|
||||
$basket = new Basket();
|
||||
$basket->setUsrId($inviteUsrid);
|
||||
$basket->setName('test');
|
||||
|
||||
self::$DI['app']['EM']->persist($basket);
|
||||
|
||||
$element = new BasketElement();
|
||||
$element->setRecord(self::$DI['record_24']);
|
||||
$element->setBasket($basket);
|
||||
$basket->addElement($element);
|
||||
|
||||
self::$DI['app']['EM']->persist($element);
|
||||
self::$DI['app']['EM']->flush();
|
||||
|
||||
$this->XMLHTTPRequest('POST', '/prod/records/', array(
|
||||
'env' => 'BASK',
|
||||
'pos' => 0,
|
||||
'query' => '',
|
||||
'cont' => $basket->getId(),
|
||||
));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertArrayHasKey('desc', $data);
|
||||
$this->assertArrayHasKey('html_preview', $data);
|
||||
$this->assertArrayHasKey('current', $data);
|
||||
$this->assertArrayHasKey('others', $data);
|
||||
$this->assertArrayHasKey('history', $data);
|
||||
$this->assertArrayHasKey('popularity', $data);
|
||||
$this->assertArrayHasKey('tools', $data);
|
||||
$this->assertArrayHasKey('pos', $data);
|
||||
$this->assertArrayHasKey('title', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||
*/
|
||||
|
||||
@@ -499,13 +499,16 @@ abstract class PhraseanetTestCase extends WebTestCase
|
||||
* Authenticates self::['user'] against application.
|
||||
*
|
||||
* @param Application $app
|
||||
* @param User_Adapter $user
|
||||
*/
|
||||
protected function authenticate(Application $app)
|
||||
protected function authenticate(Application $app, $user = null)
|
||||
{
|
||||
$user = $user ?: self::$DI['user'];
|
||||
|
||||
$app['session']->clear();
|
||||
$app['session']->set('usr_id', self::$DI['user']->get_id());
|
||||
$app['session']->set('usr_id', $user->get_id());
|
||||
$session = new Session();
|
||||
$session->setUsrId(self::$DI['user']->get_id());
|
||||
$session->setUsrId($user->get_id());
|
||||
$session->setUserAgent('');
|
||||
self::$DI['app']['EM']->persist($session);
|
||||
self::$DI['app']['EM']->flush();
|
||||
|
||||
Reference in New Issue
Block a user