...
 
Commits (12)
......@@ -6,11 +6,11 @@ insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
indent_size = 2
[{package.json,.travis.yml}]
indent_style = space
indent_size = 4
indent_size = 2
[*.md]
trim_trailing_whitespace = false
# Contribution Guide
## New Merge Requests
- Your commits must be **Verified**
- Your **Code Coverage** must be **100%**
- Your tests ([*GitLab CI/CD*](https://docs.gitlab.com/ee/ci/)) must be with **Passing** status (**no broken tests!**)
- Your **Coding Style** must be valid [*PSR-2*](https://www.php-fig.org/psr/psr-2/) (*use this:* [*php-cs-fixer config*](https://gitlab.com/snippets/1749141))
## New Issues
There is no special template for creating new issues, but please when create new one describe your issue and provide enough information about it : error logs, screen shots, state what version of the package you are using, what version of laravel (laravel based cms) etc.
## Security Reports
If you discover a security vulnerability within this package, please send an e-mail to Roumen Damianoff via [roumen@laravelium.com](mailto:roumen@laravelium.com). All security vulnerabilities will be promptly addressed.
{
"name": "laravelium/feed",
"description": "Laravelium Feed generator for Laravel.",
"description": "Laravelium Feed package for Laravel.",
"homepage": "https://laravelium.com",
"keywords": ["laravelium", "laravel", "feed", "generator", "rss", "atom"],
"license": "MIT",
......@@ -18,7 +18,7 @@
},
"require-dev": {
"phpunit/phpunit": "~7.0",
"orchestra/testbench": "3.6.x-dev"
"orchestra/testbench": "3.6.*"
},
"autoload": {
"psr-0": {
......
......@@ -4,13 +4,13 @@
* Feed generator class for laravel-feed package.
*
* @author Roumen Damianoff <roumen@damianoff.com>
* @version 3.0
* @version 3.1
* @link https://laravelium.com
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
use Illuminate\Cache\Repository as CacheRepository;
use Illuminate\Config\Repository as ConfigRepository;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Illuminate\Filesystem\Filesystem as Filesystem;
use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactory;
use Illuminate\View\Factory as ViewFactory;
......@@ -231,17 +231,17 @@ class Feed
// add to items
$this->setItem([
'title' => htmlspecialchars(strip_tags($title), ENT_COMPAT, 'UTF-8'),
'author' => $author,
'link' => $link,
'pubdate' => $pubdate,
'description' => $description,
'content' => $content,
'enclosure' => $enclosure,
'category' => $category,
'subtitle' => htmlspecialchars(strip_tags($subtitle), ENT_COMPAT, 'UTF-8'),
'duration' => $duration
]);
'title' => htmlspecialchars(strip_tags($title), ENT_COMPAT, 'UTF-8'),
'author' => $author,
'link' => $link,
'pubdate' => $pubdate,
'description' => $description,
'content' => $content,
'enclosure' => $enclosure,
'category' => $category,
'subtitle' => htmlspecialchars(strip_tags($subtitle), ENT_COMPAT, 'UTF-8'),
'duration' => $duration
]);
}
/**
......@@ -262,6 +262,10 @@ class Feed
return;
}
// append ... to description
$append = '';
// shortening the description
if ($this->shortening) {
if (strlen($item['description']) > $this->shorteningLimit) {
//adds '...'' for shortened description
......@@ -289,7 +293,9 @@ class Feed
$format = "atom";
}
if (null != $cache) {
if (0 == $cache || (null == $cache && 0 == $this->caching)) {
$this->clearCache();
} else {
$this->caching = $cache;
}
......@@ -303,10 +309,14 @@ class Feed
$view = 'feed::'.$format;
}
$this->ctype = ($format == 'atom') ? 'application/atom+xml' : 'application/rss+xml';
if (null != $this->getCtype()) {
$ctype = $this->getCtype();
} else {
$ctype = ($format == 'atom') ? 'application/atom+xml' : 'application/rss+xml';
}
// if cache is on and there is cached feed => return it
if ($this->caching > 0 && $this->cache->has($this->cacheKey)) {
if (0 < $this->caching && $this->cache->has($this->cacheKey)) {
return $this->response->make($this->cache->get($this->cacheKey), 200, ['Content-Type' => $this->cache->get($this->cacheKey."_ctype").'; charset='.$this->charset]);
}
......@@ -324,43 +334,43 @@ class Feed
}
$channel = [
'title' => htmlspecialchars(strip_tags($this->title), ENT_COMPAT, 'UTF-8'),
'subtitle' => htmlspecialchars(strip_tags($this->subtitle), ENT_COMPAT, 'UTF-8'),
'description' => $this->description,
'logo' => $this->logo,
'icon' => $this->icon,
'color' => $this->color,
'cover' => $this->cover,
'ga' => $this->ga,
'related' => $this->related,
'rssLink' => $this->getRssLink(),
'link' => $this->link,
'ref' => $this->ref,
'pubdate' => $this->formatDate($this->pubdate, $format),
'lang' => $this->lang,
'copyright' => $this->copyright
];
'title' => htmlspecialchars(strip_tags($this->title), ENT_COMPAT, 'UTF-8'),
'subtitle' => htmlspecialchars(strip_tags($this->subtitle), ENT_COMPAT, 'UTF-8'),
'description' => $this->description,
'logo' => $this->logo,
'icon' => $this->icon,
'color' => $this->color,
'cover' => $this->cover,
'ga' => $this->ga,
'related' => $this->related,
'rssLink' => $this->getRssLink(),
'link' => $this->link,
'ref' => $this->ref,
'pubdate' => $this->formatDate($this->pubdate, $format),
'lang' => $this->lang,
'copyright' => $this->copyright
];
$viewData = [
'items' => $this->items,
'channel' => $channel,
'namespaces' => $this->getNamespaces()
];
'items' => $this->items,
'channel' => $channel,
'namespaces' => $this->getNamespaces()
];
// if cache is on put this feed in cache and return it
if ($this->caching > 0) {
if (0 < $this->caching) {
// cache the view
// cache the view
$this->cache->put($this->cacheKey, $this->view->make($view, $viewData)->render(), $this->caching);
// cache the ctype
$this->cache->put($this->cacheKey."_ctype", $this->ctype, $this->caching);
$this->cache->put($this->cacheKey."_ctype", $ctype, $this->caching);
return $this->response->make($this->cache->get($this->cacheKey), 200, ['Content-Type' => $this->cache->get($this->cacheKey."_ctype").'; charset='.$this->charset]);
} else {
// if cache is 0 delete the key (if exists) and return response
$this->clearCache();
return $this->response->make($this->view->make($view, $viewData), 200, ['Content-Type' => $this->ctype.'; charset='.$this->charset]);
return $this->response->make($this->view->make($view, $viewData), 200, ['Content-Type' => $ctype.'; charset='.$this->charset]);
}
}
......@@ -502,28 +512,28 @@ class Feed
{
if ($format == "atom") {
switch ($this->dateFormat) {
case "carbon":
$date = date('c', strtotime($date->toDateTimeString()));
break;
case "timestamp":
$date = date('c', strtotime('@'.$date));
break;
case "datetime":
$date = date('c', strtotime($date));
break;
}
case "carbon":
$date = date('c', strtotime($date->toDateTimeString()));
break;
case "timestamp":
$date = date('c', strtotime('@'.$date));
break;
case "datetime":
$date = date('c', strtotime($date));
break;
}
} else {
switch ($this->dateFormat) {
case "carbon":
$date = date('D, d M Y H:i:s O', strtotime($date->toDateTimeString()));
break;
case "timestamp":
$date = date('D, d M Y H:i:s O', strtotime('@'.$date));
break;
case "datetime":
$date = date('D, d M Y H:i:s O', strtotime($date));
break;
}
case "carbon":
$date = date('D, d M Y H:i:s O', strtotime($date->toDateTimeString()));
break;
case "timestamp":
$date = date('D, d M Y H:i:s O', strtotime('@'.$date));
break;
case "datetime":
$date = date('D, d M Y H:i:s O', strtotime($date));
break;
}
}
return $date;
......@@ -633,4 +643,24 @@ class Feed
{
return $this->caching;
}
/**
* Setter for $ctype
*
* @return string
*/
public function setCtype($ctype=null)
{
$this->ctype = $ctype;
}
/**
* Getter for $ctype
*
* @return string
*/
public function getCtype()
{
return $this->ctype;
}
}
<?php namespace Laravelium\Feed;
<?php namespace Laravelium\Feed;
use Illuminate\Support\ServiceProvider;
use Laravelium\Feed\Feed;
use Illuminate\Support\ServiceProvider;
use Laravelium\Feed\Feed;
class FeedServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Bootstrap the application events.
*
* @return void
*/
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../../views', 'feed');
$this->loadViewsFrom(__DIR__ . '/../../views', 'feed');
$this->publishes([
__DIR__ . '/../../views' => base_path('resources/views/vendor/feed')
], 'views');
__DIR__ . '/../../views' => base_path('resources/views/vendor/feed')
], 'views');
$config_file = __DIR__ . '/../../config/config.php';
$config_file = __DIR__ . '/../../config/config.php';
$this->mergeConfigFrom($config_file, 'feed');
$this->publishes([
$config_file => config_path('feed.php')
], 'config');
$config_file => config_path('feed.php')
], 'config');
}
/**
* Register the service provider.
*
* @return void
*/
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bind('feed', function ($app) {
$config = config('feed');
$config = config('feed');
return new Feed(
$config,
$app['Illuminate\Cache\Repository'],
$app['config'],
$app['files'],
$app['Illuminate\Contracts\Routing\ResponseFactory'],
$app['view']
);
return new Feed(
$config,
$app['Illuminate\Cache\Repository'],
$app['config'],
$app['files'],
$app['Illuminate\Contracts\Routing\ResponseFactory'],
$app['view']
);
});
$this->app->alias('feed', Feed::class);
}
/**
* Get the services provided by the provider.
*
* @return array
*/
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return ['feed', Feed::class];
return ['feed', Feed::class];
}
}
......@@ -2,30 +2,30 @@
<feed xmlns="http://www.w3.org/2005/Atom"<?php foreach ($namespaces as $n) {
echo " ".$n;
} ?>>
<title type="text">{!! $channel['title'] !!}</title>
<subtitle type="html"><![CDATA[{!! $channel['description'] !!}]]></subtitle>
<link href="{{ $channel['rssLink'] }}"></link>
<id>{{ $channel['link'] }}</id>
<link rel="alternate" type="text/html" href="{{ $channel['rssLink'] }}" ></link>
<link rel="{{ $channel['ref'] }}" type="application/atom+xml" href="{{ $channel['link'] }}" ></link>
<title type="text">{!! $channel['title'] !!}</title>
<subtitle type="html"><![CDATA[{!! $channel['description'] !!}]]></subtitle>
<link href="{{ $channel['rssLink'] }}"></link>
<id>{{ $channel['link'] }}</id>
<link rel="alternate" type="text/html" href="{{ $channel['rssLink'] }}" ></link>
<link rel="{{ $channel['ref'] }}" type="application/atom+xml" href="{{ $channel['link'] }}" ></link>
@if (!empty($channel['logo']))
<logo>{{ $channel['logo'] }}</logo>
<logo>{{ $channel['logo'] }}</logo>
@endif
@if (!empty($channel['icon']))
<icon>{{ $channel['icon'] }}</icon>
<icon>{{ $channel['icon'] }}</icon>
@endif
<updated>{{ $channel['pubdate'] }}</updated>
<updated>{{ $channel['pubdate'] }}</updated>
@foreach($items as $item)
<entry>
<author>
<name>{{ $item['author'] }}</name>
</author>
<title type="text"><![CDATA[{!! $item['title'] !!}]]></title>
<link rel="alternate" type="text/html" href="{{ $item['link'] }}"></link>
<id>{{ $item['link'] }}</id>
<summary type="html"><![CDATA[{!! $item['description'] !!}]]></summary>
<content type="html"><![CDATA[{!! $item['content'] !!}]]></content>
<updated>{{ $item['pubdate'] }}</updated>
</entry>
<entry>
<author>
<name>{{ $item['author'] }}</name>
</author>
<title type="text"><![CDATA[{!! $item['title'] !!}]]></title>
<link rel="alternate" type="text/html" href="{{ $item['link'] }}"></link>
<id>{{ $item['link'] }}</id>
<summary type="html"><![CDATA[{!! $item['description'] !!}]]></summary>
<content type="html"><![CDATA[{!! $item['content'] !!}]]></content>
<updated>{{ $item['pubdate'] }}</updated>
</entry>
@endforeach
</feed>
......@@ -2,90 +2,90 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:webfeeds="http://webfeeds.org/rss/1.0" xmlns:media="http://search.yahoo.com/mrss/"<?php foreach ($namespaces as $n) {
echo " ".$n;
} ?>>
<channel>
<title>{!! $channel['title'] !!}</title>
<link>{{ $channel['rssLink'] }}</link>
<description><![CDATA[{!! $channel['description'] !!}]]></description>
<atom:link href="{{ $channel['link'] }}" rel="{{ $channel['ref'] }}" type="application/rss+xml" />
@if (!empty($channel['copyright']))
<copyright>{{ $channel['copyright'] }}</copyright>
@endif
@if (!empty($channel['color']))
<webfeeds:accentColor>{{ $channel['color'] }}</webfeeds:accentColor>
@endif
@if (!empty($channel['cover']))
<webfeeds:cover image="{{ $channel['cover'] }}" />
@endif
@if (!empty($channel['icon']))
<webfeeds:icon>{{ $channel['icon'] }}</webfeeds:icon>
@endif
@if (!empty($channel['logo']))
<webfeeds:logo>{{ $channel['logo'] }}</webfeeds:logo>
<image>
<url>{{ $channel['logo'] }}</url>
<title>{{ $channel['title'] }}</title>
<link>{{ $channel['rssLink'] }}</link>
</image>
@endif
@if (!empty($channel['related']))
<webfeeds:related layout="card" target="browser" />
@endif
@if (!empty($channel['ga']))
<webfeeds:analytics id="{{ $channel['ga'] }}" engine="GoogleAnalytics" />
@endif
<language>{{ $channel['lang'] }}</language>
<lastBuildDate>{{ $channel['pubdate'] }}</lastBuildDate>
@foreach($items as $item)
<item>
<title><![CDATA[{!! $item['title'] !!}]]></title>
@if (!empty($item['category']))
<category>{{ $item['category'] }}</category>
@endif
<link>{{ $item['link'] }}</link>
<guid isPermaLink="true">{{ $item['link'] }}</guid>
<description><![CDATA[{!! $item['description'] !!}]]></description>
@if (!empty($item['content']))
<content:encoded><![CDATA[{!! $item['content'] !!}]]></content:encoded>
@endif
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">{!! $item['author'] !!}</dc:creator>
<pubDate>{{ $item['pubdate'] }}</pubDate>
@if (!empty($item['enclosure']))
<enclosure
@foreach ($item['enclosure'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:content']))
<media:content
@foreach ($item['media:content'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:thumbnail']))
<media:thumbnail
@foreach ($item['media:thumbnail'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:title']))
<media:title type="plain">{{ $item['media:title'] }}</media:title>
@endif
@if (!empty($item['media:description']))
<media:description type="plain">{{ $item['media:description'] }}</media:description>
@endif
@if (!empty($item['media:keywords']))
<media:keywords>{{ $item['media:title'] }}</media:keywords>
@endif
@if (!empty($item['media:rating']))
<media:rating>{{ $item['media:rating'] }}</media:rating>
@endif
@if (!empty($item['creativeCommons:license']))
<creativeCommons:license>{{ $item['creativeCommons:license'] }}</creativeCommons:license>
@endif
</item>
@endforeach
</channel>
<channel>
<title>{!! $channel['title'] !!}</title>
<link>{{ $channel['rssLink'] }}</link>
<description><![CDATA[{!! $channel['description'] !!}]]></description>
<atom:link href="{{ $channel['link'] }}" rel="{{ $channel['ref'] }}" type="application/rss+xml" />
@if (!empty($channel['copyright']))
<copyright>{{ $channel['copyright'] }}</copyright>
@endif
@if (!empty($channel['color']))
<webfeeds:accentColor>{{ $channel['color'] }}</webfeeds:accentColor>
@endif
@if (!empty($channel['cover']))
<webfeeds:cover image="{{ $channel['cover'] }}" />
@endif
@if (!empty($channel['icon']))
<webfeeds:icon>{{ $channel['icon'] }}</webfeeds:icon>
@endif
@if (!empty($channel['logo']))
<webfeeds:logo>{{ $channel['logo'] }}</webfeeds:logo>
<image>
<url>{{ $channel['logo'] }}</url>
<title>{{ $channel['title'] }}</title>
<link>{{ $channel['rssLink'] }}</link>
</image>
@endif
@if (!empty($channel['related']))
<webfeeds:related layout="card" target="browser" />
@endif
@if (!empty($channel['ga']))
<webfeeds:analytics id="{{ $channel['ga'] }}" engine="GoogleAnalytics" />
@endif
<language>{{ $channel['lang'] }}</language>
<lastBuildDate>{{ $channel['pubdate'] }}</lastBuildDate>
@foreach($items as $item)
<item>
<title><![CDATA[{!! $item['title'] !!}]]></title>
@if (!empty($item['category']))
<category>{{ $item['category'] }}</category>
@endif
<link>{{ $item['link'] }}</link>
<guid isPermaLink="true">{{ $item['link'] }}</guid>
<description><![CDATA[{!! $item['description'] !!}]]></description>
@if (!empty($item['content']))
<content:encoded><![CDATA[{!! $item['content'] !!}]]></content:encoded>
@endif
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">{!! $item['author'] !!}</dc:creator>
<pubDate>{{ $item['pubdate'] }}</pubDate>
@if (!empty($item['enclosure']))
<enclosure
@foreach ($item['enclosure'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:content']))
<media:content
@foreach ($item['media:content'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:thumbnail']))
<media:thumbnail
@foreach ($item['media:thumbnail'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:title']))
<media:title type="plain">{{ $item['media:title'] }}</media:title>
@endif
@if (!empty($item['media:description']))
<media:description type="plain">{{ $item['media:description'] }}</media:description>
@endif
@if (!empty($item['media:keywords']))
<media:keywords>{{ $item['media:title'] }}</media:keywords>
@endif
@if (!empty($item['media:rating']))
<media:rating>{{ $item['media:rating'] }}</media:rating>
@endif
@if (!empty($item['creativeCommons:license']))
<creativeCommons:license>{{ $item['creativeCommons:license'] }}</creativeCommons:license>
@endif
</item>
@endforeach
</channel>
</rss>
......@@ -25,11 +25,11 @@ class FeedTest extends TestCase
parent::setUp();
$config = [
'feed.use_cache' => false,
'feed.cache_key' => 'Laravel.feed.',
'feed.cache_duration' => 3600,
'feed.testing' => true
];
'feed.use_cache' => false,
'feed.cache_key' => 'Laravel.feed.',
'feed.cache_duration' => 3600,
'feed.testing' => true
];
config($config);
......@@ -84,6 +84,17 @@ class FeedTest extends TestCase
$this->assertEquals('http://domain.tld/images/cover.png', $this->feed->cover);
$this->assertEquals('UA-1525185-18', $this->feed->ga);
$this->assertEquals(false, $this->feed->related);
$this->assertEquals(null, $this->feed->getCtype());
$this->feed->setCtype('plain/text');
$this->assertEquals('plain/text', $this->feed->getCtype());
$this->assertEquals('laravel-feed', $this->feed->getCacheKey());
$this->assertEquals(0, $this->feed->getCacheDuration());
$this->feed->setCache(30, 'laravel-feed1');
$this->assertEquals('laravel-feed1', $this->feed->getCacheKey());
$this->assertEquals(30, $this->feed->getCacheDuration());
}
......@@ -110,49 +121,49 @@ class FeedTest extends TestCase
public function testFeedAddItem()
{
$this->feed->addItem([
'title' => 'TestTitle',
'author' => 'TestAuthor',
'link' => 'TestUrl',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume</p>',
'content' => '<p>TestContent</p>',
'category' => 'testCategory',
'enclosure' => ['url'=>'http://foobar.dev/someThing.jpg', 'type' => 'image/jpeg'],
'duration' => '00:00:00'
]);
'title' => 'TestTitle',
'author' => 'TestAuthor',
'link' => 'TestUrl',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume</p>',
'content' => '<p>TestContent</p>',
'category' => 'testCategory',
'enclosure' => ['url'=>'http://foobar.dev/someThing.jpg', 'type' => 'image/jpeg'],
'duration' => '00:00:00'
]);
$this->feed->addItem([
'title' => 'TestTitle2',
'author' => 'TestAuthor2',
'link' => 'TestUrl2',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume2</p>'
]);
'title' => 'TestTitle2',
'author' => 'TestAuthor2',
'link' => 'TestUrl2',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume2</p>'
]);
// add multidimensional array
$this->feed->addItem([
[
'title' => 'TestTitle3',
'author' => 'TestAuthor3',
'link' => 'TestUrl3',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume3</p>'
],
[
'title' => 'TestTitle4',
'author' => 'TestAuthor4',
'link' => 'TestUrl4',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume4</p>'
],
[
'title' => 'TestTitle5',
'author' => 'TestAuthor5',
'link' => 'TestUrl5',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume5</p>'
]
]);
[
'title' => 'TestTitle3',
'author' => 'TestAuthor3',
'link' => 'TestUrl3',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume3</p>'
],
[
'title' => 'TestTitle4',
'author' => 'TestAuthor4',
'link' => 'TestUrl4',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume4</p>'
],
[
'title' => 'TestTitle5',
'author' => 'TestAuthor5',
'link' => 'TestUrl5',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>TestResume5</p>'
]
]);
// get items
$items = $this->feed->getItems();
......@@ -204,14 +215,26 @@ class FeedTest extends TestCase
$this->assertEquals(200, $response->status());
$this->assertEquals('application/atom+xml; charset=utf-8', $response->headers->get('Content-Type'));
$response = $this->feed->render('rss', 60, 'testFeed');
$response = $this->feed->render('rss', 60, 'testFeed2');
$this->assertEquals(200, $response->status());
$this->assertEquals('application/rss+xml; charset=utf-8', $response->headers->get('Content-Type'));
// nonexisting custom view, won't get an error, because will use the cached view from above
$this->feed->setCustomView('vendor.feed.test2');
$response = $this->feed->render('atom', 60, 'testFeed');
$response = $this->feed->render('atom', 60, 'testFeed2');
$this->assertEquals(200, $response->status());
// returns wrong ctype, because will use the cached view/ctype for 'testFeed' key
$this->assertEquals('application/rss+xml; charset=utf-8', $response->headers->get('Content-Type'));
$this->feed->setCustomView(null);
$response = $this->feed->render('atom', 0, 'testFeed2');
$this->assertEquals(200, $response->status());
$this->assertEquals('application/atom+xml; charset=utf-8', $response->headers->get('Content-Type'));
$this->feed->setCtype('application/atom+json');
$response = $this->feed->render('atom', 0, 'testFeed2');
$this->assertEquals(200, $response->status());
$this->assertEquals('application/atom+json; charset=utf-8', $response->headers->get('Content-Type'));
}
public function testIsCached()
......@@ -296,12 +319,12 @@ class FeedTest extends TestCase
$this->feed->add('TestTitle', 'TestAuthor', 'TestUrl', '2014-02-29 00:00:00', '<p>TestResume</p>');
$this->feed->addItem([
'title' => 'TestTitle',
'author' => 'TestAuthor',
'link' => 'TestUrl',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>Test2Resume</p>'
]);
'title' => 'TestTitle',
'author' => 'TestAuthor',
'link' => 'TestUrl',
'pubdate' => '2014-02-29 00:00:00',
'description' => '<p>Test2Resume</p>'
]);
$items = $this->feed->getItems();
......