aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml4
-rw-r--r--composer.json3
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php16
-rw-r--r--tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php6
-rw-r--r--tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php32
-rw-r--r--tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php2
6 files changed, 42 insertions, 21 deletions
diff --git a/.travis.yml b/.travis.yml
index 393d0033..8c1ec5cb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -54,6 +54,10 @@ before_script:
54 - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini 54 - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
55 - phpenv config-rm xdebug.ini || echo "xdebug not available" 55 - phpenv config-rm xdebug.ini || echo "xdebug not available"
56 - composer self-update --no-progress 56 - composer self-update --no-progress
57 # install imagick
58 - pear config-set preferred_state beta
59 - pecl channel-update pecl.php.net
60 - yes | pecl install imagick
57 61
58script: 62script:
59 - travis_wait bash composer install -o --no-interaction --no-progress --prefer-dist 63 - travis_wait bash composer install -o --no-interaction --no-progress --prefer-dist
diff --git a/composer.json b/composer.json
index b28404e3..b1c144c7 100644
--- a/composer.json
+++ b/composer.json
@@ -103,6 +103,9 @@
103 "phpstan/phpstan-symfony": "^0.11.0", 103 "phpstan/phpstan-symfony": "^0.11.0",
104 "phpstan/phpstan-doctrine": "^0.11.0" 104 "phpstan/phpstan-doctrine": "^0.11.0"
105 }, 105 },
106 "suggest": {
107 "ext-imagick": "To keep GIF animation when downloading image is enabled"
108 },
106 "scripts": { 109 "scripts": {
107 "post-cmd": [ 110 "post-cmd": [
108 "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", 111 "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index cc3dcfce..9a7e9828 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -135,7 +135,21 @@ class DownloadImages
135 135
136 switch ($ext) { 136 switch ($ext) {
137 case 'gif': 137 case 'gif':
138 imagegif($im, $localPath); 138 // use Imagick if available to keep GIF animation
139 if (class_exists('\\Imagick')) {
140 try {
141 $imagick = new \Imagick();
142 $imagick->readImageBlob($res->getBody());
143 $imagick->setImageFormat('gif');
144 $imagick->writeImages($localPath, true);
145 } catch (\Exception $e) {
146 // if Imagick fail, fallback to the default solution
147 imagegif($im, $localPath);
148 }
149 } else {
150 imagegif($im, $localPath);
151 }
152
139 $this->logger->debug('DownloadImages: Re-creating gif'); 153 $this->logger->debug('DownloadImages: Re-creating gif');
140 break; 154 break;
141 case 'jpeg': 155 case 'jpeg':
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
index 7beccd30..277d8012 100644
--- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
+++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
@@ -33,7 +33,7 @@ class GrabySiteConfigBuilderTest extends TestCase
33 $grabyConfigBuilderMock 33 $grabyConfigBuilderMock
34 ->method('buildForHost') 34 ->method('buildForHost')
35 ->with('example.com') 35 ->with('example.com')
36 ->will($this->returnValue($grabySiteConfig)); 36 ->willReturn($grabySiteConfig);
37 37
38 $logger = new Logger('foo'); 38 $logger = new Logger('foo');
39 $handler = new TestHandler(); 39 $handler = new TestHandler();
@@ -93,7 +93,7 @@ class GrabySiteConfigBuilderTest extends TestCase
93 $grabyConfigBuilderMock 93 $grabyConfigBuilderMock
94 ->method('buildForHost') 94 ->method('buildForHost')
95 ->with('unknown.com') 95 ->with('unknown.com')
96 ->will($this->returnValue(new GrabySiteConfig())); 96 ->willReturn(new GrabySiteConfig());
97 97
98 $logger = new Logger('foo'); 98 $logger = new Logger('foo');
99 $handler = new TestHandler(); 99 $handler = new TestHandler();
@@ -153,7 +153,7 @@ class GrabySiteConfigBuilderTest extends TestCase
153 $grabyConfigBuilderMock 153 $grabyConfigBuilderMock
154 ->method('buildForHost') 154 ->method('buildForHost')
155 ->with('example.com') 155 ->with('example.com')
156 ->will($this->returnValue($grabySiteConfig)); 156 ->willReturn($grabySiteConfig);
157 157
158 $logger = new Logger('foo'); 158 $logger = new Logger('foo');
159 $handler = new TestHandler(); 159 $handler = new TestHandler();
diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php
index 92fe38cd..48c82dde 100644
--- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php
+++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php
@@ -26,7 +26,7 @@ class UsernameFeedTokenConverterTest extends TestCase
26 26
27 $registry->expects($this->once()) 27 $registry->expects($this->once())
28 ->method('getManagers') 28 ->method('getManagers')
29 ->will($this->returnValue([])); 29 ->willReturn([]);
30 30
31 $params = new ParamConverter([]); 31 $params = new ParamConverter([]);
32 $converter = new UsernameFeedTokenConverter($registry); 32 $converter = new UsernameFeedTokenConverter($registry);
@@ -42,7 +42,7 @@ class UsernameFeedTokenConverterTest extends TestCase
42 42
43 $registry->expects($this->once()) 43 $registry->expects($this->once())
44 ->method('getManagers') 44 ->method('getManagers')
45 ->will($this->returnValue(['default' => null])); 45 ->willReturn(['default' => null]);
46 46
47 $params = new ParamConverter([]); 47 $params = new ParamConverter([]);
48 $converter = new UsernameFeedTokenConverter($registry); 48 $converter = new UsernameFeedTokenConverter($registry);
@@ -58,7 +58,7 @@ class UsernameFeedTokenConverterTest extends TestCase
58 58
59 $meta->expects($this->once()) 59 $meta->expects($this->once())
60 ->method('getName') 60 ->method('getName')
61 ->will($this->returnValue('nothingrelated')); 61 ->willReturn('nothingrelated');
62 62
63 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') 63 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
64 ->disableOriginalConstructor() 64 ->disableOriginalConstructor()
@@ -67,7 +67,7 @@ class UsernameFeedTokenConverterTest extends TestCase
67 $em->expects($this->once()) 67 $em->expects($this->once())
68 ->method('getClassMetadata') 68 ->method('getClassMetadata')
69 ->with('superclass') 69 ->with('superclass')
70 ->will($this->returnValue($meta)); 70 ->willReturn($meta);
71 71
72 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') 72 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
73 ->disableOriginalConstructor() 73 ->disableOriginalConstructor()
@@ -75,12 +75,12 @@ class UsernameFeedTokenConverterTest extends TestCase
75 75
76 $registry->expects($this->once()) 76 $registry->expects($this->once())
77 ->method('getManagers') 77 ->method('getManagers')
78 ->will($this->returnValue(['default' => null])); 78 ->willReturn(['default' => null]);
79 79
80 $registry->expects($this->once()) 80 $registry->expects($this->once())
81 ->method('getManagerForClass') 81 ->method('getManagerForClass')
82 ->with('superclass') 82 ->with('superclass')
83 ->will($this->returnValue($em)); 83 ->willReturn($em);
84 84
85 $params = new ParamConverter(['class' => 'superclass']); 85 $params = new ParamConverter(['class' => 'superclass']);
86 $converter = new UsernameFeedTokenConverter($registry); 86 $converter = new UsernameFeedTokenConverter($registry);
@@ -96,7 +96,7 @@ class UsernameFeedTokenConverterTest extends TestCase
96 96
97 $meta->expects($this->once()) 97 $meta->expects($this->once())
98 ->method('getName') 98 ->method('getName')
99 ->will($this->returnValue('Wallabag\UserBundle\Entity\User')); 99 ->willReturn('Wallabag\UserBundle\Entity\User');
100 100
101 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') 101 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
102 ->disableOriginalConstructor() 102 ->disableOriginalConstructor()
@@ -105,7 +105,7 @@ class UsernameFeedTokenConverterTest extends TestCase
105 $em->expects($this->once()) 105 $em->expects($this->once())
106 ->method('getClassMetadata') 106 ->method('getClassMetadata')
107 ->with('WallabagUserBundle:User') 107 ->with('WallabagUserBundle:User')
108 ->will($this->returnValue($meta)); 108 ->willReturn($meta);
109 109
110 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') 110 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
111 ->disableOriginalConstructor() 111 ->disableOriginalConstructor()
@@ -113,12 +113,12 @@ class UsernameFeedTokenConverterTest extends TestCase
113 113
114 $registry->expects($this->once()) 114 $registry->expects($this->once())
115 ->method('getManagers') 115 ->method('getManagers')
116 ->will($this->returnValue(['default' => null])); 116 ->willReturn(['default' => null]);
117 117
118 $registry->expects($this->once()) 118 $registry->expects($this->once())
119 ->method('getManagerForClass') 119 ->method('getManagerForClass')
120 ->with('WallabagUserBundle:User') 120 ->with('WallabagUserBundle:User')
121 ->will($this->returnValue($em)); 121 ->willReturn($em);
122 122
123 $params = new ParamConverter(['class' => 'WallabagUserBundle:User']); 123 $params = new ParamConverter(['class' => 'WallabagUserBundle:User']);
124 $converter = new UsernameFeedTokenConverter($registry); 124 $converter = new UsernameFeedTokenConverter($registry);
@@ -149,7 +149,7 @@ class UsernameFeedTokenConverterTest extends TestCase
149 $repo->expects($this->once()) 149 $repo->expects($this->once())
150 ->method('findOneByUsernameAndFeedToken') 150 ->method('findOneByUsernameAndFeedToken')
151 ->with('test', 'test') 151 ->with('test', 'test')
152 ->will($this->returnValue(null)); 152 ->willReturn(null);
153 153
154 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') 154 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
155 ->disableOriginalConstructor() 155 ->disableOriginalConstructor()
@@ -158,7 +158,7 @@ class UsernameFeedTokenConverterTest extends TestCase
158 $em->expects($this->once()) 158 $em->expects($this->once())
159 ->method('getRepository') 159 ->method('getRepository')
160 ->with('WallabagUserBundle:User') 160 ->with('WallabagUserBundle:User')
161 ->will($this->returnValue($repo)); 161 ->willReturn($repo);
162 162
163 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') 163 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
164 ->disableOriginalConstructor() 164 ->disableOriginalConstructor()
@@ -167,7 +167,7 @@ class UsernameFeedTokenConverterTest extends TestCase
167 $registry->expects($this->once()) 167 $registry->expects($this->once())
168 ->method('getManagerForClass') 168 ->method('getManagerForClass')
169 ->with('WallabagUserBundle:User') 169 ->with('WallabagUserBundle:User')
170 ->will($this->returnValue($em)); 170 ->willReturn($em);
171 171
172 $params = new ParamConverter(['class' => 'WallabagUserBundle:User']); 172 $params = new ParamConverter(['class' => 'WallabagUserBundle:User']);
173 $converter = new UsernameFeedTokenConverter($registry); 173 $converter = new UsernameFeedTokenConverter($registry);
@@ -187,7 +187,7 @@ class UsernameFeedTokenConverterTest extends TestCase
187 $repo->expects($this->once()) 187 $repo->expects($this->once())
188 ->method('findOneByUsernameAndFeedtoken') 188 ->method('findOneByUsernameAndFeedtoken')
189 ->with('test', 'test') 189 ->with('test', 'test')
190 ->will($this->returnValue($user)); 190 ->willReturn($user);
191 191
192 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') 192 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
193 ->disableOriginalConstructor() 193 ->disableOriginalConstructor()
@@ -196,7 +196,7 @@ class UsernameFeedTokenConverterTest extends TestCase
196 $em->expects($this->once()) 196 $em->expects($this->once())
197 ->method('getRepository') 197 ->method('getRepository')
198 ->with('WallabagUserBundle:User') 198 ->with('WallabagUserBundle:User')
199 ->will($this->returnValue($repo)); 199 ->willReturn($repo);
200 200
201 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') 201 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
202 ->disableOriginalConstructor() 202 ->disableOriginalConstructor()
@@ -205,7 +205,7 @@ class UsernameFeedTokenConverterTest extends TestCase
205 $registry->expects($this->once()) 205 $registry->expects($this->once())
206 ->method('getManagerForClass') 206 ->method('getManagerForClass')
207 ->with('WallabagUserBundle:User') 207 ->with('WallabagUserBundle:User')
208 ->will($this->returnValue($em)); 208 ->willReturn($em);
209 209
210 $params = new ParamConverter(['class' => 'WallabagUserBundle:User', 'name' => 'user']); 210 $params = new ParamConverter(['class' => 'WallabagUserBundle:User', 'name' => 'user']);
211 $converter = new UsernameFeedTokenConverter($registry); 211 $converter = new UsernameFeedTokenConverter($registry);
diff --git a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
index fd32f380..d976c4ac 100644
--- a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
+++ b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
@@ -68,7 +68,7 @@ class CreateConfigListenerTest extends TestCase
68 68
69 $this->em->expects($this->once()) 69 $this->em->expects($this->once())
70 ->method('persist') 70 ->method('persist')
71 ->will($this->returnValue($config)); 71 ->willReturn($config);
72 $this->em->expects($this->once()) 72 $this->em->expects($this->once())
73 ->method('flush'); 73 ->method('flush');
74 74