<commit_before><?php

namespace StaticPagesTest\Action;

use Interop\Http\ServerMiddleware\DelegateInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Prophet;
use Psr\Http\Message\ServerRequestInterface;
use StaticPages\Action\StaticPagesAction;
use Zend\Diactoros\Response\HtmlResponse;
use Zend\Expressive\Router\RouteResult;
use Zend\Expressive\Router\RouterInterface;
use Zend\Expressive\Template\TemplateRendererInterface;

class StaticPagesActionTest extends TestCase
{
    /**
     * @var Prophet
     */
    private $prophet;

    public function setUp()
    {
        $this->prophet = new Prophet;
    }

    /**
     * @dataProvider correctTemplateData
     * @param string $routeName
     * @param string $templateName
     */
    public function testDoesRequestCorrectTemplate($routeName, $templateName)
    {
        $delegate = $this->prophet->prophesize(DelegateInterface::class);
        $router = $this->prophet->prophesize(RouterInterface::class);
        $template = $this->prophet->prophesize(TemplateRendererInterface::class);
        $template
            ->render($templateName)
            ->shouldBeCalledTimes(1)
            ->willReturn('<html></html>');

        $action = new StaticPagesAction($router->reveal(), $template->reveal());

        $routeResult = $this->prophet->prophesize(RouteResult::class);
        $routeResult->getMatchedRouteName()
            ->willReturn($routeName);

        $request = $this->prophet->prophesize(ServerRequestInterface::class);
        $request->getAttribute("Zend\Expressive\Router\RouteResult")
            ->willReturn($routeResult->reveal());

        $this->assertInstanceOf(
            HtmlResponse::class,
            $action->process($request->reveal(), $delegate->reveal())
        );
    }

    /**
     * @return array
     */
    public function correctTemplateData()
    {
        return [
            [<commit_msg>Use the class resolution operator instead of a string<commit_after><?php

namespace StaticPagesTest\Action;

use Interop\Http\ServerMiddleware\DelegateInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Prophet;
use Psr\Http\Message\ServerRequestInterface;
use StaticPages\Action\StaticPagesAction;
use Zend\Diactoros\Response\HtmlResponse;
use Zend\Expressive\Router\RouteResult;
use Zend\Expressive\Router\RouterInterface;
use Zend\Expressive\Template\TemplateRendererInterface;

class StaticPagesActionTest extends TestCase
{
    /**
     * @var Prophet
     */
    private $prophet;

    public function setUp()
    {
        $this->prophet = new Prophet;
    }

    /**
     * @dataProvider correctTemplateData
     * @param string $routeName
     * @param string $templateName
     */
    public function testDoesRequestCorrectTemplate($routeName, $templateName)
    {
        $delegate = $this->prophet->prophesize(DelegateInterface::class);
        $router = $this->prophet->prophesize(RouterInterface::class);
        $template = $this->prophet->prophesize(TemplateRendererInterface::class);
        $template
            ->render($templateName)
            ->shouldBeCalledTimes(1)
            ->willReturn('<html></html>');

        $action = new StaticPagesAction($router->reveal(), $template->reveal());

        $routeResult = $this->prophet->prophesize(RouteResult::class);
        $routeResult->getMatchedRouteName()
            ->willReturn($routeName);

        $request = $this->prophet->prophesize(ServerRequestInterface::class);
        $request->getAttribute(RouteResult::class)
            ->willReturn($routeResult->reveal());

        $this->assertInstanceOf(
            HtmlResponse::class,
            $action->process($request->reveal(), $delegate->reveal())
        );
    }

    /**
     * @return array
     */
    public function correctTemplateData()
    {
        return [
            [
{'fraction_non_alphanumeric': 0.12669801462904912, 'fraction_numerical': 0.0005224660397074191, 'mean_word_length': 3.117204301075269, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 57, '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': '4807931', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1030, 'n_words': 166}