<commit_before><?php

namespace CL\Bundle\TriggerBundle\Tests\Util;

use CL\Bundle\TriggerBundle\Tests\AbstractTestCase;
use CL\Bundle\TriggerBundle\Util\RedirectHelper;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

class RedirectHelperTest extends AbstractTestCase
{
    private $expectedQuery = [
        'foo' => 'bar',
    ];

    public function testCreateFromRequestWithoutParameters()
    {
        $redirect    = $this->createRedirect([]);
        $actualQuery = $this->getQueryFromRedirect($redirect);

        $this->assertArrayHasKey('foo', $actualQuery);
        $this->assertEquals($this->expectedQuery['foo'], $actualQuery['foo']);
    }

    public function testCreateFromRequestWithParameters()
    {
        $redirect    = $this->createRedirect(['foo']);
        $actualQuery = $this->getQueryFromRedirect($redirect);

        $this->assertArrayNotHasKey('foo', $actualQuery);
    }

    /**
     * @param array $withoutParameters
     *
     * @return RedirectResponse
     */
    private function createRedirect(array $withoutParameters)
    {
        $request        = Request::create('/test', 'GET', $this->expectedQuery);
        $redirectHelper = new RedirectHelper($request, $withoutParameters);
        $redirect       = $redirectHelper->create();

        $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $redirect);

        return $redirect;
    }

    /**
     * @param RedirectResponse $redirectResponse
     *<commit_msg>fixes<commit_after><?php

namespace CL\Bundle\TriggerBundle\Tests\Util;

use CL\Bundle\TriggerBundle\Tests\AbstractTestCase;
use CL\Bundle\TriggerBundle\Util\RedirectHelper;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

class RedirectHelperTest extends AbstractTestCase
{
    public function testCreateFromRequestWithoutParameters()
    {
        $currentQuery = ['foo' => 'bar'];
        $redirect     = $this->createRedirect($currentQuery);
        $actualQuery  = $this->getQueryFromRedirect($redirect);

        $this->assertArrayHasKey('foo', $actualQuery);
        $this->assertEquals($currentQuery['foo'], $actualQuery['foo']);
    }

    public function testCreateFromRequestWithParameters()
    {
        $redirect    = $this->createRedirect(['foo' => 'bar'], ['foo']);
        $actualQuery = $this->getQueryFromRedirect($redirect);

        $this->assertArrayNotHasKey('foo', $actualQuery);
    }

    /**
     * @param array $currentQuery
     * @param array $withoutParameters
     *
     * @return RedirectResponse
     */
    private function createRedirect(array $currentQuery, array $withoutParameters = [])
    {
        $request        = Request::create('/test', 'GET', $currentQuery);
        $redirectHelper = new RedirectHelper($request, $withoutParameters);
        $redirect       = $redirectHelper->create();

        $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $redirect);

        return $redirect;
    }

    /**
     * @param RedirectResponse $redirectResponse
     *
{'fraction_non_alphanumeric': 0.1310897435897436, 'fraction_numerical': 0.0, 'mean_word_length': 3.5297532656023223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, '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': '2210106', 'n_tokens_mistral': 822, 'n_tokens_neox': 808, 'n_words': 136}