<commit_before><?php

namespace Kunstmaan\AdminBundle\Tests\Helper\AdminPanel;

use Kunstmaan\AdminBundle\Entity\User;
use Kunstmaan\AdminBundle\Helper\AdminPanel\AdminPanelAction;
use Kunstmaan\AdminBundle\Helper\AdminPanel\AdminPanelLogoutAction;
use Kunstmaan\AdminBundle\Helper\AdminPanel\DefaultAdminPanelAdaptor;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;

class DefaultAdminPanelAdapterTest extends TestCase
{
    use ExpectDeprecationTrait;

    public function testAdminPanelAdapter()
    {
        $requestStack = new RequestStack();
        $requestStack->push(new Request());

        $storage = new TokenStorage();
        $storage->setToken(new UsernamePasswordToken((new User())->setUsername('test'), 'password', '<PASSWORD>'));

        $logoutUrlGenerator = new LogoutUrlGenerator($requestStack, null, $storage);
        $logoutUrlGenerator->registerListener('main', '/logout', 'logout', '_token');

        $adapter = new DefaultAdminPanelAdaptor($storage, $logoutUrlGenerator);
        $actions = $adapter->getAdminPanelActions();

        $this->assertCount(3, $actions);
        $this->assertInstanceOf(AdminPanelAction::class, $actions[0]);
        $this->assertInstanceOf(AdminPanelAction::class, $actions[1]);
        $this->assertInstanceOf(AdminPanelLogoutAction::class, $actions[2]);<commit_msg>[AdminBundle] Fix symfony 5.4 security deprecation<commit_after><?php

namespace Kunstmaan\AdminBundle\Tests\Helper\AdminPanel;

use Kunstmaan\AdminBundle\Entity\User;
use Kunstmaan\AdminBundle\Helper\AdminPanel\AdminPanelAction;
use Kunstmaan\AdminBundle\Helper\AdminPanel\AdminPanelLogoutAction;
use Kunstmaan\AdminBundle\Helper\AdminPanel\DefaultAdminPanelAdaptor;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Bundle\SecurityBundle\Security\FirewallConfig;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;

class DefaultAdminPanelAdapterTest extends TestCase
{
    use ExpectDeprecationTrait;

    public function testAdminPanelAdapter()
    {
        $requestStack = new RequestStack();
        $requestStack->push(new Request());

        $storage = new TokenStorage();
        // NEXT_MAJOR: Remove check when symfony <5.4 support is dropped.
        if (method_exists(FirewallConfig::class, 'getAuthenticators')) {
            $token = new UsernamePasswordToken((new User())->setUsername('test'), 'main');
        } else {
            $token = new UsernamePasswordToken((new User())->setUsername('test'), null, 'main');
        }
        $storage->setToken($token);

        $logoutUrlGenerator = new LogoutUrlGenerator($requestStack, null, $storage);
        $logoutUrlGenerator->registerListener('main', '/logout', 'logout', '_token');

        $adapter = new DefaultAdminPanelAdaptor($storage, $logoutUrlGenerator);
        $actions = $adapter->getAdminPanelActions();

        $this->assertCount(3, $actions);
        $this->assertInstanceOf(AdminPanelAction::class, $actions[0]);
        $this->assertInstanceOf(AdminPanelAction::class, $actions[1]);
        $this->assertInstanceOf(AdminPanelLogoutAction::class, $actions[2]);
{'fraction_non_alphanumeric': 0.11951871657754011, 'fraction_numerical': 0.0032085561497326204, 'mean_word_length': 5.224625623960066, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3526879', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1038, 'n_words': 166}