From 7eddea6ff74d74b35a0c150a7b19e5f73118a58b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 14 Jun 2023 14:50:17 +0200 Subject: [PATCH] Added test --- src/Wallabag/CoreBundle/Entity/Config.php | 2 +- .../Controller/ConfigControllerTest.php | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index 750d4ced0..081d25027 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -120,7 +120,7 @@ class Config /** * @var int * - * @ORM\Column(name="display_thumbnails", type="integer", nullable=true) + * @ORM\Column(name="display_thumbnails", type="integer", nullable=true, options={"default" = 1}) * * @Groups({"config_api"}) */ diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 44de9dd26..03a7485df 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -1354,4 +1354,40 @@ class ConfigControllerTest extends WallabagCoreTestCase $this->assertCount(5, $taggingRules); $this->assertSame('title matches "football"', $taggingRules[4]->getRule()); } + + public function testSwitchDisplayThumbnails() + { + $this->logInAs('admin'); + $client = $this->getTestClient(); + + // Change configuration to show thumbnails + $crawler = $client->request('GET', '/config'); + $this->assertSame(200, $client->getResponse()->getStatusCode()); + $form = $crawler->filter('button[id=config_save]')->form(); + $data = [ + 'config[display_thumbnails]' => true, + ]; + $client->submit($form, $data); + $client->followRedirect(); + + $client->request('GET', '/unread/list'); + + $this->assertStringContainsString('class="preview"', $client->getResponse()->getContent()); + + // Change configuration to hide thumbnails + $crawler = $client->request('GET', '/config'); + $this->assertSame(200, $client->getResponse()->getStatusCode()); + $form = $crawler->filter('button[id=config_save]')->form(); + $data = [ + 'config[display_thumbnails]' => false, + ]; + $client->submit($form, $data); + $client->followRedirect(); + + $client->request('GET', '/unread/list'); + + $this->assertStringNotContainsString('class="preview"', $client->getResponse()->getContent()); + + $client->request('GET', '/config/view-mode'); + } }