1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Add availability to disable an importer

This commit is contained in:
Nicolas Lœuillet 2025-05-26 15:45:55 +02:00
parent cad5a24fb6
commit 7e7674a4a6
17 changed files with 332 additions and 3 deletions

View file

@ -0,0 +1,45 @@
<?php
namespace Security\Voter;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Wallabag\Entity\SiteCredential;
use Wallabag\Entity\User;
use Wallabag\Security\Voter\ImportVoter;
class ImportVoterTest extends TestCase
{
private $token;
private $user;
private $importVoter;
protected function setUp(): void
{
$this->token = $this->createMock(TokenInterface::class);
$this->user = new User();
$this->importVoter = new ImportVoter();
}
public function testVoteReturnsAbstainForInvalidSubject(): void
{
$this->assertSame(VoterInterface::ACCESS_ABSTAIN, $this->importVoter->vote($this->token, new \stdClass(), [ImportVoter::USE_IMPORTER]));
}
public function testVoteReturnsAbstainForInvalidAttribute(): void
{
$this->assertSame(VoterInterface::ACCESS_ABSTAIN, $this->importVoter->vote($this->token, new SiteCredential(new User()), ['INVALID']));
}
public function testVoteReturnsDeniedForNonSiteCredentialUserEdit(): void
{
$this->assertSame(VoterInterface::ACCESS_DENIED, $this->importVoter->vote($this->token, new SiteCredential(new User()), [ImportVoter::USE_IMPORTER]));
}
public function testVoteReturnsGrantedForSiteCredentialUserEdit(): void
{
$this->assertSame(VoterInterface::ACCESS_GRANTED, $this->importVoter->vote($this->token, new SiteCredential($this->user), [ImportVoter::USE_IMPORTER]));
}
}