<commit_before><?php

namespace Oro\Bundle\UserBundle\Tests\Functional;

use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\Kernel;

use Symfony\Component\Console\Application;

use Oro\Bundle\OrganizationBundle\Entity\Organization;
use Oro\Bundle\UserBundle\Command\GenerateWSSEHeaderCommand;
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase;

/**
 * @outputBuffering enabled
 * @dbIsolation
 * @dbReindex
 */
class CommandsTest extends WebTestCase
{
    protected function setUp()
    {
        $this->initClient();
    }

    public function testGenerateWsse()
    {
        /** @var Kernel $kernel */
        $kernel = $this->client->getKernel();

        /** @var Application $application */
        $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
        $application->setAutoExit(false);

        $doctrine =$this->client
            ->getContainer()
            ->get('doctrine');
        /** @var Organization $organization */
        $organization = $doctrine->getRepository('OroOrganizationBundle:Organization')
            ->getFirst();
        $user = $this->client
            ->getContainer()
            ->get('oro_user.manager')
            ->findUserByUsername('admin');
        $apiKey = $doctrine->getRepository('OroUserBundle:UserApi')->findOneBy(
            ['user' => $user, 'organization' => $organization]
        );

        $command = new GenerateWSSEHeaderCommand();
        $command->setApplication($application);
        $commandTester = new CommandTester($command);
        $commandTester->execute(
            array(
                'command' => $command->getName(),
                '--env' => $kernel->getEnvironment(),
                'apiKey' => $apiKey->getApiKey(),
            )
        );

        preg_match_all('/(^Authorization:\s*(.*$))|(^X-WSSE:\s*(.*$))/im', $commandTester->getDisplay(), $header);
<commit_msg>BAP-7889 User entity modification fixture fix<commit_after><?php

namespace Oro\Bundle\UserBundle\Tests\Functional;

use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\Kernel;

use Symfony\Component\Console\Application;

use Oro\Bundle\OrganizationBundle\Entity\Organization;
use Oro\Bundle\UserBundle\Command\GenerateWSSEHeaderCommand;
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase;

/**
 * @outputBuffering enabled
 * @dbIsolation
 * @dbReindex
 */
class CommandsTest extends WebTestCase
{
    protected function setUp()
    {
        $this->initClient();
    }

    public function testGenerateWsse()
    {
        /** @var Kernel $kernel */
        $kernel = $this->client->getKernel();

        /** @var Application $application */
        $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
        $application->setAutoExit(false);

        $doctrine =$this->client
            ->getContainer()
            ->get('doctrine');
        /** @var Organization $organization */
        $organization = $doctrine->getRepository('OroOrganizationBundle:Organization')
            ->getFirst();
        $user = $this->client
            ->getContainer()
            ->get('oro_user.manager')
            ->findUserByUsername('admin');
        $apiKey = $doctrine->getRepository('OroUserBundle:UserApi')->findOneBy(
            ['user' => $user, 'organization' => $organization]
        );
        
        static::assertInstanceOf('Oro\Bundle\UserBundle\Entity\UserApi', $apiKey, '$apiKey is not an object');

        $command = new GenerateWSSEHeaderCommand();
        $command->setApplication($application);
        $commandTester = new CommandTester($command);
        $commandTester->execute(
            array(
                'command' => $command->getName(),
                '--env' => $kernel->getEnvironment(),
                'apiKey' => $apiKey->getApiKey(),
            )
        );

        preg_match_all('/(^Authorization:\s*(.*$))|(^X-WSSE:\s*(.*$))/im', $commandTester->getDisplay(), $header);

{'fraction_non_alphanumeric': 0.14935064935064934, 'fraction_numerical': 0.000999000999000999, 'mean_word_length': 2.76056338028169, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, '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': '2766688', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1102, 'n_words': 174}