<commit_before><?php

namespace Tests\Controllers;

use App\Bootstrap\ViewComposer;
use App\Controllers\DirectoryController;
use Psr\Http\Message\ResponseInterface;
use Slim\Psr7\Response;
use Slim\Views\Twig;
use Symfony\Component\Finder\Finder;
use Tests\TestCase;

class DirectoryControllerTest extends TestCase
{
    public function test_it_returns_a_response(): void
    {
        $this->container->call(ViewComposer::class);

        $controller = new DirectoryController(
            $this->container,
            $this->config,
            $this->container->get(Twig::class)
        );

        $response = $controller(
            new Finder(),
            new Response(),
            'tests/files'
        );

        $this->assertInstanceOf(ResponseInterface::class, $response);
        $this->assertEquals(200, $response->getStatusCode());
    }

    public function test_it_returns_a_404_error_when_not_found()
    {
        $this->container->call(ViewComposer::class);

        $controller = new DirectoryController(
            $this->container,
            $this->config,
            $this->container->get(Twig::class)
        );

        $response = $controller(
            new Finder(),
            new Response(),
            '404'
        );

        $this->assertInstanceOf(ResponseInterface::class, $response);
        $this->assertEquals(404, $response->getStatusCode());
    }
}<commit_msg>Added search request test<commit_after><?php

namespace Tests\Controllers;

use App\Bootstrap\ViewComposer;
use App\Controllers\DirectoryController;
use Psr\Http\Message\ResponseInterface;
use Slim\Psr7\Request;
use Slim\Psr7\Response;
use Slim\Views\Twig;
use Symfony\Component\Finder\Finder;
use Tests\TestCase;

class DirectoryControllerTest extends TestCase
{
    public function test_it_returns_a_response(): void
    {
        $this->container->call(ViewComposer::class);

        $controller = new DirectoryController(
            $this->container,
            $this->config,
            $this->container->get(Twig::class)
        );

        $response = $controller(
            new Finder(),
            $this->createMock(Request::class),
            new Response(),
            'tests/files'
        );

        $this->assertInstanceOf(ResponseInterface::class, $response);
        $this->assertEquals(200, $response->getStatusCode());
    }

    public function test_it_returns_a_404_error_when_not_found()
    {
        $this->container->call(ViewComposer::class);

        $controller = new DirectoryController(
            $this->container,
            $this->config,
            $this->container->get(Twig::class)
        );

        $response = $controller(
            new Finder(),
            $this->createMock(Request::class),
            new Response(),
            '404'
        );

        $this->assertInstanceOf(ResponseInterface::class, $response);
        $this->assertEquals(404, $response->getStatusCode());
    }

    public function test_it_returns_a_successful_response_for_a_search()
    {
        $this->container->call(ViewComposer::class);

        $controller = new DirectoryController(
            $this->container,
            $this->config,
            $this->container->get(Twig::class)
        );

        $request = $this->createMock(Request::class);
        $request->method('getQueryParams')->willReturn([
            'search' => 'charlie'
        ]);

        $response = $controller(
            new Finder(),
            $request,
            new Response(),
            'tests/files'
        );

        $this->assertInstanceOf(ResponseInterface::class, $response);
        $this->assertEquals(200, $response->getStatusCode());
    }
}
{'fraction_non_alphanumeric': 0.12922411462557448, 'fraction_numerical': 0.008110300081103, 'mean_word_length': 2.4195933456561924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 54, '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': '4621104', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1006, 'n_words': 162}