diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-09 12:52:06 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-09 12:52:06 +0100 |
commit | 89c03230c3d51e618608b044b0e3f45cf0c06a11 (patch) | |
tree | 504e54ecfd8ae6203f76a19a910e5e6c5dee1c3e /src/Wallabag/CoreBundle/Tests/Controller | |
parent | 8af35ad932177e0363412a868afc128b406e3322 (diff) | |
parent | 3b815d2de5a852fe2ebad5827bd4c9070aa175ea (diff) | |
download | wallabag-89c03230c3d51e618608b044b0e3f45cf0c06a11.tar.gz wallabag-89c03230c3d51e618608b044b0e3f45cf0c06a11.tar.zst wallabag-89c03230c3d51e618608b044b0e3f45cf0c06a11.zip |
Merge pull request #1062 from wallabag/v2-relation-entry-user
add a real relation between user and entry
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 38 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | 40 |
2 files changed, 69 insertions, 9 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index fde210c9..5d8daea3 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -2,13 +2,24 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\CoreBundle\Tests\Controller; | 3 | namespace Wallabag\CoreBundle\Tests\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | 5 | use Wallabag\CoreBundle\Tests\WallabagTestCase; |
6 | 6 | ||
7 | class EntryControllerTest extends WebTestCase | 7 | class EntryControllerTest extends WallabagTestCase |
8 | { | 8 | { |
9 | public function testLogin() | ||
10 | { | ||
11 | $client = $this->getClient(); | ||
12 | |||
13 | $crawler = $client->request('GET', '/new'); | ||
14 | |||
15 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
16 | $this->assertContains('login', $client->getResponse()->headers->get('location')); | ||
17 | } | ||
18 | |||
9 | public function testGetNew() | 19 | public function testGetNew() |
10 | { | 20 | { |
11 | $client = static::createClient(); | 21 | $this->logIn(); |
22 | $client = $this->getClient(); | ||
12 | 23 | ||
13 | $crawler = $client->request('GET', '/new'); | 24 | $crawler = $client->request('GET', '/new'); |
14 | 25 | ||
@@ -20,7 +31,8 @@ class EntryControllerTest extends WebTestCase | |||
20 | 31 | ||
21 | public function testPostNewEmpty() | 32 | public function testPostNewEmpty() |
22 | { | 33 | { |
23 | $client = static::createClient(); | 34 | $this->logIn(); |
35 | $client = $this->getClient(); | ||
24 | 36 | ||
25 | $crawler = $client->request('GET', '/new'); | 37 | $crawler = $client->request('GET', '/new'); |
26 | 38 | ||
@@ -37,7 +49,8 @@ class EntryControllerTest extends WebTestCase | |||
37 | 49 | ||
38 | public function testPostNewOk() | 50 | public function testPostNewOk() |
39 | { | 51 | { |
40 | $client = static::createClient(); | 52 | $this->logIn(); |
53 | $client = $this->getClient(); | ||
41 | 54 | ||
42 | $crawler = $client->request('GET', '/new'); | 55 | $crawler = $client->request('GET', '/new'); |
43 | 56 | ||
@@ -55,13 +68,14 @@ class EntryControllerTest extends WebTestCase | |||
55 | 68 | ||
56 | $crawler = $client->followRedirect(); | 69 | $crawler = $client->followRedirect(); |
57 | 70 | ||
58 | $this->assertCount(1, $alert = $crawler->filter('h2 a')->extract(array('_text'))); | 71 | $this->assertGreaterThan(1, $alert = $crawler->filter('h2 a')->extract(array('_text'))); |
59 | $this->assertContains('Mailjet', $alert[0]); | 72 | $this->assertContains('Mailjet', $alert[0]); |
60 | } | 73 | } |
61 | 74 | ||
62 | public function testArchive() | 75 | public function testArchive() |
63 | { | 76 | { |
64 | $client = static::createClient(); | 77 | $this->logIn(); |
78 | $client = $this->getClient(); | ||
65 | 79 | ||
66 | $crawler = $client->request('GET', '/archive'); | 80 | $crawler = $client->request('GET', '/archive'); |
67 | 81 | ||
@@ -70,7 +84,8 @@ class EntryControllerTest extends WebTestCase | |||
70 | 84 | ||
71 | public function testStarred() | 85 | public function testStarred() |
72 | { | 86 | { |
73 | $client = static::createClient(); | 87 | $this->logIn(); |
88 | $client = $this->getClient(); | ||
74 | 89 | ||
75 | $crawler = $client->request('GET', '/starred'); | 90 | $crawler = $client->request('GET', '/starred'); |
76 | 91 | ||
@@ -79,13 +94,18 @@ class EntryControllerTest extends WebTestCase | |||
79 | 94 | ||
80 | public function testView() | 95 | public function testView() |
81 | { | 96 | { |
82 | $client = static::createClient(); | 97 | $this->logIn(); |
98 | $client = $this->getClient(); | ||
83 | 99 | ||
84 | $content = $client->getContainer() | 100 | $content = $client->getContainer() |
85 | ->get('doctrine.orm.entity_manager') | 101 | ->get('doctrine.orm.entity_manager') |
86 | ->getRepository('WallabagCoreBundle:Entry') | 102 | ->getRepository('WallabagCoreBundle:Entry') |
87 | ->findOneByIsArchived(false); | 103 | ->findOneByIsArchived(false); |
88 | 104 | ||
105 | if (!$content) { | ||
106 | $this->markTestSkipped('No content found in db.'); | ||
107 | } | ||
108 | |||
89 | $crawler = $client->request('GET', '/view/'.$content->getId()); | 109 | $crawler = $client->request('GET', '/view/'.$content->getId()); |
90 | 110 | ||
91 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 111 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php new file mode 100644 index 00000000..54cf5073 --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests\Controller; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagTestCase; | ||
6 | |||
7 | class SecurityControllerTest extends WallabagTestCase | ||
8 | { | ||
9 | public function testLogin() | ||
10 | { | ||
11 | $client = $this->getClient(); | ||
12 | |||
13 | $crawler = $client->request('GET', '/new'); | ||
14 | |||
15 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
16 | $this->assertContains('login', $client->getResponse()->headers->get('location')); | ||
17 | } | ||
18 | |||
19 | public function testLoginFail() | ||
20 | { | ||
21 | $client = $this->getClient(); | ||
22 | |||
23 | $crawler = $client->request('GET', '/login'); | ||
24 | |||
25 | $form = $crawler->filter('button[type=submit]')->form(); | ||
26 | $data = array( | ||
27 | '_username' => 'admin', | ||
28 | '_password' => 'admin', | ||
29 | ); | ||
30 | |||
31 | $client->submit($form, $data); | ||
32 | |||
33 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
34 | $this->assertContains('login', $client->getResponse()->headers->get('location')); | ||
35 | |||
36 | $crawler = $client->followRedirect(); | ||
37 | |||
38 | $this->assertContains('Bad credentials', $client->getResponse()->getContent()); | ||
39 | } | ||
40 | } | ||