aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-02-07 20:39:03 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-02-07 20:39:03 +0100
commit8af35ad932177e0363412a868afc128b406e3322 (patch)
tree8d517780d2a82d68ebd06aea2da2fc4c7c67b5bb /src/Wallabag
parentd01db0c71dcf183f1676b6b06206456138cb7660 (diff)
parent9c0c88200635a979b9abdcba922e1d3904790636 (diff)
downloadwallabag-8af35ad932177e0363412a868afc128b406e3322.tar.gz
wallabag-8af35ad932177e0363412a868afc128b406e3322.tar.zst
wallabag-8af35ad932177e0363412a868afc128b406e3322.zip
Merge pull request #1066 from wallabag/v2-api-tests-entry
V2 api tests entry
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Resources/public/js/bookmarklet.js2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/_bookmarklet.html.twig3
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/_head.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/layout.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Service/Extractor.php3
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php79
6 files changed, 83 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/public/js/bookmarklet.js b/src/Wallabag/CoreBundle/Resources/public/js/bookmarklet.js
new file mode 100644
index 00000000..2afdfc3c
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/public/js/bookmarklet.js
@@ -0,0 +1,2 @@
1
2top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>"
diff --git a/src/Wallabag/CoreBundle/Resources/views/_bookmarklet.html.twig b/src/Wallabag/CoreBundle/Resources/views/_bookmarklet.html.twig
deleted file mode 100644
index fd662c19..00000000
--- a/src/Wallabag/CoreBundle/Resources/views/_bookmarklet.html.twig
+++ /dev/null
@@ -1,3 +0,0 @@
1 <script type="text/javascript">
2 top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>"
3 </script>
diff --git a/src/Wallabag/CoreBundle/Resources/views/_head.html.twig b/src/Wallabag/CoreBundle/Resources/views/_head.html.twig
index f123183b..726b4163 100755
--- a/src/Wallabag/CoreBundle/Resources/views/_head.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/_head.html.twig
@@ -37,3 +37,4 @@
37 <script src="{{ asset('themes/_global/js/saveLink.js') }}"></script> 37 <script src="{{ asset('themes/_global/js/saveLink.js') }}"></script>
38 <script src="{{ asset('themes/_global/js/popupForm.js') }}"></script> 38 <script src="{{ asset('themes/_global/js/popupForm.js') }}"></script>
39 <script src="{{ asset('themes/baggy/js/closeMessage.js') }}"></script> 39 <script src="{{ asset('themes/baggy/js/closeMessage.js') }}"></script>
40 <script src="{{ asset('bundles/wallabagcore/js/bookmarklet.js') }}"></script>
diff --git a/src/Wallabag/CoreBundle/Resources/views/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/layout.html.twig
index f062672c..e9ccc58c 100644
--- a/src/Wallabag/CoreBundle/Resources/views/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/layout.html.twig
@@ -12,7 +12,6 @@
12 <![endif]--> 12 <![endif]-->
13 <title>{% block title %}{% endblock %} - wallabag</title> 13 <title>{% block title %}{% endblock %} - wallabag</title>
14 {% include "WallabagCoreBundle::_head.html.twig" %} 14 {% include "WallabagCoreBundle::_head.html.twig" %}
15 {% include "WallabagCoreBundle::_bookmarklet.html.twig" %}
16 </head> 15 </head>
17 <body> 16 <body>
18 {% include "WallabagCoreBundle::_top.html.twig" %} 17 {% include "WallabagCoreBundle::_top.html.twig" %}
diff --git a/src/Wallabag/CoreBundle/Service/Extractor.php b/src/Wallabag/CoreBundle/Service/Extractor.php
index d38b0d76..e4ec96f6 100644
--- a/src/Wallabag/CoreBundle/Service/Extractor.php
+++ b/src/Wallabag/CoreBundle/Service/Extractor.php
@@ -10,7 +10,7 @@ final class Extractor
10 public static function extract($url) 10 public static function extract($url)
11 { 11 {
12 $pageContent = Extractor::getPageContent(new Url(base64_encode($url))); 12 $pageContent = Extractor::getPageContent(new Url(base64_encode($url)));
13 $title = ($pageContent['rss']['channel']['item']['title'] != '') ? $pageContent['rss']['channel']['item']['title'] : _('Untitled'); 13 $title = $pageContent['rss']['channel']['item']['title'] ?: 'Untitled';
14 $body = $pageContent['rss']['channel']['item']['description']; 14 $body = $pageContent['rss']['channel']['item']['description'];
15 15
16 $content = new Content(); 16 $content = new Content();
@@ -19,6 +19,7 @@ final class Extractor
19 19
20 return $content; 20 return $content;
21 } 21 }
22
22 /** 23 /**
23 * Get the content for a given URL (by a call to FullTextFeed) 24 * Get the content for a given URL (by a call to FullTextFeed)
24 * 25 *
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 786ff811..fde210c9 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -6,12 +6,89 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6 6
7class EntryControllerTest extends WebTestCase 7class EntryControllerTest extends WebTestCase
8{ 8{
9 public function testIndex() 9 public function testGetNew()
10 { 10 {
11 $client = static::createClient(); 11 $client = static::createClient();
12 12
13 $crawler = $client->request('GET', '/new'); 13 $crawler = $client->request('GET', '/new');
14 14
15 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 15 $this->assertEquals(200, $client->getResponse()->getStatusCode());
16
17 $this->assertCount(1, $crawler->filter('input[type=url]'));
18 $this->assertCount(1, $crawler->filter('button[type=submit]'));
19 }
20
21 public function testPostNewEmpty()
22 {
23 $client = static::createClient();
24
25 $crawler = $client->request('GET', '/new');
26
27 $this->assertEquals(200, $client->getResponse()->getStatusCode());
28
29 $form = $crawler->filter('button[type=submit]')->form();
30
31 $crawler = $client->submit($form);
32
33 $this->assertEquals(200, $client->getResponse()->getStatusCode());
34 $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(array('_text')));
35 $this->assertEquals('This value should not be blank.', $alert[0]);
36 }
37
38 public function testPostNewOk()
39 {
40 $client = static::createClient();
41
42 $crawler = $client->request('GET', '/new');
43
44 $this->assertEquals(200, $client->getResponse()->getStatusCode());
45
46 $form = $crawler->filter('button[type=submit]')->form();
47
48 $data = array(
49 'form[url]' => 'https://www.mailjet.com/blog/mailjet-zapier-integrations-made-easy/',
50 );
51
52 $client->submit($form, $data);
53
54 $this->assertEquals(302, $client->getResponse()->getStatusCode());
55
56 $crawler = $client->followRedirect();
57
58 $this->assertCount(1, $alert = $crawler->filter('h2 a')->extract(array('_text')));
59 $this->assertContains('Mailjet', $alert[0]);
60 }
61
62 public function testArchive()
63 {
64 $client = static::createClient();
65
66 $crawler = $client->request('GET', '/archive');
67
68 $this->assertEquals(200, $client->getResponse()->getStatusCode());
69 }
70
71 public function testStarred()
72 {
73 $client = static::createClient();
74
75 $crawler = $client->request('GET', '/starred');
76
77 $this->assertEquals(200, $client->getResponse()->getStatusCode());
78 }
79
80 public function testView()
81 {
82 $client = static::createClient();
83
84 $content = $client->getContainer()
85 ->get('doctrine.orm.entity_manager')
86 ->getRepository('WallabagCoreBundle:Entry')
87 ->findOneByIsArchived(false);
88
89 $crawler = $client->request('GET', '/view/'.$content->getId());
90
91 $this->assertEquals(200, $client->getResponse()->getStatusCode());
92 $this->assertContains($content->getTitle(), $client->getResponse()->getContent());
16 } 93 }
17} 94}