public function testAddEntry() { $extras = ['keywords' => ['foo', 'bar']]; $images = [['loc' => 'http://example.com/1.jpg'], ['loc' => 'http://example.com/2.jpg']]; $this->sitemap->addEntry('http://example.com/', 'Example News Article', '2014-09-26T00:00:00+00:00', $extras, $images); $items = $this->sitemap->getEntries(); $this->assertCount(1, $items); $item = $items[0]; $this->assertEquals('http://example.com/', $item['loc']); $news = $item['news']; $this->assertEquals('2014-09-26T00:00:00+00:00', $news['publication_date']); $this->assertEquals('Example News Article', $news['title']); $publication = $news['publication']; $this->assertEquals('Test News Site', $publication['name']); $this->assertEquals('en', $publication['language']); $this->assertCount(2, $news['keywords']); $this->assertEquals($extras['keywords'], $news['keywords']); $images = $item['images']; $this->assertCount(2, $images); $this->assertEquals('http://example.com/1.jpg', $images[0]['loc']); $this->assertEquals('http://example.com/2.jpg', $images[1]['loc']); }
/** * Register the service provider. * * @return void */ public function register() { $this->app->bind('Cviebrock\\LaravelNewsSitemap\\NewsSitemap', function ($app) { $sitemap = new NewsSitemap($app['cache'], $app['view']); $sitemap->setUseCache($app['config']->get('news-sitemap::cache.enable')); $sitemap->setCacheKey($app['config']->get('news-sitemap::cache.key')); $sitemap->setCacheLifetime($app['config']->get('news-sitemap::cache.lifetime')); $sitemap->setDefaults($app['config']->get('news-sitemap::defaults')); return $sitemap; }); }