Replaced remaining occurrences of Feed_ classes, updated tests

This commit is contained in:
Andrey
2013-06-12 17:54:36 +02:00
parent 9a5baff4a0
commit 84300f3c92
33 changed files with 310 additions and 296 deletions

View File

@@ -62,7 +62,7 @@ class Publications implements ControllerProviderInterface
$feed->setIconUrl(false); $feed->setIconUrl(false);
if ($request->request->get('public') == '1') { if ($request->request->get('public') == '1') {
$feed->setPublic(true); $feed->setIsPublic(true);
} elseif ($request->request->get('base_id')) { } elseif ($request->request->get('base_id')) {
$feed->setCollection(\collection::get_from_base_id($app, $request->request->get('base_id'))); $feed->setCollection(\collection::get_from_base_id($app, $request->request->get('base_id')));
} }
@@ -102,7 +102,7 @@ class Publications implements ControllerProviderInterface
$feed->setSubtitle($subtitle); $feed->setSubtitle($subtitle);
} }
$feed->setCollection($collection); $feed->setCollection($collection);
$feed->setPublic($request->request->get('public') === '1' ? true : false); $feed->setIsPublic($request->request->get('public') === '1' ? true : false);
$app['EM']->persist($feed); $app['EM']->persist($feed);
$app['EM']->flush(); $app['EM']->flush();

View File

