aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php55
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php38
2 files changed, 93 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
index 7085151a..7b32354f 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -479,4 +479,59 @@ class ConfigControllerTest extends WallabagCoreTestCase
479 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text'))); 479 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
480 $this->assertContains($expectedMessage, $alert[0]); 480 $this->assertContains($expectedMessage, $alert[0]);
481 } 481 }
482
483 public function testTaggingRuleCreation()
484 {
485 $this->logInAs('admin');
486 $client = $this->getClient();
487
488 $crawler = $client->request('GET', '/config');
489
490 $this->assertTrue($client->getResponse()->isSuccessful());
491
492 $form = $crawler->filter('button[id=tagging_rule_save]')->form();
493
494 $data = array(
495 'tagging_rule[rule]' => 'readingTime <= 3',
496 'tagging_rule[tags]' => 'short reading',
497 );
498
499 $client->submit($form, $data);
500
501 $this->assertEquals(302, $client->getResponse()->getStatusCode());
502
503 $crawler = $client->followRedirect();
504
505 $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
506 $this->assertContains('Tagging rules updated', $alert[0]);
507
508 $deleteLink = $crawler->filter('.delete')->last()->link();
509
510 $crawler = $client->click($deleteLink);
511 $this->assertEquals(302, $client->getResponse()->getStatusCode());
512
513 $crawler = $client->followRedirect();
514 $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
515 $this->assertContains('Tagging rule deleted', $alert[0]);
516 }
517
518 public function dataForTaggingRuleFailed()
519 {
520 return array(
521 array(
522 array(
523 'rss_config[rule]' => 'unknownVar <= 3',
524 'rss_config[tags]' => 'cool tag',
525 ),
526 'The variable « unknownVar » does not exist.',
527 ),
528 array(
529 array(
530 'rss_config[rule]' => 'length(domainName) <= 42',
531 'rss_config[tags]' => 'cool tag',
532 ),
533 'The operator « length » does not exist.',
534 ),
535 );
536 }
482} 537}
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 56b4c9e4..af62aee8 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -102,6 +102,44 @@ class EntryControllerTest extends WallabagCoreTestCase
102 $this->assertContains('Google', $alert[0]); 102 $this->assertContains('Google', $alert[0]);
103 } 103 }
104 104
105 /**
106 * This test will require an internet connection.
107 */
108 public function testPostNewThatWillBeTaggued()
109 {
110 $this->logInAs('admin');
111 $client = $this->getClient();
112
113 $crawler = $client->request('GET', '/new');
114
115 $this->assertEquals(200, $client->getResponse()->getStatusCode());
116
117 $form = $crawler->filter('button[type=submit]')->form();
118
119 $data = array(
120 'entry[url]' => $url = 'https://github.com/wallabag/wallabag',
121 );
122
123 $client->submit($form, $data);
124
125 $this->assertEquals(302, $client->getResponse()->getStatusCode());
126
127 $crawler = $client->followRedirect();
128
129 $em = $client->getContainer()
130 ->get('doctrine.orm.entity_manager');
131 $entry = $em
132 ->getRepository('WallabagCoreBundle:Entry')
133 ->findOneByUrl($url);
134 $tags = $entry->getTags();
135
136 $this->assertCount(1, $tags);
137 $this->assertEquals('wallabag', $tags[0]->getLabel());
138
139 $em->remove($entry);
140 $em->flush();
141 }
142
105 public function testArchive() 143 public function testArchive()
106 { 144 {
107 $this->logInAs('admin'); 145 $this->logInAs('admin');