Remove voter & add tests

This commit is contained in:
Jeremy Benoist
2025-10-02 11:54:12 +02:00
parent 7e7674a4a6
commit 5629330cb6
29 changed files with 269 additions and 154 deletions

View File

@ -91,7 +91,7 @@ class ChromeControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
public function testImportWallabagWithChromeFile()
public function testImportChromeWithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -132,7 +132,7 @@ class ChromeControllerTest extends WallabagTestCase
$this->assertSame('07', $createdAt->format('m'));
}
public function testImportWallabagWithEmptyFile()
public function testImportChromeWithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -155,4 +155,17 @@ class ChromeControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportChromeDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('chrome_enabled', 0);
$client->request('GET', '/import/chrome');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('chrome_enabled', 1);
}
}

View File

@ -200,4 +200,17 @@ class DeliciousControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportDeliciousDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('delicious_enabled', 0);
$client->request('GET', '/import/delicious');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('delicious_enabled', 1);
}
}

View File

@ -133,4 +133,17 @@ class ElcuratorControllerTest extends WallabagTestCase
$this->assertContains('tag1', $tags, 'It includes the "tag1" tag');
$this->assertContains('tag2', $tags, 'It includes the "tag2" tag');
}
public function testImportElcuratorDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('elcurator_enabled', 0);
$client->request('GET', '/import/elcurator');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('elcurator_enabled', 1);
}
}

View File

@ -91,7 +91,7 @@ class FirefoxControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
public function testImportWallabagWithFirefoxFile()
public function testImportFirefoxWithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -129,7 +129,7 @@ class FirefoxControllerTest extends WallabagTestCase
$this->assertCount(3, $content->getTags());
}
public function testImportWallabagWithEmptyFile()
public function testImportFirefoxWithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -152,4 +152,17 @@ class FirefoxControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportFirefoxDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('firefox_enabled', 0);
$client->request('GET', '/import/firefox');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('firefox_enabled', 1);
}
}

View File

@ -213,4 +213,17 @@ class InstapaperControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportInstapaperDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('instapaper_enabled', 0);
$client->request('GET', '/import/instapaper');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('instapaper_enabled', 1);
}
}

View File

@ -200,4 +200,17 @@ class OmnivoreControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportOmnivoreDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('omnivore_enabled', 0);
$client->request('GET', '/import/omnivore');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('omnivore_enabled', 1);
}
}

View File

@ -207,4 +207,17 @@ class PinboardControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportPinboardDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('pinboard_enabled', 0);
$client->request('GET', '/import/pinboard');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('pinboard_enabled', 1);
}
}

View File

@ -75,6 +75,11 @@ class PocketControllerTest extends WallabagTestCase
->method('getRequestToken')
->willReturn('token');
$pocketImport
->expects($this->once())
->method('isEnabled')
->willReturn(true);
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$client->request('POST', '/import/pocket/auth');
@ -97,6 +102,11 @@ class PocketControllerTest extends WallabagTestCase
->method('authorize')
->willReturn(false);
$pocketImport
->expects($this->once())
->method('isEnabled')
->willReturn(true);
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$client->request('GET', '/import/pocket/callback');
@ -131,6 +141,11 @@ class PocketControllerTest extends WallabagTestCase
->method('import')
->willReturn(true);
$pocketImport
->expects($this->once())
->method('isEnabled')
->willReturn(true);
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$client->request('GET', '/import/pocket/callback');
@ -139,4 +154,17 @@ class PocketControllerTest extends WallabagTestCase
$this->assertStringContainsString('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
$this->assertSame('flashes.import.notice.summary', $client->getContainer()->get(SessionInterface::class)->getFlashBag()->peek('notice')[0]);
}
public function testImportPocketDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('pocket_enabled', 0);
$client->request('GET', '/import/pocket');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('pocket_enabled', 1);
}
}

View File

@ -91,7 +91,7 @@ class PocketHtmlControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
public function testImportWallabagWithPocketHtmlFile()
public function testImportPocketHtmlWithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -129,7 +129,7 @@ class PocketHtmlControllerTest extends WallabagTestCase
$this->assertCount(3, $content->getTags());
}
public function testImportWallabagWithEmptyFile()
public function testImportPocketHtmlWithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -152,4 +152,17 @@ class PocketHtmlControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportPocketHtmlDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('pocket_html_enabled', 0);
$client->request('GET', '/import/pocket_html');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('pocket_html_enabled', 1);
}
}

View File

@ -205,4 +205,17 @@ class ReadabilityControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportReadabilityDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('readability_enabled', 0);
$client->request('GET', '/import/readability');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('readability_enabled', 1);
}
}

View File

@ -91,7 +91,7 @@ class ShaarliControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
public function testImportWallabagWithShaarliFile()
public function testImportShaarliWithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -129,7 +129,7 @@ class ShaarliControllerTest extends WallabagTestCase
$this->assertCount(2, $content->getTags());
}
public function testImportWallabagWithEmptyFile()
public function testImportShaarliWithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -152,4 +152,17 @@ class ShaarliControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportShaarliDisabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('shaarli_enabled', 0);
$client->request('GET', '/import/shaarli');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('shaarli_enabled', 1);
}
}

View File

@ -11,7 +11,7 @@ use Wallabag\Entity\Entry;
class WallabagV1ControllerTest extends WallabagTestCase
{
public function testImportWallabag()
public function testImportWallabagV1()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -23,7 +23,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportWallabagWithRabbitEnabled()
public function testImportWallabagV1WithRabbitEnabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -39,7 +39,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_rabbitmq', 0);
}
public function testImportWallabagBadFile()
public function testImportWallabagV1BadFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -56,7 +56,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportWallabagWithRedisEnabled()
public function testImportWallabagV1WithRedisEnabled()
{
$this->checkRedis();
$this->logInAs('admin');
@ -92,7 +92,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
public function testImportWallabagWithFile()
public function testImportWallabagV1WithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -136,7 +136,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
}
public function testImportWallabagWithFileAndMarkAllAsRead()
public function testImportWallabagV1WithFileAndMarkAllAsRead()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -183,7 +183,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
}
public function testImportWallabagWithEmptyFile()
public function testImportWallabagV1WithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -206,4 +206,17 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportWallabagV1Disabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('wallabag_v1_enabled', 0);
$client->request('GET', '/import/wallabag_v1');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('wallabag_v1_enabled', 1);
}
}

View File

@ -11,7 +11,7 @@ use Wallabag\Entity\Entry;
class WallabagV2ControllerTest extends WallabagTestCase
{
public function testImportWallabag()
public function testImportWallabagV2()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -23,7 +23,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportWallabagWithRabbitEnabled()
public function testImportWallabagV2WithRabbitEnabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -39,7 +39,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_rabbitmq', 0);
}
public function testImportWallabagBadFile()
public function testImportWallabagV2BadFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -56,7 +56,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportWallabagWithRedisEnabled()
public function testImportWallabagV2WithRedisEnabled()
{
$this->checkRedis();
$this->logInAs('admin');
@ -92,7 +92,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
public function testImportWallabagWithFile()
public function testImportWallabagV2WithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -158,7 +158,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$this->assertTrue($content->isStarred(), 'Entry is starred');
}
public function testImportWallabagWithEmptyFile()
public function testImportWallabagV2WithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@ -181,4 +181,17 @@ class WallabagV2ControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
}
public function testImportWallabagV2Disabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$client->getContainer()->get(Config::class)->set('wallabag_v2_enabled', 0);
$client->request('GET', '/import/wallabag_v2');
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->getContainer()->get(Config::class)->set('wallabag_v2_enabled', 1);
}
}