@@ -161,12 +161,12 @@ class Lightbox implements ControllerProviderInterface
$controllers->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(SilexApplication $app, $entry_id, $item_id) { $controllers->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(SilexApplication $app, $entry_id, $item_id) {
$entry = $app['EM']->getRepository('Entities\FeedEntry')->find($entry_id); $entry = $app['EM']->getRepository('Entities\FeedEntry')->find($entry_id);
$item = $entry->getItems()->getItem($item_id); $item = $entry->getItem($item_id);
if ($app['browser']->isMobile()) { if ($app['browser']->isMobile()) {
$output = $app['twig']->render('lightbox/feed_element.html.twig', array( $output = $app['twig']->render('lightbox/feed_element.html.twig', array(
'feed_element' => $item, 'feed_element' => $item,
'module_name' => $item->getRecord()->get_title() 'module_name' => $item->getRecord($app)->get_title()
) )
); );
@@ -181,12 +181,12 @@ class Lightbox implements ControllerProviderInterface
} }
$ret = array(); $ret = array();
$ret['number'] = $item->get_record()->get_number(); $ret['number'] = $item->getRecord($app)->get_number();
$ret['title'] = $item->get_record()->get_title(); $ret['title'] = $item->getRecord($app)->get_title();
$ret['preview'] = $app['twig']->render($template_preview, array('record' => $item->get_record(), 'not_wrapped' => true)); $ret['preview'] = $app['twig']->render($template_preview, array('record' => $item->getRecord($app), 'not_wrapped' => true));
$ret['options_html'] = $app['twig']->render($template_options, array('feed_element' => $item)); $ret['options_html'] = $app['twig']->render($template_options, array('feed_element' => $item));
$ret['caption'] = $app['twig']->render($template_caption, array('view' => 'preview', 'record' => $item->get_record())); $ret['caption'] = $app['twig']->render($template_caption, array('view' => 'preview', 'record' => $item->getRecord($app)));
$ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = ''; $ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = '';
@@ -313,7 +313,7 @@ class Lightbox implements ControllerProviderInterface
return $app->redirectPath('logout'); return $app->redirectPath('logout');
} }
$feed_entry = $app['EM']->getEntity('Entities\FeedEntry')->find($entry_id); $feed_entry = $app['EM']->getRepository('Entities\FeedEntry')->find($entry_id);
$template = 'lightbox/feed.html.twig'; $template = 'lightbox/feed.html.twig';
@@ -322,10 +322,11 @@ class Lightbox implements ControllerProviderInterface
} }
$content = $feed_entry->getItems(); $content = $feed_entry->getItems();
$first = $content->first();
$output = $app['twig']->render($template, array( $output = $app['twig']->render($template, array(
'feed_entry' => $feed_entry, 'feed_entry' => $feed_entry,
'first_item' => array_shift($content), 'first_item' => $first,
'local_title' => $feed_entry->getTitle(), 'local_title' => $feed_entry->getTitle(),
'module' => 'lightbox', 'module' => 'lightbox',
'module_name' => _('admin::monitor: module validation') 'module_name' => _('admin::monitor: module validation')

View File

@@ -36,7 +36,7 @@ class RSSFeeds implements ControllerProviderInterface
$app->abort(404, 'Feed not found'); $app->abort(404, 'Feed not found');
} }
if (!$feed->getPublic()) { if (!$feed->isPublic()) {
$app->abort(403, 'Forbidden'); $app->abort(403, 'Forbidden');
} }
@@ -110,7 +110,7 @@ class RSSFeeds implements ControllerProviderInterface
$page = (int) $request->query->get('page'); $page = (int) $request->query->get('page');
$page = $page < 1 ? 1 : $page; $page = $page < 1 ? 1 : $page;
return $app[$this->getFormater('cooliris')]->createResponse($feed, $page); return $app[$this->getFormater('cooliris')]->createResponse($feed, $page, null, 'Phraseanet', $app);
}) })
->bind('feed_public_cooliris'); ->bind('feed_public_cooliris');

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Feed\Formatter; namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Feed\FeedInterface; use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Feed\Link\FeedLink; use Alchemy\Phrasea\Feed\Link\FeedLink;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection; use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
@@ -34,7 +35,7 @@ class AtomFormatter extends FeedFormatterAbstract implements FeedFormatterInterf
return $response; return $response;
} }
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet') public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null)
{ {
$title = $feed->getTitle(); $title = $feed->getTitle();
$subtitle = $feed->getSubtitle(); $subtitle = $feed->getSubtitle();

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Feed\Formatter; namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Feed\FeedInterface; use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection; use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -26,15 +27,15 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
$this->linkGenerator = $generator; $this->linkGenerator = $generator;
} }
public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet') public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null)
{ {
$content = $this->format($feed, $page, $user, $generator); $content = $this->format($feed, $page, $user, $generator, $app);
$response = new Response($content, 200, array('Content-Type' => 'application/rss+xml')); $response = new Response($content, 200, array('Content-Type' => 'application/rss+xml'));
$response->setCharset('UTF-8'); $response->setCharset('UTF-8');
return $response; return $response;
} }
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet') public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null)
{ {
$title = $feed->getTitle(); $title = $feed->getTitle();
$subtitle = $feed->getSubtitle(); $subtitle = $feed->getSubtitle();
@@ -158,28 +159,28 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
} }
foreach ($feed->getEntries() as $item) { foreach ($feed->getEntries() as $item) {
$this->addItem($doc, $channel, $item); $this->addItem($app, $doc, $channel, $item);
} }
return $doc->saveXML(); return $doc->saveXML();
} }
protected function addItem(\DOMDocument $document, \DOMNode $feed, FeedEntry $entry) protected function addItem(Application $app, \DOMDocument $document, \DOMNode $feed, FeedEntry $entry)
{ {
foreach ($entry->get_content() as $content) { foreach ($entry->get_content() as $content) {
$this->addContent($document, $feed, $entry, $content); $this->addContent($app, $document, $feed, $entry, $content);
} }
} }
protected function addContent(\DOMDocument $document, \DOMNode $node, FeedItem $content) protected function addContent(Application $app, \DOMDocument $document, \DOMNode $node, FeedItem $content)
{ {
$preview_sd = $content->getRecord()->get_subdef('preview'); $preview_sd = $content->getRecord($app)->get_subdef('preview');
$preview_permalink = $preview_sd->get_permalink(); $preview_permalink = $preview_sd->get_permalink();
$thumbnail_sd = $content->getRecord()->get_thumbnail(); $thumbnail_sd = $content->getRecord($app)->get_thumbnail();
$thumbnail_permalink = $thumbnail_sd->get_permalink(); $thumbnail_permalink = $thumbnail_sd->get_permalink();
$medium = strtolower($content->getRecord()->get_type()); $medium = strtolower($content->getRecord($app)->get_type());
if ( ! in_array($medium, array('image', 'audio', 'video'))) { if ( ! in_array($medium, array('image', 'audio', 'video'))) {
return $this; return $this;
@@ -192,13 +193,13 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
//add item node to channel node //add item node to channel node
$item = $this->addTag($document, $node, 'item'); $item = $this->addTag($document, $node, 'item');
$caption = $content->getRecord()->get_caption(); $caption = $content->getRecord($app)->get_caption();
$title_field = $caption->get_dc_field(databox_Field_DCESAbstract::Title); $title_field = $caption->get_dc_field(databox_Field_DCESAbstract::Title);
if ($title_field) { if ($title_field) {
$str_title = $title_field->get_serialized_values(' '); $str_title = $title_field->get_serialized_values(' ');
} else { } else {
$str_title = $content->getRecord()->get_title(); $str_title = $content->getRecord($app)->get_title();
} }
//attach tile node to item node //attach tile node to item node
@@ -214,7 +215,7 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
//attach desc node to item node //attach desc node to item node
$desc = $this->addTag($document, $item, 'description', $str_desc); $desc = $this->addTag($document, $item, 'description', $str_desc);
$duration = $content->getRecord()->get_duration(); $duration = $content->getRecord($app)->get_duration();
if ($preview_permalink) { if ($preview_permalink) {
$preview = $this->addTag($document, $item, 'media:content'); $preview = $this->addTag($document, $item, 'media:content');

View File

@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Feed\Formatter; namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
abstract class FeedFormatterAbstract abstract class FeedFormatterAbstract
{ {
const PAGE_SIZE = 20; const PAGE_SIZE = 20;
@@ -41,14 +43,14 @@ abstract class FeedFormatterAbstract
* @param FeedItem $content * @param FeedItem $content
* @return FeedFormaterInterface * @return FeedFormaterInterface
*/ */
protected function addContent(\DOMDocument $document, \DOMNode $item, FeedItem $content) protected function addContent(Application $app, \DOMDocument $document, \DOMNode $item, FeedItem $content)
{ {
$preview_sd = $content->getRecord()->get_subdef('preview'); $preview_sd = $content->getRecord($app)->get_subdef('preview');
$preview_permalink = $preview_sd->get_permalink(); $preview_permalink = $preview_sd->get_permalink();
$thumbnail_sd = $content->getRecord()->get_thumbnail(); $thumbnail_sd = $content->getRecord($app)->get_thumbnail();
$thumbnail_permalink = $thumbnail_sd->get_permalink(); $thumbnail_permalink = $thumbnail_sd->get_permalink();
$medium = strtolower($content->getRecord()->get_type()); $medium = strtolower($content->getRecord($app)->get_type());
if ( ! in_array($medium, array('image', 'audio', 'video'))) { if ( ! in_array($medium, array('image', 'audio', 'video'))) {
return $this; return $this;
@@ -60,7 +62,7 @@ abstract class FeedFormatterAbstract
$group = $this->addTag($document, $item, 'media:group'); $group = $this->addTag($document, $item, 'media:group');
$caption = $content->getRecord()->get_caption(); $caption = $content->getRecord($app)->get_caption();
$title_field = $caption->get_dc_field(databox_Field_DCESAbstract::Title); $title_field = $caption->get_dc_field(databox_Field_DCESAbstract::Title);
if ($title_field) { if ($title_field) {

View File

@@ -16,5 +16,5 @@ interface FeedFormatterInterface
* *
* @return string * @return string
*/ */
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet'); public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null);
} }

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Feed\Formatter; namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Feed\FeedInterface; use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Feed\Link\FeedLink; use Alchemy\Phrasea\Feed\Link\FeedLink;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection; use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
@@ -35,7 +36,7 @@ class RssFormatter extends FeedFormatterAbstract implements FeedFormatterInterfa
return $response; return $response;
} }
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet') public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null)
{ {
$title = $feed->getTitle(); $title = $feed->getTitle();
$subtitle = $feed->getSubtitle(); $subtitle = $feed->getSubtitle();

View File

@@ -91,7 +91,7 @@ class Feed implements FeedInterface
* @param boolean $public * @param boolean $public
* @return Feed * @return Feed
*/ */
public function setPublic($public) public function setIsPublic($public)
{ {
$this->public = $public; $this->public = $public;
@@ -103,7 +103,7 @@ class Feed implements FeedInterface
* *
* @return boolean * @return boolean
*/ */
public function getPublic() public function isPublic()
{ {
return $this->public; return $this->public;
} }

View File

@@ -2,7 +2,7 @@
namespace Entities; namespace Entities;
use Doctrine\ORM\Mapping as ORM; use Alchemy\Phrasea\Application;
/** /**
* FeedItem * FeedItem
@@ -196,4 +196,9 @@ class FeedItem
{ {
$this->setOrd($this->getEntry()->getItems()->count() + 1); $this->setOrd($this->getEntry()->getItems()->count() + 1);
} }
public function getRecord(Application $app)
{
return new \record_adapter($app, $this->getSbasId(), $this->getRecordId(), $this->getOrd());
}
} }

View File

@@ -57,7 +57,7 @@ class SessionRepository extends EntityRepository
$feed = $this->find($id); $feed = $this->find($id);
if ($feed) { if ($feed) {
$coll = $feed->getCollection($app); $coll = $feed->getCollection($app);
if ($feed->getPublic() if ($feed->isPublic()
|| $coll === null || $coll === null
|| in_array($coll->get_base_id(), array_keys($user->ACL()->get_granted_base()))) { || in_array($coll->get_base_id(), array_keys($user->ACL()->get_granted_base()))) {
return $feed; return $feed;

View File

@@ -9,11 +9,16 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Feed\Aggregate;
use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Border\Attribute\Status; use Alchemy\Phrasea\Border\Attribute\Status;
use Alchemy\Phrasea\Border\Manager as BorderManager; use Alchemy\Phrasea\Border\Manager as BorderManager;
use Entities\Feed;
use Entities\FeedEntry;
use Entities\FeedItem;
use Entities\UserQuery; use Entities\UserQuery;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -1479,10 +1484,10 @@ class API_V1_adapter extends API_V1_Abstract
{ {
$result = new API_V1_result($this->app, $request, $this); $result = new API_V1_result($this->app, $request, $this);
$coll = Feed_Collection::load_all($this->app, $user); $coll = $this->app['EM']->getRepository('Entities\Feed')->getAllForUser($user);
$datas = array(); $datas = array();
foreach ($coll->get_feeds() as $feed) { foreach ($coll as $feed) {
$datas[] = $this->list_publication($feed, $user); $datas[] = $this->list_publication($feed, $user);
} }
@@ -1512,7 +1517,7 @@ class API_V1_adapter extends API_V1_Abstract
{ {
$result = new API_V1_result($this->app, $request, $this); $result = new API_V1_result($this->app, $request, $this);
$feed = Feed_Adapter::load_with_user($this->app, $user, $publication_id); $feed = $this->app['EM']->getRepository('Entities\Feed')->loadWithUser($this->app, $user, $publication_id);
$offset_start = (int) ($request->get('offset_start') ? : 0); $offset_start = (int) ($request->get('offset_start') ? : 0);
$per_page = (int) ($request->get('per_page') ? : 5); $per_page = (int) ($request->get('per_page') ? : 5);
@@ -1535,7 +1540,7 @@ class API_V1_adapter extends API_V1_Abstract
{ {
$result = new API_V1_result($this->app, $request, $this); $result = new API_V1_result($this->app, $request, $this);
$feed = Feed_Aggregate::load_with_user($this->app, $user); $feed = Aggregate::createFromUser($this->app['EM'], $user);
$offset_start = (int) ($request->get('offset_start') ? : 0); $offset_start = (int) ($request->get('offset_start') ? : 0);
$per_page = (int) ($request->get('per_page') ? : 5); $per_page = (int) ($request->get('per_page') ? : 5);
@@ -1543,7 +1548,7 @@ class API_V1_adapter extends API_V1_Abstract
$per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5; $per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5;
$datas = array( $datas = array(
'total_entries' => $feed->get_count_total_entries(), 'total_entries' => $feed->getCountTotalEntries(),
'offset_start' => $offset_start, 'offset_start' => $offset_start,
'per_page' => $per_page, 'per_page' => $per_page,
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page), 'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
@@ -1558,9 +1563,9 @@ class API_V1_adapter extends API_V1_Abstract
{ {
$result = new API_V1_result($this->app, $request, $this); $result = new API_V1_result($this->app, $request, $this);
$entry = Feed_Entry_Adapter::load_from_id($this->app, $entry_id); $entry = $this->app['EM']->getRepository('Entities\FeedEntry')->find($entry_id);
$collection = $entry->get_feed()->get_collection(); $collection = $entry->getFeed()->getCollection($this->app);
if (null !== $collection && !$user->ACL()->has_access_to_base($collection->get_base_id())) { if (null !== $collection && !$user->ACL()->has_access_to_base($collection->get_base_id())) {
throw new \API_V1_exception_forbidden('You have not access to the parent feed'); throw new \API_V1_exception_forbidden('You have not access to the parent feed');
@@ -1578,38 +1583,38 @@ class API_V1_adapter extends API_V1_Abstract
/** /**
* Retrieve detailled informations about one feed * Retrieve detailled informations about one feed
* *
* @param Feed_Adapter $feed * @param Feed $feed
* @param type $user * @param type $user
* @return array * @return array
*/ */
protected function list_publication(Feed_Adapter $feed, $user) protected function list_publication(Feed $feed, $user)
{ {
return array( return array(
'id' => $feed->get_id(), 'id' => $feed->getId(),
'title' => $feed->get_title(), 'title' => $feed->getTitle(),
'subtitle' => $feed->get_subtitle(), 'subtitle' => $feed->getSubtitle(),
'total_entries' => $feed->get_count_total_entries(), 'total_entries' => $feed->getCountTotalEntries(),
'icon' => $feed->get_icon_url(), 'icon' => $feed->getIconUrl(),
'public' => $feed->is_public(), 'public' => $feed->isPublic(),
'readonly' => !$feed->is_publisher($user), 'readonly' => !$feed->isPublisher($user),
'deletable' => $feed->is_owner($user), 'deletable' => $feed->isOwner($user),
'created_on' => $feed->get_created_on()->format(DATE_ATOM), 'created_on' => $feed->getCreatedOn()->format(DATE_ATOM),
'updated_on' => $feed->get_updated_on()->format(DATE_ATOM), 'updated_on' => $feed->getUpdatedOn()->format(DATE_ATOM),
); );
} }
/** /**
* Retrieve all entries of one feed * Retrieve all entries of one feed
* *
* @param Feed_Adapter $feed * @param FeedInterface $feed
* @param int $offset_start * @param int $offset_start
* @param int $how_many * @param int $how_many
* @return array * @return array
*/ */
protected function list_publications_entries(Feed_Abstract $feed, $offset_start = 0, $how_many = 5) protected function list_publications_entries(FeedInterface $feed, $offset_start = 0, $how_many = 5)
{ {
$entries = $feed->get_entries($offset_start, $how_many)->get_entries(); $entries = $feed->getEntries($offset_start, $how_many);
$out = array(); $out = array();
foreach ($entries as $entry) { foreach ($entries as $entry) {
@@ -1622,42 +1627,42 @@ class API_V1_adapter extends API_V1_Abstract
/** /**
* Retrieve detailled information about one feed entry * Retrieve detailled information about one feed entry
* *
* @param Feed_Entry_Adapter $entry * @param FeedEntry $entry
* @return array * @return array
*/ */
protected function list_publication_entry(Feed_Entry_Adapter $entry) protected function list_publication_entry(FeedEntry $entry)
{ {
$items = array(); $items = array();
foreach ($entry->get_content() as $item) { foreach ($entry->getItems() as $item) {
$items[] = $this->list_publication_entry_item($item); $items[] = $this->list_publication_entry_item($item);
} }
return array( return array(
'id' => $entry->get_id(), 'id' => $entry->getId(),
'author_email' => $entry->get_author_email(), 'author_email' => $entry->getAuthorEmail(),
'author_name' => $entry->get_author_name(), 'author_name' => $entry->getAuthorName(),
'created_on' => $entry->get_created_on()->format(DATE_ATOM), 'created_on' => $entry->getCreatedOn()->format(DATE_ATOM),
'updated_on' => $entry->get_updated_on()->format(DATE_ATOM), 'updated_on' => $entry->getUpdatedOn()->format(DATE_ATOM),
'title' => $entry->get_title(), 'title' => $entry->getTitle(),
'subtitle' => $entry->get_subtitle(), 'subtitle' => $entry->getSubtitle(),
'items' => $items, 'items' => $items,
'feed_id' => $entry->get_feed()->get_id(), 'feed_id' => $entry->getFeed()->getId(),
'feed_url' => '/feeds/' . $entry->get_feed()->get_id() . '/content/', 'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/',
'url' => '/feeds/entry/' . $entry->get_id() . '/', 'url' => '/feeds/entry/' . $entry->getId() . '/',
); );
} }
/** /**
* Retrieve detailled informations about one feed entry item * Retrieve detailled informations about one feed entry item
* *
* @param Feed_Entry_Item $item * @param FeedItem $item
* @return array * @return array
*/ */
protected function list_publication_entry_item(Feed_Entry_Item $item) protected function list_publication_entry_item(FeedItem $item)
{ {
$datas = array( $datas = array(
'item_id' => $item->get_id() 'item_id' => $item->getId()
, 'record' => $this->list_record($item->get_record()) , 'record' => $this->list_record($item->getRecord($this->app))
); );
return $datas; return $datas;

View File

@@ -140,7 +140,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
$sx = simplexml_load_string($datas); $sx = simplexml_load_string($datas);
try { try {
$entry = $this->app['EM']->getRepository("Entities\FeedEntry")->find((int) $sx->entry_id); $entry = $this->app['EM']->getRepository('Entities\FeedEntry')->find((int) $sx->entry_id);
} catch (\Exception $e) { } catch (\Exception $e) {
return array(); return array();
} }

View File

@@ -175,30 +175,30 @@ class record_preview extends record_adapter
} }
break; break;
case "FEED": case "FEED":
$entry = Feed_Entry_Adapter::load_from_id($app, $contId); $entry = $app['EM']->getRepository('Entities\FeedEntry')->find($contId);
$this->container = $entry; $this->container = $entry;
$this->total = count($entry->get_content()); $this->total = count($entry->getItems());
$i = 0; $i = 0;
$first = true; $first = true;
foreach ($entry->get_content() as $element) { foreach ($entry->getItems() as $element) {
$i ++; $i ++;
if ($first) { if ($first) {
$sbas_id = $element->get_record()->get_sbas_id(); $sbas_id = $element->getRecord()->get_sbas_id();
$record_id = $element->get_record()->get_record_id(); $record_id = $element->getRecord()->get_record_id();
$this->original_item = $element; $this->original_item = $element;
$this->name = $entry->get_title(); $this->name = $entry->getTitle();
$number = $element->get_ord(); $number = $element->getOrd();
} }
$first = false; $first = false;
if ($element->get_ord() == $pos) { if ($element->getOrd() == $pos) {
$sbas_id = $element->get_record()->get_sbas_id(); $sbas_id = $element->getRecord()->get_sbas_id();
$record_id = $element->get_record()->get_record_id(); $record_id = $element->getRecord()->get_record_id();
$this->original_item = $element; $this->original_item = $element;
$this->name = $entry->get_title(); $this->name = $entry->getTitle();
$number = $element->get_ord(); $number = $element->getOrd();
} }
} }
break; break;

View File

@@ -0,0 +1,95 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhraseaFixture\Feed;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Entities\Feed;
class LoadOneFeed extends AbstractFixture implements FixtureInterface
{
/**
*
* @var \Entities\Feed
*/
public $feed;
public $user;
public $title;
public $public;
public function load(ObjectManager $manager)
{
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new feed');
}
$feed = new Feed();
$publisher = new \Entities\FeedPublisher();
$publisher->setUsrId($this->user->get_id());
$publisher->setIsOwner(true);
$publisher->setFeed($feed);
$feed->addPublisher($publisher);
if (isset($this->title) && $this->title !== null) {
$feed->setTitle($this->title);
}
else {
$feed->setTitle("test");
}
if (isset($this->public) && $this->public !== null) {
$feed->setIsPublic($this->public);
}
$feed->setSubtitle("description");
$manager->persist($feed);
$manager->persist($publisher);
$manager->flush();
$this->feed = $feed;
$this->addReference('one-feed', $feed);
}
public function setUser(\User_Adapter $user)
{
$this->user = $user;
}
public function getUser()
{
return $this->user;
}
public function setTitle($title)
{
$this->title = $title;
}
public function getTitle()
{
return $this->title;
}
public function setPublic($public)
{
$this->public = $public;
}
public function getPublic()
{
return $this->public;
}
}

View File

@@ -12,26 +12,26 @@
{% block content %} {% block content %}
<div id="home" data-role="page"> <div id="home" data-role="page">
<div data-role="header"> <div data-role="header">
<h1>{{feed_entry.get_title()}}</h1> <h1>{{feed_entry.getTitle()}}</h1>
<a rel="external" href="{{ path('lightbox') }}" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">{% trans 'Home' %}</a> <a rel="external" href="{{ path('lightbox') }}" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">{% trans 'Home' %}</a>
</div> </div>
<div data-role="content"> <div data-role="content">
<p> <p>
{{feed_entry.get_subtitle()|nl2br|raw}} {{feed_entry.getSubtitle()|nl2br|raw}}
</p> </p>
<p> <p>
{% set author = feed_entry.get_author_name() %} {% set author = feed_entry.getAuthorName() %}
<span class="author">{% trans %}Par {{ author }}{% endtrans %}</span> <span class="author">{% trans %}Par {{ author }}{% endtrans %}</span>
{% set entry_length = feed_entry.get_content()|length %} {% set entry_length = feed_entry.getItems()|length %}
{% trans %}{{entry_length}} documents{% endtrans %} {% trans %}{{entry_length}} documents{% endtrans %}
</p> </p>
<ul class="image_set"> <ul class="image_set">
{% for item in feed_entry.get_content() %} {% for item in feed_entry.getItems() %}
<li class="image_box" id="item_{{item.get_id()}}"> <li class="image_box" id="item_{{item.getId()}}">
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.get_id(), 'item_id' : item.get_id()}) }}"> <a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : item.getId()}) }}">
{{thumbnail.format(item.get_record().get_thumbnail(), 80, 80, '', true, false)}} {{thumbnail.format(item.getRecord().get_thumbnail(), 80, 80, '', true, false)}}
</a> </a>
<input type="hidden" class="display_id" name="display_id" value="{{item.get_ord()}}" /> <input type="hidden" class="display_id" name="display_id" value="{{item.getOrd()}}" />
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@@ -11,11 +11,11 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% set record = feed_element.get_record() %} {% set record = feed_element.getRecord(app) %}
<div data-role="page"> <div data-role="page">
<div data-role="header"> <div data-role="header">
<a href="{{ path('lightbox_feed_entry', { 'entry_id' : feed_element.get_entry().get_id() }) }}" data-rel="back" data-icon="arrow-l">Back</a> <a href="{{ path('lightbox_feed_entry', { 'entry_id' : feed_element.getEntry().getId() }) }}" data-rel="back" data-icon="arrow-l">Back</a>
<h1>{{feed_element.get_ord()}} - {{record.get_title()}}</h1> <h1>{{feed_element.getOrd()}} - {{record.getTitle()}}</h1>
<a rel="external" href="{{ path('lightbox') }}" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a> <a rel="external" href="{{ path('lightbox') }}" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
</div> </div>
<div data-role="content"> <div data-role="content">

View File

@@ -99,7 +99,7 @@
<div class="control-group"> <div class="control-group">
<label class="control-label" for="edit_pub_base_id">{% trans 'Etendue de la publication' %} :</label> <label class="control-label" for="edit_pub_base_id">{% trans 'Etendue de la publication' %} :</label>
<div class="controls"> <div class="controls">
<select id="edit_pub_base_id" class="input-large" name="base_id" {% if feed.getPublic() %}disabled="disabled"{% endif %}> <select id="edit_pub_base_id" class="input-large" name="base_id" {% if feed.isPublic() %}disabled="disabled"{% endif %}>
<option value="">{% trans 'Non-Restreinte (publique)' %}</option> <option value="">{% trans 'Non-Restreinte (publique)' %}</option>
{% for databox in app['authentication'].getUser().ACL().get_granted_sbas('bas_chupub') %} {% for databox in app['authentication'].getUser().ACL().get_granted_sbas('bas_chupub') %}
<optgroup label="{{ databox.get_label(app['locale.I18n']) }}"> <optgroup label="{{ databox.get_label(app['locale.I18n']) }}">
@@ -114,7 +114,7 @@
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<label class="checkbox" for="edit_pub_public"> <label class="checkbox" for="edit_pub_public">
<input type="checkbox" id="edit_pub_public" class="input-large" name="public" value="1" {% if feed.getPublic() %}checked="checked"{% endif %} /> <input type="checkbox" id="edit_pub_public" class="input-large" name="public" value="1" {% if feed.isPublic() %}checked="checked"{% endif %} />
{% trans 'Publique' %} {% trans 'Publique' %}
</label> </label>
</div> </div>

View File

@@ -85,7 +85,7 @@
{% endif %} {% endif %}
</td> </td>
<td valign="center" align="center"> <td valign="center" align="center">
{% if feed.getPublic() %} {% if feed.isPublic() %}
<img src="/skins/icons/ligth-on.png" title="{% trans 'This feed is public' %}"/> <img src="/skins/icons/ligth-on.png" title="{% trans 'This feed is public' %}"/>
{% endif %} {% endif %}
</td> </td>

View File

@@ -18,11 +18,11 @@
<tr valign="middle"> <tr valign="middle">
<td style="width:10px;"></td> <td style="width:10px;"></td>
<td style="width:35px;text-align:center;"> <td style="width:35px;text-align:center;">
<div class="display_id">{% if first_item %}{{first_item.get_ord()}}{% endif %}</div> <div class="display_id">{% if first_item %}{{first_item.getOrd()}}{% endif %}</div>
</td> </td>
<td style="text-align:left;width:auto;"> <td style="text-align:left;width:auto;">
<div class="title title15" title="{% if first_item %}{{first_item.get_record().get_title|e}}{% endif %}"> <div class="title title15" title="{% if first_item %}{{first_item.getRecord(app).get_title|e}}{% endif %}">
{% if first_item %}{{first_item.get_record().get_title}}{% endif %} {% if first_item %}{{first_item.getRecord(app).get_title}}{% endif %}
</div> </div>
</td> </td>
<td style="text-align:right;width:230px;"> <td style="text-align:right;width:230px;">
@@ -34,10 +34,10 @@
</div> </div>
<div class="lightbox_container left"> <div class="lightbox_container left">
{% if first_item %} {% if first_item %}
{% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.get_record(), 'preview') %} {% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.getRecord(app), 'preview') %}
{% set preview = first_item.get_record().get_preview() %} {% set preview = first_item.getRecord(app).get_preview() %}
{% else %} {% else %}
{% set preview = first_item.get_record().get_thumbnail() %} {% set preview = first_item.getRecord(app).get_thumbnail() %}
{% endif %} {% endif %}
{{thumbnail.format(preview, preview.get_width(), preview.get_height(),'', false, false)}} {{thumbnail.format(preview, preview.get_width(), preview.get_height(),'', false, false)}}
{% endif %} {% endif %}
@@ -52,8 +52,8 @@
<div class="display_id"></div> <div class="display_id"></div>
</td> </td>
<td style="text-align:left;width:auto;"> <td style="text-align:left;width:auto;">
<div class="title title15" title="{% if first_item %}{{first_item.get_record().get_title|e}}{% endif %}"> <div class="title title15" title="{% if first_item %}{{first_item.getRecord(app).get_title|e}}{% endif %}">
{% if first_item %}{{first_item.get_record().get_title}}{% endif %} {% if first_item %}{{first_item.getRecord(app).get_title}}{% endif %}
</div> </div>
</td> </td>
<td style="text-align:right;width:230px;"> <td style="text-align:right;width:230px;">
@@ -81,9 +81,9 @@
<div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;"> <div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;">
<div id="record_infos"> <div id="record_infos">
<div class="lightbox_container"> <div class="lightbox_container">
{% set business = app['authentication'].getUser().ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %} {% set business = app['authentication'].getUser().ACL().has_right_on_base(first_item.getRecord(app).get_base_id(), 'canmodifrecord') %}
{% if first_item %} {% if first_item %}
{{caption.format_caption(first_item.get_record(), '', null, business)}} {{caption.format_caption(first_item.getRecord(app), '', null, business)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@@ -6,9 +6,9 @@
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : element.getId()}) }}"> <a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : element.getId()}) }}">
<div id="scid_{{element.getId()}}" class="basket_element ui-corner-all {% if first_item and first_item.getId() == element.getId() %}selected{% endif %}"> <div id="scid_{{element.getId()}}" class="basket_element ui-corner-all {% if first_item and first_item.getId() == element.getId() %}selected{% endif %}">
<div class="display_id">{{element.getOrd()}}</div> <div class="display_id">{{element.getOrd()}}</div>
{{thumbnail.format(element.getRecord().get_thumbnail() ,114,85, '', true, false)}} {{thumbnail.format(element.getRecord(app).get_thumbnail() ,114,85, '', true, false)}}
<form name="download_form" class="download_form" style="display:none;"> <form name="download_form" class="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{element.getRecord().get_serialize_key()}}"/> <input type="hidden" name="basrec" value="{{element.getRecord(app).get_serialize_key()}}"/>
</form> </form>
<div tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : element.getRecord().get_sbas_id(), 'record_id' : element.getRecord().get_record_id() }) }}" class="previewTips"></div> <div tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : element.getRecord().get_sbas_id(), 'record_id' : element.getRecord().get_record_id() }) }}" class="previewTips"></div>
</div> </div>

View File

@@ -22,7 +22,7 @@
<img src="/skins/lightbox/saveie6.png"/> <img src="/skins/lightbox/saveie6.png"/>
</button> </button>
<form name="download_form" style="display:none;"> <form name="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{feed_element.getRecord().get_serialize_key()}}"/> <input type="hidden" name="basrec" value="{{feed_element.getRecord(app).get_serialize_key()}}"/>
</form> </form>
| |
{% endif %} {% endif %}

View File

@@ -24,11 +24,11 @@
<tr valign="middle"> <tr valign="middle">
<td style="width:10px;"></td> <td style="width:10px;"></td>
<td style="width:35px;text-align:center;"> <td style="width:35px;text-align:center;">
<div class="display_id">{% if first_item %}{{first_item.get_ord()}}{% endif %}</div> <div class="display_id">{% if first_item %}{{first_item.getOrd()}}{% endif %}</div>
</td> </td>
<td style="text-align:left;width:auto;"> <td style="text-align:left;width:auto;">
<div class="title title15" title="{% if first_item %}{{first_item.getRecord().getTitle|e}}{% endif %}"> <div class="title title15" title="{% if first_item %}{{first_item.getRecord(app).get_title|e}}{% endif %}">
{% if first_item %}{{first_item.get_record().getTitle|raw}}{% endif %} {% if first_item %}{{first_item.getRecord(app).get_title|raw}}{% endif %}
</div> </div>
</td> </td>
<td style="text-align:right;width:230px;"> <td style="text-align:right;width:230px;">
@@ -42,10 +42,10 @@
</div> </div>
<div class="lightbox_container PNB record_display_box"> <div class="lightbox_container PNB record_display_box">
{% if first_item %} {% if first_item %}
{% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.get_record(), 'preview') %} {% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.getRecord(app), 'preview') %}
{% set bask_prev = first_item.getRecord().get_preview() %} {% set bask_prev = first_item.getRecord(app).get_preview() %}
{% else %} {% else %}
{% set bask_prev = first_item.getRecord().get_thumbnail() %} {% set bask_prev = first_item.getRecord(app).get_thumbnail() %}
{% endif %} {% endif %}
{{thumbnail.format(bask_prev,bask_prev.get_width(),bask_prev.get_height(),'', false, false)}} {{thumbnail.format(bask_prev,bask_prev.get_width(),bask_prev.get_height(),'', false, false)}}
{% endif %} {% endif %}
@@ -60,8 +60,8 @@
<div class="display_id"></div> <div class="display_id"></div>
</td> </td>
<td style="text-align:left;width:auto;"> <td style="text-align:left;width:auto;">
<div class="title title15" title="{% if first_item %}{{first_item.getRecord().get_title|e}}{% endif %}"> <div class="title title15" title="{% if first_item %}{{first_item.getRecord(app).get_title|e}}{% endif %}">
{% if first_item %}{{first_item.getRecord().get_title}}{% endif %} {% if first_item %}{{first_item.getRecord(app).get_title}}{% endif %}
</div> </div>
</td> </td>
<td style="text-align:right;width:230px;"> <td style="text-align:right;width:230px;">
@@ -81,9 +81,9 @@
<div class="right_column_wrapper caption right_column_wrapper_caption PNB"> <div class="right_column_wrapper caption right_column_wrapper_caption PNB">
<div id="record_infos" class="PNB"> <div id="record_infos" class="PNB">
<div class="lightbox_container PNB"> <div class="lightbox_container PNB">
{% set business = app['authentication'].getUser().ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %} {% set business = app['authentication'].getUser().ACL().has_right_on_base(first_item.getRecord(app).get_base_id(), 'canmodifrecord') %}
{% if first_item %} {% if first_item %}
{{caption.format_caption(first_item.getRecord(), '', null, business)}} {{caption.format_caption(first_item.getRecord(app), '', null, business)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@@ -6,9 +6,9 @@
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : element.getId()}) }}"> <a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : element.getId()}) }}">
<div id="scid_{{element.getId()}}" class="basket_element ui-corner-all {% if first_item and first_item.getId() == element.getId() %}selected{% endif %}"> <div id="scid_{{element.getId()}}" class="basket_element ui-corner-all {% if first_item and first_item.getId() == element.getId() %}selected{% endif %}">
<div class="display_id">{{element.getOrd()}}</div> <div class="display_id">{{element.getOrd()}}</div>
{{thumbnail.format(element.getRecord().get_thumbnail() ,114,85, '', true, false)}} {{thumbnail.format(element.getRecord(app).get_thumbnail() ,114,85, '', true, false)}}
<form name="download_form" class="download_form" style="display:none;"> <form name="download_form" class="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{element.getRecord().get_serialize_key()}}"/> <input type="hidden" name="basrec" value="{{element.getRecord(app).get_serialize_key()}}"/>
</form> </form>
<div tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : element.getRecord().get_sbas_id(), 'record_id' : element.getRecord().get_record_id() }) }}" class="previewTips"></div> <div tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : element.getRecord().get_sbas_id(), 'record_id' : element.getRecord().get_record_id() }) }}" class="previewTips"></div>
</div> </div>

