aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-03-12 11:10:21 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-03-12 11:10:21 +0100
commit6ab56c7b2c225b74b000e9ecedfe28aa0f8d1e18 (patch)
treecfb8e6887628780ba7a571565f561f00019a0e0b
parent55e61971f393d679a47e18f48cd2e04403ce4368 (diff)
parentb95ffda2a105af4c6f4f86aca025a0bf967bc86a (diff)
downloadwallabag-6ab56c7b2c225b74b000e9ecedfe28aa0f8d1e18.tar.gz
wallabag-6ab56c7b2c225b74b000e9ecedfe28aa0f8d1e18.tar.zst
wallabag-6ab56c7b2c225b74b000e9ecedfe28aa0f8d1e18.zip
Merge pull request #1775 from wallabag/v2-few-fixes
Some fixes
-rw-r--r--.travis.yml2
-rw-r--r--src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php18
-rw-r--r--src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php53
-rw-r--r--src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php6
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php1
-rw-r--r--src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php4
6 files changed, 68 insertions, 16 deletions
diff --git a/.travis.yml b/.travis.yml
index 5f0abe87..5741b533 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -50,6 +50,6 @@ before_install:
50 - if [[ $TRAVIS_REPO_SLUG = wallabag/wallabag ]]; then cp .composer-auth.json ~/.composer/auth.json; fi; 50 - if [[ $TRAVIS_REPO_SLUG = wallabag/wallabag ]]; then cp .composer-auth.json ~/.composer/auth.json; fi;
51 51
52script: 52script:
53 - travis_wait composer update --no-interaction --no-progress 53 - travis_wait composer install --no-interaction --no-progress --prefer-dist -o
54 - ant prepare-$DB 54 - ant prepare-$DB
55 - bin/phpunit -v 55 - bin/phpunit -v
diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
index c1c6e638..5f7da70e 100644
--- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
+++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
@@ -88,4 +88,22 @@ class AnnotationRepository extends EntityRepository
88 ->getQuery() 88 ->getQuery()
89 ->getOneOrNullResult(); 89 ->getOneOrNullResult();
90 } 90 }
91
92 /**
93 * Used only in test case to get the right annotation associated to the right user.
94 *
95 * @param string $username
96 *
97 * @return Annotation
98 */
99 public function findOneByUsername($username)
100 {
101 return $this->createQueryBuilder('a')
102 ->leftJoin('a.user', 'u')
103 ->where('u.username = :username')->setParameter('username', $username)
104 ->orderBy('a.id', 'DESC')
105 ->setMaxResults(1)
106 ->getQuery()
107 ->getSingleResult();
108 }
91} 109}
diff --git a/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php b/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php
index c0efe272..e972c2de 100644
--- a/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php
+++ b/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php
@@ -11,11 +11,12 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
11 $annotation = $this->client->getContainer() 11 $annotation = $this->client->getContainer()
12 ->get('doctrine.orm.entity_manager') 12 ->get('doctrine.orm.entity_manager')
13 ->getRepository('WallabagAnnotationBundle:Annotation') 13 ->getRepository('WallabagAnnotationBundle:Annotation')
14 ->findOneBy(array('user' => 1)); 14 ->findOneByUsername('admin');
15 15
16 if (!$annotation) { 16 if (!$annotation) {
17 $this->markTestSkipped('No content found in db.'); 17 $this->markTestSkipped('No content found in db.');
18 } 18 }
19
19 $this->logInAs('admin'); 20 $this->logInAs('admin');
20 $crawler = $this->client->request('GET', 'annotations/'.$annotation->getEntry()->getId().'.json'); 21 $crawler = $this->client->request('GET', 'annotations/'.$annotation->getEntry()->getId().'.json');
21 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 22 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -32,18 +33,25 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
32 $entry = $this->client->getContainer() 33 $entry = $this->client->getContainer()
33 ->get('doctrine.orm.entity_manager') 34 ->get('doctrine.orm.entity_manager')
34 ->getRepository('WallabagCoreBundle:Entry') 35 ->getRepository('WallabagCoreBundle:Entry')
35 ->findOneBy(array('user' => 1)); 36 ->findOneByUsernameAndNotArchived('admin');
36 37
37 $headers = array('CONTENT_TYPE' => 'application/json'); 38 $headers = array('CONTENT_TYPE' => 'application/json');
38 $content = json_encode(array( 39 $content = json_encode(array(
39 'text' => 'my annotation', 40 'text' => 'my annotation',
40 'quote' => 'my quote', 41 'quote' => 'my quote',
41 'range' => '[{"start":"","startOffset":24,"end":"","endOffset":31}]', 42 'ranges' => array('start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31),
42 )); 43 ));
43 $crawler = $this->client->request('POST', 'annotations/'.$entry->getId().'.json', array(), array(), $headers, $content); 44 $crawler = $this->client->request('POST', 'annotations/'.$entry->getId().'.json', array(), array(), $headers, $content);
44 45
45 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 46 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
46 47
48 $content = json_decode($this->client->getResponse()->getContent(), true);
49
50 $this->assertEquals('Big boss', $content['user']);
51 $this->assertEquals('v1.0', $content['annotator_schema_version']);
52 $this->assertEquals('my annotation', $content['text']);
53 $this->assertEquals('my quote', $content['quote']);
54
47 $annotation = $this->client->getContainer() 55 $annotation = $this->client->getContainer()
48 ->get('doctrine.orm.entity_manager') 56 ->get('doctrine.orm.entity_manager')
49 ->getRepository('WallabagAnnotationBundle:Annotation') 57 ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -57,25 +65,56 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
57 $annotation = $this->client->getContainer() 65 $annotation = $this->client->getContainer()
58 ->get('doctrine.orm.entity_manager') 66 ->get('doctrine.orm.entity_manager')
59 ->getRepository('WallabagAnnotationBundle:Annotation') 67 ->getRepository('WallabagAnnotationBundle:Annotation')
60 ->findOneBy(array('user' => 1)); 68 ->findOneByUsername('admin');
61 69
62 $this->logInAs('admin'); 70 $this->logInAs('admin');
63 71
64 $headers = array('CONTENT_TYPE' => 'application/json'); 72 $headers = array('CONTENT_TYPE' => 'application/json');
65 $content = json_encode(array( 73 $content = json_encode(array(
66 'text' => 'a modified annotation', 74 'text' => 'a modified annotation',
67 )); 75 ));
68 $crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content); 76 $crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content);
69 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 77 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
70 78
71 $content = json_decode($this->client->getResponse()->getContent(), true); 79 $content = json_decode($this->client->getResponse()->getContent(), true);
72 80
81 $this->assertEquals('Big boss', $content['user']);
82 $this->assertEquals('v1.0', $content['annotator_schema_version']);
73 $this->assertEquals('a modified annotation', $content['text']); 83 $this->assertEquals('a modified annotation', $content['text']);
84 $this->assertEquals('my quote', $content['quote']);
74 85
75 $annotationUpdated = $this->client->getContainer() 86 $annotationUpdated = $this->client->getContainer()
76 ->get('doctrine.orm.entity_manager') 87 ->get('doctrine.orm.entity_manager')
77 ->getRepository('WallabagAnnotationBundle:Annotation') 88 ->getRepository('WallabagAnnotationBundle:Annotation')
78 ->findAnnotationById($annotation->getId()); 89 ->findOneById($annotation->getId());
79 $this->assertEquals('a modified annotation', $annotationUpdated->getText()); 90 $this->assertEquals('a modified annotation', $annotationUpdated->getText());
80 } 91 }
92
93 public function testDeleteAnnotation()
94 {
95 $annotation = $this->client->getContainer()
96 ->get('doctrine.orm.entity_manager')
97 ->getRepository('WallabagAnnotationBundle:Annotation')
98 ->findOneByUsername('admin');
99
100 $this->logInAs('admin');
101
102 $headers = array('CONTENT_TYPE' => 'application/json');
103 $content = json_encode(array(
104 'text' => 'a modified annotation',
105 ));
106 $crawler = $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content);
107 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
108
109 $content = json_decode($this->client->getResponse()->getContent(), true);
110
111 $this->assertEquals('a modified annotation', $content['text']);
112
113 $annotationDeleted = $this->client->getContainer()
114 ->get('doctrine.orm.entity_manager')
115 ->getRepository('WallabagAnnotationBundle:Annotation')
116 ->findOneById($annotation->getId());
117
118 $this->assertNull($annotationDeleted);
119 }
81} 120}
diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php
index a705f9de..cce39d0b 100644
--- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php
+++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php
@@ -162,12 +162,12 @@ class WallabagRestControllerTest extends WallabagApiTestCase
162 $this->assertCount(1, $content['tags']); 162 $this->assertCount(1, $content['tags']);
163 } 163 }
164 164
165 public function testPostArchivedEntry() 165 public function testPostArchivedAndStarredEntry()
166 { 166 {
167 $this->client->request('POST', '/api/entries.json', array( 167 $this->client->request('POST', '/api/entries.json', array(
168 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', 168 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
169 'archive' => true, 169 'archive' => true,
170 'starred' => false, 170 'starred' => true,
171 )); 171 ));
172 172
173 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 173 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -177,7 +177,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
177 $this->assertGreaterThan(0, $content['id']); 177 $this->assertGreaterThan(0, $content['id']);
178 $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']); 178 $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
179 $this->assertEquals(true, $content['is_archived']); 179 $this->assertEquals(true, $content['is_archived']);
180 $this->assertEquals(false, $content['is_starred']); 180 $this->assertEquals(true, $content['is_starred']);
181 } 181 }
182 182
183 public function testPatchEntry() 183 public function testPatchEntry()
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 1791eac2..1930a2ae 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -16,7 +16,6 @@ use Wallabag\CoreBundle\Form\Type\RssType;
16use Wallabag\CoreBundle\Form\Type\TaggingRuleType; 16use Wallabag\CoreBundle\Form\Type\TaggingRuleType;
17use Wallabag\CoreBundle\Form\Type\UserInformationType; 17use Wallabag\CoreBundle\Form\Type\UserInformationType;
18use Wallabag\CoreBundle\Tools\Utils; 18use Wallabag\CoreBundle\Tools\Utils;
19use Wallabag\UserBundle\Entity\User;
20 19
21class ConfigController extends Controller 20class ConfigController extends Controller
22{ 21{
diff --git a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
index 92712b9d..450cdc95 100644
--- a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
+++ b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
@@ -302,8 +302,6 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
302 "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", 302 "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland",
303 "favorite": "1", 303 "favorite": "1",
304 "status": "1", 304 "status": "1",
305 "resolved_title": "The Massive Ryder Cup Preview",
306 "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview",
307 "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", 305 "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.",
308 "is_article": "1", 306 "is_article": "1",
309 "has_video": "1", 307 "has_video": "1",
@@ -317,8 +315,6 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
317 "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", 315 "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland",
318 "favorite": "1", 316 "favorite": "1",
319 "status": "0", 317 "status": "0",
320 "resolved_title": "The Massive Ryder Cup Preview",
321 "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview",
322 "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", 318 "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.",
323 "is_article": "1", 319 "is_article": "1",
324 "has_video": "0", 320 "has_video": "0",