mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
Fix tests
This commit is contained in:
@@ -75,7 +75,7 @@ class ACLProvider
|
||||
*/
|
||||
private function hasCache(\User_Adapter $user)
|
||||
{
|
||||
return array_key_exists($user->get_id(), self::$cache) && self::$cache[$user->get_id()] instanceof \ACL;
|
||||
return isset(self::$cache[$user->get_id()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -210,7 +210,7 @@ class Feed implements ControllerProviderInterface
|
||||
$page = (int) $request->query->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
|
||||
$feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['authentication']->getUser());
|
||||
$feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($app['authentication']->getUser()));
|
||||
|
||||
$datas = $app['twig']->render('prod/feeds/feeds.html.twig', array(
|
||||
'feeds' => $feeds,
|
||||
|
@@ -78,7 +78,7 @@ class Upload implements ControllerProviderInterface
|
||||
return $app['twig']->render(
|
||||
'prod/upload/upload-flash.html.twig', array(
|
||||
'sessionId' => session_id(),
|
||||
'collections' => $this->getGrantedCollections($app['authentication']->getUser()),
|
||||
'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())),
|
||||
'maxFileSize' => $maxFileSize,
|
||||
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
||||
));
|
||||
@@ -98,7 +98,7 @@ class Upload implements ControllerProviderInterface
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/upload/upload.html.twig', array(
|
||||
'collections' => $this->getGrantedCollections($app['authentication']->getUser()),
|
||||
'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())),
|
||||
'maxFileSize' => $maxFileSize,
|
||||
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
||||
));
|
||||
@@ -269,14 +269,15 @@ class Upload implements ControllerProviderInterface
|
||||
/**
|
||||
* Get current user's granted collections where he can upload
|
||||
*
|
||||
* @param \User_Adapter $user
|
||||
* @param \ACL $acl The user's ACL.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getGrantedCollections(\User_Adapter $user)
|
||||
private function getGrantedCollections(\ACL $acl)
|
||||
{
|
||||
$collections = array();
|
||||
|
||||
foreach ($app['acl']->get($user)->get_granted_base(array('canaddrecord')) as $collection) {
|
||||
foreach ($acl->get_granted_base(array('canaddrecord')) as $collection) {
|
||||
$databox = $collection->get_databox();
|
||||
|
||||
if ( ! isset($collections[$databox->get_sbas_id()])) {
|
||||
|
@@ -130,7 +130,7 @@
|
||||
{% if usr.is_template() %}
|
||||
<img title="{% trans 'This is a template' %}" src="/skins/icons/template.png"/>
|
||||
{% else %}
|
||||
{% if app['acl'].get(usr.).is_phantom() %}
|
||||
{% if app['acl'].get(usr).is_phantom() %}
|
||||
<img title="{% trans 'This user has no rights' %}" src="/skins/admin/ghost.png"/>
|
||||
{% endif %}
|
||||
{{usr.get_id()}}
|
||||
|
@@ -97,7 +97,7 @@
|
||||
<div id="record_infos" class="PNB">
|
||||
<div class="lightbox_container PNB">
|
||||
{% if basket_element %}
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(basket_element.getRecord(app).get_base_id(), 'canmodifrecord') %}
|
||||
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(basket_element.getRecord(app).get_base_id(), 'canmodifrecord') %}
|
||||
{{caption.format_caption(basket_element.getRecord(app), '', null, business)}}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@@ -22,7 +22,7 @@
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
{% if app['acl'].get(app['authentication'].getUser()).has_right('deleterecord') and app['authentication'].getUser()).has_right('addrecord') %}
|
||||
{% if app['acl'].get(app['authentication'].getUser()).has_right('deleterecord') and app['acl'].get(app['authentication'].getUser()).has_right('addrecord') %}
|
||||
<button class="ui-corner-all TOOL_chgcoll_btn basket_window" title="{% trans 'action : collection' %}">
|
||||
<img src="/skins/prod/000000/images/chgcoll_history.gif"/>
|
||||
</button>
|
||||
|
@@ -21,7 +21,7 @@
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
{% if app['acl'].get(app['authentication'].getUser()).has_right('deleterecord') and app['authentication'].getUser()).has_right('addrecord') %}
|
||||
{% if app['acl'].get(app['authentication'].getUser()).has_right('deleterecord') and app['acl'].get(app['authentication'].getUser()).has_right('addrecord') %}
|
||||
<button class="ui-corner-all TOOL_chgcoll_btn story_window" title="{% trans 'action : collection' %}">
|
||||
<img src="/skins/prod/000000/images/chgcoll_history.gif"/>
|
||||
</button>
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<div style="text-align:center;">
|
||||
{{record.get_status_icons()|raw}}
|
||||
</div>
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
|
||||
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
|
||||
{% if record.is_from_reg() %}
|
||||
{{caption.format_caption(record, '', null, business)}}
|
||||
{% else %}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
<div class="printer" title="'{% trans 'action : print' %}"
|
||||
onclick="evt_print('{{record.get_sbas_id()}}_{{record.get_record_id()}}');return(false);"></div>
|
||||
|
||||
{% if app['authentication'].getUser().ACL().has_right_on_base(record.get_base_id(), 'candwnldhd') or app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'candwnldpreview') %}
|
||||
{% if app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'candwnldhd') or app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'candwnldpreview') %}
|
||||
<div class="downloader" title="{% trans 'action : exporter' %}"
|
||||
onclick="evt_dwnl('{{record.get_sbas_id()}}_{{record.get_record_id()}}');return(false);"></div>
|
||||
{% endif %}
|
||||
|
@@ -31,8 +31,6 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
'email' => 'sent'
|
||||
));
|
||||
|
||||
var_dump(self::$DI['client']->getResponse()->getContent());
|
||||
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$crawler = self::$DI['client']->request('POST', '/prod/feeds/requestavailable/');
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
$feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['user']);
|
||||
$feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['app']['acl']->get(self::$DI['user']));
|
||||
foreach ($feeds as $one_feed) {
|
||||
if ($one_feed->isPublisher(self::$DI['user'])) {
|
||||
$this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $one_feed->getId() . "' and @name='feed_proposal[]']")->count());
|
||||
@@ -369,17 +369,15 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
public function testRoot()
|
||||
{
|
||||
|
||||
$crawler = self::$DI['client']->request('GET', '/prod/feeds/');
|
||||
|
||||
$pageContent = self::$DI['client']->getResponse()->getContent();
|
||||
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
|
||||
$feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['user']);
|
||||
$feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['app']['acl']->get(self::$DI['user']));
|
||||
|
||||
foreach ($feeds as $one_feed) {
|
||||
|
||||
$path = CssSelector::toXPath("ul.submenu a[href='/prod/feeds/feed/" . $one_feed->getId() . "/']");
|
||||
$msg = sprintf("user %s has access to feed %s", self::$DI['user']->getId(), $one_feed->getId());
|
||||
|
||||
@@ -396,7 +394,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$feed = $this->insertOneFeed(self::$DI['user']);
|
||||
|
||||
$feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['user']);
|
||||
$feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['app']['acl']->get(self::$DI['user']));
|
||||
|
||||
$crawler = self::$DI['client']->request('GET', '/prod/feeds/feed/' . $feed->getId() . "/");
|
||||
$pageContent = self::$DI['client']->getResponse()->getContent();
|
||||
|
@@ -77,10 +77,10 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$data = DataUri\Data::buildFromFile(__DIR__ . '/../../../../../files/cestlafete.jpg');
|
||||
$data = DataURI\Data::buildFromFile(__DIR__ . '/../../../../../files/cestlafete.jpg');
|
||||
$params = array(
|
||||
'base_id' => self::$DI['collection']->get_base_id(),
|
||||
'b64_image' => DataUri\Dumper::dump($data)
|
||||
'b64_image' => DataURI\Dumper::dump($data)
|
||||
);
|
||||
|
||||
$files = array(
|
||||
|
@@ -9,12 +9,6 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
*/
|
||||
protected static $object;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
self::$object = self::$DI['app']['acl']->get(self::$DI['user']);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
/**
|
||||
@@ -43,6 +37,15 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
parent::tearDownAfterClass();
|
||||
}
|
||||
|
||||
public function setup()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (null === self::$object) {
|
||||
self::$object = self::$DI['app']['acl']->get(self::$DI['user']);
|
||||
}
|
||||
}
|
||||
|
||||
public function testHasAccesToRecord()
|
||||
{
|
||||
$this->assertTrue(self::$object->has_status_access_to_record(self::$DI['record_1']));
|
||||
|
@@ -677,7 +677,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
$feedItem = $this->insertOneFeedItem(self::$DI['user']);
|
||||
$feed = $feedItem->getEntry()->getFeed();
|
||||
|
||||
$feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['user']);
|
||||
$feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['app']['acl']->get(self::$DI['user']));
|
||||
foreach ($feeds as $feed) {
|
||||
$result = $this->object->get_publication($request, $feed->getId(), self::$DI['user']);
|
||||
$this->checkResponseField($result, "feed", 'array');
|
||||
|
Reference in New Issue
Block a user