diff options
Diffstat (limited to 'tests/Wallabag/CoreBundle')
6 files changed, 88 insertions, 11 deletions
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index f684a206..bd351b18 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php | |||
@@ -5,6 +5,7 @@ namespace Tests\Wallabag\CoreBundle\Command; | |||
5 | use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver; | 5 | use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver; |
6 | use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand; | 6 | use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand; |
7 | use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand; | 7 | use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand; |
8 | use Doctrine\Bundle\MigrationsBundle\Command\MigrationsMigrateDoctrineCommand; | ||
8 | use Doctrine\DBAL\Platforms\PostgreSqlPlatform; | 9 | use Doctrine\DBAL\Platforms\PostgreSqlPlatform; |
9 | use Doctrine\DBAL\Platforms\SqlitePlatform; | 10 | use Doctrine\DBAL\Platforms\SqlitePlatform; |
10 | use Symfony\Bundle\FrameworkBundle\Console\Application; | 11 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
@@ -98,7 +99,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
98 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 99 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
99 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 100 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
100 | $this->assertContains('Config setup.', $tester->getDisplay()); | 101 | $this->assertContains('Config setup.', $tester->getDisplay()); |
101 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
102 | } | 102 | } |
103 | 103 | ||
104 | public function testRunInstallCommandWithReset() | 104 | public function testRunInstallCommandWithReset() |
@@ -125,7 +125,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
125 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); | 125 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); |
126 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 126 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
127 | $this->assertContains('Config setup.', $tester->getDisplay()); | 127 | $this->assertContains('Config setup.', $tester->getDisplay()); |
128 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
129 | 128 | ||
130 | // we force to reset everything | 129 | // we force to reset everything |
131 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); | 130 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); |
@@ -171,7 +170,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
171 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 170 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
172 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 171 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
173 | $this->assertContains('Config setup.', $tester->getDisplay()); | 172 | $this->assertContains('Config setup.', $tester->getDisplay()); |
174 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
175 | 173 | ||
176 | // the current database doesn't already exist | 174 | // the current database doesn't already exist |
177 | $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); | 175 | $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); |
@@ -198,7 +196,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
198 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 196 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
199 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 197 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
200 | $this->assertContains('Config setup.', $tester->getDisplay()); | 198 | $this->assertContains('Config setup.', $tester->getDisplay()); |
201 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
202 | 199 | ||
203 | $this->assertContains('Dropping schema and creating schema', $tester->getDisplay()); | 200 | $this->assertContains('Dropping schema and creating schema', $tester->getDisplay()); |
204 | } | 201 | } |
@@ -209,6 +206,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
209 | $application->add(new InstallCommand()); | 206 | $application->add(new InstallCommand()); |
210 | $application->add(new DropDatabaseDoctrineCommand()); | 207 | $application->add(new DropDatabaseDoctrineCommand()); |
211 | $application->add(new CreateDatabaseDoctrineCommand()); | 208 | $application->add(new CreateDatabaseDoctrineCommand()); |
209 | $application->add(new MigrationsMigrateDoctrineCommand()); | ||
212 | 210 | ||
213 | // drop database first, so the install command won't ask to reset things | 211 | // drop database first, so the install command won't ask to reset things |
214 | $command = new DropDatabaseDoctrineCommand(); | 212 | $command = new DropDatabaseDoctrineCommand(); |
@@ -242,7 +240,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
242 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 240 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
243 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 241 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
244 | $this->assertContains('Config setup.', $tester->getDisplay()); | 242 | $this->assertContains('Config setup.', $tester->getDisplay()); |
245 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
246 | 243 | ||
247 | $this->assertContains('Creating schema', $tester->getDisplay()); | 244 | $this->assertContains('Creating schema', $tester->getDisplay()); |
248 | } | 245 | } |
@@ -265,6 +262,5 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
265 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 262 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
266 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 263 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
267 | $this->assertContains('Config setup.', $tester->getDisplay()); | 264 | $this->assertContains('Config setup.', $tester->getDisplay()); |
268 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
269 | } | 265 | } |
270 | } | 266 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 6e806553..4ac4548b 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -137,6 +137,8 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
137 | $this->logInAs('admin'); | 137 | $this->logInAs('admin'); |
138 | $client = $this->getClient(); | 138 | $client = $this->getClient(); |
139 | 139 | ||
140 | $client->getContainer()->get('craue_config')->set('store_article_headers', 1); | ||
141 | |||
140 | $crawler = $client->request('GET', '/new'); | 142 | $crawler = $client->request('GET', '/new'); |
141 | 143 | ||
142 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | 144 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
@@ -165,6 +167,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
165 | $this->assertSame('2015-03-28 11:43:19', $content->getPublishedAt()->format('Y-m-d H:i:s')); | 167 | $this->assertSame('2015-03-28 11:43:19', $content->getPublishedAt()->format('Y-m-d H:i:s')); |
166 | $this->assertSame('Morgane Tual', $author[0]); | 168 | $this->assertSame('Morgane Tual', $author[0]); |
167 | $this->assertArrayHasKey('x-varnish1', $content->getHeaders()); | 169 | $this->assertArrayHasKey('x-varnish1', $content->getHeaders()); |
170 | $client->getContainer()->get('craue_config')->set('store_article_headers', 0); | ||
168 | } | 171 | } |
169 | 172 | ||
170 | public function testPostWithMultipleAuthors() | 173 | public function testPostWithMultipleAuthors() |
@@ -475,6 +478,40 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
475 | 478 | ||
476 | $data = [ | 479 | $data = [ |
477 | 'entry[title]' => 'My updated title hehe :)', | 480 | 'entry[title]' => 'My updated title hehe :)', |
481 | 'entry[origin_url]' => 'https://example.io', | ||
482 | ]; | ||
483 | |||
484 | $client->submit($form, $data); | ||
485 | |||
486 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
487 | |||
488 | $crawler = $client->followRedirect(); | ||
489 | |||
490 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); | ||
491 | $this->assertContains('My updated title hehe :)', $title[0]); | ||
492 | $this->assertGreaterThan(1, $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])); | ||
493 | $this->assertContains('example.io', trim($stats[1])); | ||
494 | } | ||
495 | |||
496 | public function testEditRemoveOriginUrl() | ||
497 | { | ||
498 | $this->logInAs('admin'); | ||
499 | $client = $this->getClient(); | ||
500 | |||
501 | $entry = new Entry($this->getLoggedInUser()); | ||
502 | $entry->setUrl($this->url); | ||
503 | $this->getEntityManager()->persist($entry); | ||
504 | $this->getEntityManager()->flush(); | ||
505 | |||
506 | $crawler = $client->request('GET', '/edit/' . $entry->getId()); | ||
507 | |||
508 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | ||
509 | |||
510 | $form = $crawler->filter('button[type=submit]')->form(); | ||
511 | |||
512 | $data = [ | ||
513 | 'entry[title]' => 'My updated title hehe :)', | ||
514 | 'entry[origin_url]' => '', | ||
478 | ]; | 515 | ]; |
479 | 516 | ||
480 | $client->submit($form, $data); | 517 | $client->submit($form, $data); |
@@ -483,8 +520,10 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
483 | 520 | ||
484 | $crawler = $client->followRedirect(); | 521 | $crawler = $client->followRedirect(); |
485 | 522 | ||
486 | $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); | 523 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); |
487 | $this->assertContains('My updated title hehe :)', $alert[0]); | 524 | $this->assertContains('My updated title hehe :)', $title[0]); |
525 | $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); | ||
526 | $this->assertNotContains('example.io', trim($stats[0])); | ||
488 | } | 527 | } |
489 | 528 | ||
490 | public function testToggleArchive() | 529 | public function testToggleArchive() |
diff --git a/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php index 87ea2867..f5074403 100644 --- a/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php | |||
@@ -8,6 +8,20 @@ use Wallabag\CoreBundle\Entity\SiteCredential; | |||
8 | 8 | ||
9 | class SiteCredentialControllerTest extends WallabagCoreTestCase | 9 | class SiteCredentialControllerTest extends WallabagCoreTestCase |
10 | { | 10 | { |
11 | public function testAccessDeniedBecauseFeatureDisabled() | ||
12 | { | ||
13 | $this->logInAs('admin'); | ||
14 | $client = $this->getClient(); | ||
15 | |||
16 | $client->getContainer()->get('craue_config')->set('restricted_access', 0); | ||
17 | |||
18 | $client->request('GET', '/site-credentials/'); | ||
19 | |||
20 | $this->assertSame(404, $client->getResponse()->getStatusCode()); | ||
21 | |||
22 | $client->getContainer()->get('craue_config')->set('restricted_access', 1); | ||
23 | } | ||
24 | |||
11 | public function testListSiteCredential() | 25 | public function testListSiteCredential() |
12 | { | 26 | { |
13 | $this->logInAs('admin'); | 27 | $this->logInAs('admin'); |
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php index 5d6a29fe..5aee9f5c 100644 --- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php +++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php | |||
@@ -68,7 +68,7 @@ class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase | |||
68 | $config = $this->builder->buildForHost('www.example.com'); | 68 | $config = $this->builder->buildForHost('www.example.com'); |
69 | 69 | ||
70 | $this->assertSame('example.com', $config->getHost()); | 70 | $this->assertSame('example.com', $config->getHost()); |
71 | $this->assertSame(true, $config->requiresLogin()); | 71 | $this->assertTrue($config->requiresLogin()); |
72 | $this->assertSame('http://www.example.com/login', $config->getLoginUri()); | 72 | $this->assertSame('http://www.example.com/login', $config->getLoginUri()); |
73 | $this->assertSame('login', $config->getUsernameField()); | 73 | $this->assertSame('login', $config->getUsernameField()); |
74 | $this->assertSame('password', $config->getPasswordField()); | 74 | $this->assertSame('password', $config->getPasswordField()); |
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index f94c2137..5c99e461 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -51,7 +51,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
51 | $this->assertEmpty($entry->getMimetype()); | 51 | $this->assertEmpty($entry->getMimetype()); |
52 | $this->assertEmpty($entry->getLanguage()); | 52 | $this->assertEmpty($entry->getLanguage()); |
53 | $this->assertSame(0.0, $entry->getReadingTime()); | 53 | $this->assertSame(0.0, $entry->getReadingTime()); |
54 | $this->assertSame(null, $entry->getDomainName()); | 54 | $this->assertNull($entry->getDomainName()); |
55 | } | 55 | } |
56 | 56 | ||
57 | public function testWithEmptyContent() | 57 | public function testWithEmptyContent() |
@@ -311,7 +311,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
311 | $tagger->expects($this->once()) | 311 | $tagger->expects($this->once()) |
312 | ->method('tag'); | 312 | ->method('tag'); |
313 | 313 | ||
314 | $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | 314 | $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true); |
315 | $entry = new Entry(new User()); | 315 | $entry = new Entry(new User()); |
316 | $proxy->updateEntry( | 316 | $proxy->updateEntry( |
317 | $entry, | 317 | $entry, |
@@ -341,6 +341,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
341 | $this->assertContains('Jeremy', $entry->getPublishedBy()); | 341 | $this->assertContains('Jeremy', $entry->getPublishedBy()); |
342 | $this->assertContains('Nico', $entry->getPublishedBy()); | 342 | $this->assertContains('Nico', $entry->getPublishedBy()); |
343 | $this->assertContains('Thomas', $entry->getPublishedBy()); | 343 | $this->assertContains('Thomas', $entry->getPublishedBy()); |
344 | $this->assertNotNull($entry->getHeaders(), 'Headers are stored, so value is not null'); | ||
344 | $this->assertContains('no-cache', $entry->getHeaders()); | 345 | $this->assertContains('no-cache', $entry->getHeaders()); |
345 | } | 346 | } |
346 | 347 | ||
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php index ceec4b37..82336060 100644 --- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php +++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php | |||
@@ -30,4 +30,31 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase | |||
30 | $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr')); | 30 | $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr')); |
31 | $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com')); | 31 | $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com')); |
32 | } | 32 | } |
33 | |||
34 | public function testRemoveSchemeAndWww() | ||
35 | { | ||
36 | $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
37 | ->disableOriginalConstructor() | ||
38 | ->getMock(); | ||
39 | |||
40 | $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository') | ||
41 | ->disableOriginalConstructor() | ||
42 | ->getMock(); | ||
43 | |||
44 | $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface') | ||
45 | ->disableOriginalConstructor() | ||
46 | ->getMock(); | ||
47 | |||
48 | $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface') | ||
49 | ->disableOriginalConstructor() | ||
50 | ->getMock(); | ||
51 | |||
52 | $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); | ||
53 | |||
54 | $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr')); | ||
55 | $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr')); | ||
56 | $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('https://www.lemonde.fr')); | ||
57 | $this->assertSame('gist.github.com', $extension->removeSchemeAndWww('https://gist.github.com')); | ||
58 | $this->assertSame('ftp://gist.github.com', $extension->removeSchemeAndWww('ftp://gist.github.com')); | ||
59 | } | ||
33 | } | 60 | } |