mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-23 08:06:33 +00:00
parent
db96045a0a
commit
98f0929f16
4 changed files with 56 additions and 5 deletions
|
@ -94,6 +94,13 @@ class Entry
|
|||
*/
|
||||
private $mimetype;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="language", type="text", nullable=true)
|
||||
*/
|
||||
private $language;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
|
@ -450,4 +457,28 @@ class Entry
|
|||
{
|
||||
return $this->previewPicture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language.
|
||||
*
|
||||
* @param string $language
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function setLanguage($language)
|
||||
{
|
||||
$this->language = $language;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use JMS\Serializer\Annotation\ExclusionPolicy;
|
||||
use JMS\Serializer\Annotation\Expose;
|
||||
use FOS\UserBundle\Model\User as BaseUser;
|
||||
|
@ -74,8 +73,8 @@ class User extends BaseUser implements AdvancedUserInterface, \Serializable
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->entries = new ArrayCollection();
|
||||
$this->tags = new ArrayCollection();
|
||||
$this->entries = new ArrayCollection();
|
||||
$this->tags = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,6 +49,7 @@ class ContentProxy
|
|||
$entry->setUrl($content['url'] ?: $url);
|
||||
$entry->setTitle($title);
|
||||
$entry->setContent($html);
|
||||
$entry->setLanguage($content['language']);
|
||||
$entry->setMimetype($content['content_type']);
|
||||
|
||||
if (isset($content['open_graph']['og_image'])) {
|
||||
|
|
|
@ -18,7 +18,13 @@ class ContentProxyTest extends KernelTestCase
|
|||
|
||||
$graby->expects($this->any())
|
||||
->method('fetchContent')
|
||||
->willReturn(array('html' => false, 'title' => '', 'url' => '', 'content_type' => ''));
|
||||
->willReturn(array(
|
||||
'html' => false,
|
||||
'title' => '',
|
||||
'url' => '',
|
||||
'content_type' => '',
|
||||
'language' => '',
|
||||
));
|
||||
|
||||
$proxy = new ContentProxy($graby);
|
||||
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
|
||||
|
@ -28,6 +34,7 @@ class ContentProxyTest extends KernelTestCase
|
|||
$this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent());
|
||||
$this->assertEmpty($entry->getPreviewPicture());
|
||||
$this->assertEmpty($entry->getMimetype());
|
||||
$this->assertEmpty($entry->getLanguage());
|
||||
}
|
||||
|
||||
public function testWithEmptyContentButOG()
|
||||
|
@ -39,7 +46,17 @@ class ContentProxyTest extends KernelTestCase
|
|||
|
||||
$graby->expects($this->any())
|
||||
->method('fetchContent')
|
||||
->willReturn(array('html' => false, 'title' => '', 'url' => '', 'content_type' => '', 'open_graph' => array('og_title' => 'my title', 'og_description' => 'desc')));
|
||||
->willReturn(array(
|
||||
'html' => false,
|
||||
'title' => '',
|
||||
'url' => '',
|
||||
'content_type' => '',
|
||||
'language' => '',
|
||||
'open_graph' => array(
|
||||
'og_title' => 'my title',
|
||||
'og_description' => 'desc',
|
||||
),
|
||||
));
|
||||
|
||||
$proxy = new ContentProxy($graby);
|
||||
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
|
||||
|
@ -48,6 +65,7 @@ class ContentProxyTest extends KernelTestCase
|
|||
$this->assertEquals('my title', $entry->getTitle());
|
||||
$this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent());
|
||||
$this->assertEmpty($entry->getPreviewPicture());
|
||||
$this->assertEmpty($entry->getLanguage());
|
||||
$this->assertEmpty($entry->getMimetype());
|
||||
}
|
||||
|
||||
|
@ -65,6 +83,7 @@ class ContentProxyTest extends KernelTestCase
|
|||
'title' => 'this is my title',
|
||||
'url' => 'http://1.1.1.1',
|
||||
'content_type' => 'text/html',
|
||||
'language' => 'fr',
|
||||
'open_graph' => array(
|
||||
'og_title' => 'my OG title',
|
||||
'og_description' => 'OG desc',
|
||||
|
@ -80,5 +99,6 @@ class ContentProxyTest extends KernelTestCase
|
|||
$this->assertEquals('this is my content', $entry->getContent());
|
||||
$this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
|
||||
$this->assertEquals('text/html', $entry->getMimetype());
|
||||
$this->assertEquals('fr', $entry->getLanguage());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue