Move Annotation controller to Core

This commit is contained in:
Yassine Guedidi
2023-12-25 18:37:15 +01:00
parent eb36d692aa
commit 2ed8c219cc
7 changed files with 28 additions and 80 deletions

View File

@ -1,58 +0,0 @@
<?php
namespace Tests\Wallabag\AnnotationBundle;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Model\UserManager;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
abstract class WallabagAnnotationTestCase extends WebTestCase
{
/**
* @var KernelBrowser
*/
protected $client;
/**
* @var UserInterface
*/
protected $user;
protected function setUp(): void
{
parent::setUp();
$this->client = $this->createAuthorizedClient();
}
public function logInAs($username)
{
$crawler = $this->client->request('GET', '/login');
$form = $crawler->filter('button[type=submit]')->form();
$data = [
'_username' => $username,
'_password' => 'mypassword',
];
$this->client->submit($form, $data);
}
/**
* @return KernelBrowser
*/
protected function createAuthorizedClient()
{
$client = static::createClient();
$container = $client->getContainer();
/** @var UserManager $userManager */
$userManager = $container->get('fos_user.user_manager.test');
$firewallName = $container->getParameter('fos_user.firewall_name');
$this->user = $userManager->findUserBy(['username' => 'admin']);
$client->loginUser($this->user, $firewallName);
return $client;
}
}

View File

@ -1,15 +1,30 @@
<?php
namespace Tests\Wallabag\AnnotationBundle\Controller;
namespace Tests\Wallabag\CoreBundle\Controller;
use Doctrine\ORM\EntityManagerInterface;
use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\UserBundle\Entity\User;
class AnnotationControllerTest extends WallabagAnnotationTestCase
class AnnotationControllerTest extends WallabagCoreTestCase
{
/**
* @var KernelBrowser
*/
private $client;
protected function setUp(): void
{
parent::setUp();
$this->logInAs('admin');
$this->client = $this->getTestClient();
}
/**
* This data provider allow to tests annotation from the :
* - API POV (when user use the api to manage annotations)