View File

@@ -22,7 +22,7 @@
<i class="icon-download icon-white"></i> <i class="icon-download icon-white"></i>
</button> </button>
<form name="download_form" style="display:none;"> <form name="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{feed_element.getRecord().get_serialize_key()}}"/> <input type="hidden" name="basrec" value="{{feed_element.getRecord(app).get_serialize_key()}}"/>
</form> </form>
| |
{% endif %} {% endif %}

View File

@@ -57,7 +57,7 @@
{% if feed.isPublisher(app['authentication'].getUser()) %} {% if feed.isPublisher(app['authentication'].getUser()) %}
<div class="feed {% if loop.index is odd%}odd{% endif %}"> <div class="feed {% if loop.index is odd%}odd{% endif %}">
<span>{{ feed.getTitle() }}</span> <span>{{ feed.getTitle() }}</span>
{% if feed.getPublic() %} {% if feed.isPublic() %}
<img src="/skins/icons/ligth-on.png" title="{% trans 'This feed is public' %}"/> <img src="/skins/icons/ligth-on.png" title="{% trans 'This feed is public' %}"/>
{% endif %} {% endif %}
<input type="hidden" value="{{ feed.getId() }}"/> <input type="hidden" value="{{ feed.getId() }}"/>

View File

@@ -1673,9 +1673,8 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
public function testFeedList() public function testFeedList()
{ {
$title = 'Yellow title'; $title = 'Yellow title';
$subtitle = 'Trololololo !';
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle); $created_feed = $this->insertOneFeed(self::$DI['user'], $title);
$this->setToken(self::$token); $this->setToken(self::$token);
$route = '/api/v1/feeds/list/'; $route = '/api/v1/feeds/list/';
@@ -1695,15 +1694,12 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->evaluateGoodFeed($feed); $this->evaluateGoodFeed($feed);
if ($feed['id'] == $created_feed->get_id()) { if ($feed['id'] == $created_feed->getId()) {
$found = true; $found = true;
$this->assertEquals($title, $feed['title']); $this->assertEquals($title, $feed['title']);
$this->assertEquals($subtitle, $feed['subtitle']);
} }
} }
$created_feed->delete();
if (!$found) { if (!$found) {
$this->fail('feed not found !'); $this->fail('feed not found !');
} }
@@ -1722,10 +1718,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$title = 'Yellow title'; $title = 'Yellow title';
$subtitle = 'Trololololo !'; $subtitle = 'Trololololo !';
$entry_title = 'Superman'; $entry_title = 'Superman';
@@ -1733,11 +1725,14 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$author = "W. Shakespeare"; $author = "W. Shakespeare";
$author_email = "gontran.bonheur@gmail.com"; $author_email = "gontran.bonheur@gmail.com";
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle); $created_item = $this->insertOneFeedItem(self::$DI['user']);
$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $created_feed, self::$DI['user']); $created_entry = $created_item->getEntry();
$created_entry->setAuthorEmail($author_email);
$created_entry = \Feed_Entry_Adapter::create(self::$DI['app'], $created_feed, $publisher, $entry_title, $entry_subtitle, $author, $author_email); $created_entry->setAuthorName($author);
$created_item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $created_entry, self::$DI['record_1']); $created_entry->setTitle($entry_title);
$created_entry->setSubtitle($entry_subtitle);
self::$DI['app']['EM']->persist($created_entry);
self::$DI['app']['EM']->flush();
$this->setToken(self::$token); $this->setToken(self::$token);
$route = '/api/v1/feeds/content/'; $route = '/api/v1/feeds/content/';
@@ -1760,7 +1755,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
foreach ($content['response']['entries'] as $entry) { foreach ($content['response']['entries'] as $entry) {
$this->assertGoodEntry($entry); $this->assertGoodEntry($entry);
if ($entry['id'] == $created_entry->get_id()) { if ($entry['id'] == $created_entry->getId()) {
$found = true; $found = true;
$this->assertEquals($author_email, $entry['author_email']); $this->assertEquals($author_email, $entry['author_email']);
$this->assertEquals($author, $entry['author_name']); $this->assertEquals($author, $entry['author_name']);
@@ -1769,8 +1764,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
} }
} }
$created_feed->delete();
if (!$found) { if (!$found) {
$this->fail('entry not found !'); $this->fail('entry not found !');
} }
@@ -1786,10 +1779,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$title = 'Yellow title'; $title = 'Yellow title';
$subtitle = 'Trololololo !'; $subtitle = 'Trololololo !';
$entry_title = 'Superman'; $entry_title = 'Superman';
@@ -1797,14 +1786,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$author = "W. Shakespeare"; $author = "W. Shakespeare";
$author_email = "gontran.bonheur@gmail.com"; $author_email = "gontran.bonheur@gmail.com";
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle); $created_item = $this->insertOneFeedItem(self::$DI['user']);
$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $created_feed, self::$DI['user']); $created_entry = $created_item->getEntry();
$created_entry = \Feed_Entry_Adapter::create(self::$DI['app'], $created_feed, $publisher, $entry_title, $entry_subtitle, $author, $author_email);
$created_item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $created_entry, self::$DI['record_1']);
$this->setToken(self::$token); $this->setToken(self::$token);
$route = '/api/v1/feeds/entry/' . $created_entry->get_id() . '/'; $route = '/api/v1/feeds/entry/' . $created_entry->getId() . '/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -1817,9 +1803,8 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->assertArrayHasKey('entry', $content['response']); $this->assertArrayHasKey('entry', $content['response']);
$this->assertGoodEntry($content['response']['entry']); $this->assertGoodEntry($content['response']['entry']);
$this->assertEquals($created_entry->get_id(), $content['response']['entry']['id']); $this->assertEquals($created_entry->getId(), $content['response']['entry']['id']);
$created_feed->delete();
} }
/** /**
@@ -1832,10 +1817,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$title = 'Yellow title'; $title = 'Yellow title';
$subtitle = 'Trololololo !'; $subtitle = 'Trololololo !';
$entry_title = 'Superman'; $entry_title = 'Superman';
@@ -1843,16 +1824,14 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$author = "W. Shakespeare"; $author = "W. Shakespeare";
$author_email = "gontran.bonheur@gmail.com"; $author_email = "gontran.bonheur@gmail.com";
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle); $created_item = $this->insertOneFeedItem(self::$DI['user']);
$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $created_feed, self::$DI['user']); $created_entry = $created_item->getEntry();
$created_feed = $created_entry->getFeed();
$created_entry = \Feed_Entry_Adapter::create(self::$DI['app'], $created_feed, $publisher, $entry_title, $entry_subtitle, $author, $author_email); $created_feed->setCollection(self::$DI['collection_no_access']);
$created_item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $created_entry, self::$DI['record_1']);
$created_feed->set_collection(self::$DI['collection_no_access']);
$this->setToken(self::$adminToken); $this->setToken(self::$adminToken);
$route = '/api/v1/feeds/entry/' . $created_entry->get_id() . '/'; $route = '/api/v1/feeds/entry/' . $created_entry->getId() . '/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -1876,25 +1855,19 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$title = 'Yellow title';
$subtitle = 'Trololololo !';
$entry_title = 'Superman'; $entry_title = 'Superman';
$entry_subtitle = 'Wonder Woman'; $entry_subtitle = 'Wonder Woman';
$author = "W. Shakespeare";
$author_email = "gontran.bonheur@gmail.com";
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle); $created_item = $this->insertOneFeedItem(self::$DI['user']);
$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $created_feed, self::$DI['user']); $created_entry = $created_item->getEntry();
$created_feed = $created_entry->getFeed();
$created_entry = \Feed_Entry_Adapter::create(self::$DI['app'], $created_feed, $publisher, $entry_title, $entry_subtitle, $author, $author_email); $created_entry->setTitle($entry_title);
$created_item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $created_entry, self::$DI['record_1']); $created_entry->setSubtitle($entry_subtitle);
self::$DI['app']['EM']->persist($created_entry);
self::$DI['app']['EM']->flush();
$this->setToken(self::$token); $this->setToken(self::$token);
$route = '/api/v1/feeds/' . $created_feed->get_id() . '/content/'; $route = '/api/v1/feeds/' . $created_feed->getId() . '/content/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -1912,16 +1885,14 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
foreach ($content['response']['entries'] as $entry) { foreach ($content['response']['entries'] as $entry) {
$this->assertGoodEntry($entry); $this->assertGoodEntry($entry);
if ($entry['id'] == $created_entry->get_id()) { if ($entry['id'] == $created_entry->getId()) {
$this->assertEquals($entry_title, $entry['title']); $this->assertEquals($entry_title, $entry['title']);
$this->assertEquals($entry_subtitle, $entry['subtitle']); $this->assertEquals($entry_subtitle, $entry['subtitle']);
$found = true; $found = true;
} }
} }
$this->assertEquals($created_feed->get_id(), $content['response']['feed']['id']); $this->assertEquals($created_feed->getId(), $content['response']['feed']['id']);
$created_feed->delete();
if (!$found) { if (!$found) {
$this->fail('Entry not found'); $this->fail('Entry not found');
@@ -2037,7 +2008,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->assertInternalType('string', $feed['title']); $this->assertInternalType('string', $feed['title']);
$this->assertInternalType('string', $feed['subtitle']); $this->assertInternalType('string', $feed['subtitle']);
$this->assertInternalType('integer', $feed['total_entries']); $this->assertInternalType('integer', $feed['total_entries']);
$this->assertInternalType('string', $feed['icon']); $this->assertInternalType('boolean', $feed['icon']);
$this->assertInternalType('boolean', $feed['public']); $this->assertInternalType('boolean', $feed['public']);
$this->assertInternalType('boolean', $feed['readonly']); $this->assertInternalType('boolean', $feed['readonly']);
$this->assertInternalType('boolean', $feed['deletable']); $this->assertInternalType('boolean', $feed['deletable']);

View File

@@ -18,22 +18,10 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer') self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$this->feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], "salut", 'coucou');
$publishers = $this->feed->get_publishers();
$publisher = array_shift($publishers);
$this->entry = \Feed_Entry_Adapter::create(self::$DI['app'], $this->feed, $publisher, 'title', "sub Titkle", " jean pierre", "jp@test.com");
$this->item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $this->entry, self::$DI['record_1']);
} }
public function tearDown() public function tearDown()
{ {
if ($this->feed instanceof \Feed_Adapter)
$this->feed->delete();
parent::tearDown(); parent::tearDown();
} }
@@ -148,7 +136,10 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
{ {
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/'); $item = $this->insertOneFeedItem(self::$DI['user']);
$entry = $item->getEntry();
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $entry->getId() . '/' . $item->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type')); $this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type'));
$datas = json_decode(self::$DI['client']->getResponse()->getContent()); $datas = json_decode(self::$DI['client']->getResponse()->getContent());
@@ -164,7 +155,7 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
$this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/'); $crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $entry->getId() . '/' . $item->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type')); $this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type'));
$datas = json_decode(self::$DI['client']->getResponse()->getContent()); $datas = json_decode(self::$DI['client']->getResponse()->getContent());
@@ -180,7 +171,7 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
$this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/'); $crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $entry->getId() . '/' . $item->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertNotEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type')); $this->assertNotEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type'));
} }
@@ -241,19 +232,22 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $this->entry->get_id() . '/'); $item = $this->insertOneFeedItem(self::$DI['user']);
$entry = $item->getEntry();
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
$this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $this->entry->get_id() . '/'); $crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
$this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $this->entry->get_id() . '/'); $crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
} }

View File

@@ -68,7 +68,7 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
$this->assertEquals('test', $feed->getTitle()); $this->assertEquals('test', $feed->getTitle());
$this->assertEquals('test', $feed->getSubtitle()); $this->assertEquals('test', $feed->getSubtitle());
$this->assertTrue($feed->getPublic()); $this->assertTrue($feed->isPublic());
$this->assertNull($feed->getCollection(self::$DI['app'])); $this->assertNull($feed->getCollection(self::$DI['app']));
} }
@@ -95,7 +95,7 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
$this->assertEquals('test', $feed->getTitle()); $this->assertEquals('test', $feed->getTitle());
$this->assertEquals('test', $feed->getSubtitle()); $this->assertEquals('test', $feed->getSubtitle());
$this->assertTrue($feed->getPublic()); $this->assertTrue($feed->isPublic());
$this->assertEquals(self::$DI['collection']->get_base_id(), $collection->get_base_id()); $this->assertEquals(self::$DI['collection']->get_base_id(), $collection->get_base_id());
$this->assertTrue( $this->assertTrue(

View File

@@ -7,37 +7,6 @@ use Symfony\Component\CssSelector\CssSelector;
class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class FeedTest 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';
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
parent::setUpBeforeClass(); parent::setUpBeforeClass();
@@ -360,7 +329,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
if ($one_feed->has_access(self::$DI['user'])) { if ($one_feed->has_access(self::$DI['user'])) {
$this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg); $this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
} else { } else {
$this->fail('Feed_collection::load_all should return feed where I got access'); $this->fail('FeedRepository::getAllForUser should return feeds I am allowed to access');
} }
} }
} }
@@ -382,7 +351,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
if ($one_feed->hasAccess(self::$DI['user'], self::$DI['app'])) { if ($one_feed->hasAccess(self::$DI['user'], self::$DI['app'])) {
$this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg); $this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
} else { } else {
$this->fail('Feed_collection::load_all should return feed where I got access'); $this->fail('FeedRepository::getAllForUser should return feeds I am allowed to access');
} }
} }
} }

View File

@@ -11,14 +11,9 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
protected static $feed;
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
if (self::$feed instanceof \Feed_Adapter) {
self::$feed->delete();
}
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }
@@ -193,46 +188,18 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
self::$DI['app']['authentication']->openAccount(self::$DI['user']); self::$DI['app']['authentication']->openAccount(self::$DI['user']);
self::$feed = \Feed_Adapter::create(
self::$DI['app'],
self::$DI['user'],
'titi',
'toto'
);
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer') self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce()) $item = $this->insertOneFeedItem(self::$DI['user']);
->method('deliver') $feedEntry = $item->getEntry();
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$feedEntry = \Feed_Entry_Adapter::create(
self::$DI['app'],
self::$feed,
\Feed_Publisher_Adapter::getPublisher(
self::$DI['app']['phraseanet.appbox'],
self::$feed,
self::$DI['user']
),
'titi',
'toto',
'tata',
'tutu@test.fr'
);
\Feed_Entry_Item::create(
self::$DI['app']['phraseanet.appbox'],
$feedEntry,
self::$DI['record_1']
);
$this->XMLHTTPRequest('POST', '/prod/records/', array( $this->XMLHTTPRequest('POST', '/prod/records/', array(
'env' => 'FEED', 'env' => 'FEED',
'pos' => 0, 'pos' => 0,
'query' => '', 'query' => '',
'cont' => $feedEntry->get_id() 'cont' => $feedEntry->getId()
)); ));
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();

View File

@@ -178,7 +178,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
$all_feeds = self::$DI['app']['EM']->getRepository('Entities\Feed')->findAllPublic(); $all_feeds = self::$DI['app']['EM']->getRepository('Entities\Feed')->findAllPublic();
foreach ($all_feeds as $feed) { foreach ($all_feeds as $feed) {
$this->assertTrue($feed->getPublic()); $this->assertTrue($feed->isPublic());
} }
$crawler = self::$DI['client']->request("GET", "/feeds/aggregated/rss/"); $crawler = self::$DI['client']->request("GET", "/feeds/aggregated/rss/");
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
@@ -195,7 +195,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
$all_feeds = self::$DI['app']['EM']->getRepository('Entities\Feed')->findAllPublic(); $all_feeds = self::$DI['app']['EM']->getRepository('Entities\Feed')->findAllPublic();
foreach ($all_feeds as $feed) { foreach ($all_feeds as $feed) {
$this->assertTrue($feed->getPublic()); $this->assertTrue($feed->isPublic());
} }
$crawler = self::$DI['client']->request("GET", "/feeds/aggregated/atom/"); $crawler = self::$DI['client']->request("GET", "/feeds/aggregated/atom/");
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
@@ -633,48 +633,48 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
$this->assertEquals($feed->getCountTotalEntries(), $count); $this->assertEquals($feed->getCountTotalEntries(), $count);
} }
public function checkATOMEntryNode(\DOMNode $node, \DOMXPath $xpath, \Feed_Adapter $feed, \Feed_Entry_Adapter $entry) public function checkATOMEntryNode(\DOMNode $node, \DOMXPath $xpath, Feed $feed, FeedEntry $entry)
{ {
foreach ($node->childNodes as $child) { foreach ($node->childNodes as $child) {
if ($child->nodeType !== XML_TEXT_NODE) { if ($child->nodeType !== XML_TEXT_NODE) {
switch ($child->nodeName) { switch ($child->nodeName) {
case 'id': case 'id':
$this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->get_id()), $child->nodeValue); $this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->getId()), $child->nodeValue);
break; break;
case 'link': case 'link':
foreach ($child->attributes as $attribute) { foreach ($child->attributes as $attribute) {
if ($attribute->name == "href") { if ($attribute->name == "href") {
$this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->get_id()), $attribute->value); $this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->getId()), $attribute->value);
break; break;
} }
} }
break; break;
case 'updated': case 'updated':
$this->assertEquals($entry->get_updated_on()->format(DATE_ATOM), $child->nodeValue); $this->assertEquals($entry->getUpdatedOn()->format(DATE_ATOM), $child->nodeValue);
break; break;
case 'published': case 'published':
$this->assertEquals($entry->get_created_on()->format(DATE_ATOM), $child->nodeValue); $this->assertEquals($entry->getCreatedOn()->format(DATE_ATOM), $child->nodeValue);
break; break;
case 'title': case 'title':
$this->assertEquals($entry->get_title(), $child->nodeValue); $this->assertEquals($entry->getTitle(), $child->nodeValue);
break; break;
case 'content': case 'content':
$this->assertEquals($entry->get_subtitle(), $child->nodeValue); $this->assertEquals($entry->getSubtitle(), $child->nodeValue);
break; break;
case 'author': case 'author':
foreach ($node->childNodes as $child) { foreach ($node->childNodes as $child) {
if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "email") if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "email")
$this->assertEquals($entry->get_author_email(), $child->nodeValue); $this->assertEquals($entry->getAuthorEmail(), $child->nodeValue);
if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "name") if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "name")
$this->assertEquals($entry->get_author_name(), $child->nodeValue); $this->assertEquals($entry->getAuthorName(), $child->nodeValue);
} }
break; break;
} }
} }
} }
$content = $entry->get_content(); $content = $entry->getItems()->toArray();
$available_medium = array('image', 'audio', 'video'); $available_medium = array('image', 'audio', 'video');
@@ -686,7 +686,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
foreach ($media_group as $media) { foreach ($media_group as $media) {
$entry_item = array_shift($content); $entry_item = array_shift($content);
if ($entry_item instanceof \Feed_Entry_Item) { if ($entry_item instanceof FeedEntry) {
$this->verifyMediaItem($entry_item, $media); $this->verifyMediaItem($entry_item, $media);
} }
} }

View File

@@ -431,7 +431,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* *
* @return \Entities\FeedEntry * @return \Entities\FeedItem
*/ */
protected function insertOneFeedItem(\User_Adapter $user) protected function insertOneFeedItem(\User_Adapter $user)
{ {
@@ -440,6 +440,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$item = new \Entities\FeedItem(); $item = new \Entities\FeedItem();
$item->setEntry($entry); $item->setEntry($entry);
$item->setRecordId(self::$DI['record_1']->get_record_id());
$item->setSbasId(self::$DI['record_1']->get_sbas_id());
$entry->addItem($item); $entry->addItem($item);
@@ -449,11 +451,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$em->persist($item); $em->persist($item);
$em->flush(); $em->flush();
return $entry;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->fail('Fail to load one FeedEntry : ' . $e->getMessage()); $this->fail('Fail to load one FeedEntry : ' . $e->getMessage());
} }
return $item;
} }
/** /**