'value' => 'wallabag',
'section' => 'misc',
],
+ [
+ 'name' => 'download_images_enabled',
+ 'value' => '0',
+ 'section' => 'image',
+ ],
+ [
+ 'name' => 'download_images_with_rabbitmq',
+ 'value' => '0',
+ 'section' => 'image',
+ ],
+ [
+ 'name' => 'download_images_with_redis',
+ 'value' => '0',
+ 'section' => 'image',
+ ],
];
foreach ($settings as $setting) {
$config = new $this->configClass();
$config->setEntityManager($args->getEntityManager());
+ if (!$config->get('download_images_enabled')) {
+ return;
+ }
+
// field content has been updated
if ($args->hasChangedField('content')) {
$html = $this->downloadImages($config, $entity);
$config = new $this->configClass();
$config->setEntityManager($args->getEntityManager());
+ if (!$config->get('download_images_enabled')) {
+ return;
+ }
+
// update all images inside the html
$html = $this->downloadImages($config, $entity);
if (false !== $html) {
$client->request('GET', '/share/'.$content->getUuid());
$this->assertEquals(404, $client->getResponse()->getStatusCode());
}
+
+ public function testNewEntryWithDownloadImagesEnabled()
+ {
+ $this->logInAs('admin');
+ $client = $this->getClient();
+
+ $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route';
+ $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
+
+ $crawler = $client->request('GET', '/new');
+
+ $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+ $form = $crawler->filter('form[name=entry]')->form();
+
+ $data = [
+ 'entry[url]' => $url,
+ ];
+
+ $client->submit($form, $data);
+
+ $this->assertEquals(302, $client->getResponse()->getStatusCode());
+
+ $em = $client->getContainer()
+ ->get('doctrine.orm.entity_manager');
+
+ $entry = $em
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findByUrlAndUserId($url, $this->getLoggedInUserId());
+
+ $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
+ $this->assertEquals($url, $entry->getUrl());
+ $this->assertContains('Perpignan', $entry->getTitle());
+ $this->assertContains('assets/images/8/e/8ec9229a/d9bc0fcd.jpeg', $entry->getContent());
+
+ $em->remove($entry);
+ $em->flush();
+
+ $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
+ }
}