<commit_before><?php

namespace Lily\Test\Usage;

use Symfony\Component\DomCrawler\Crawler;

use Lily\Application\MiddlewareApplication;
use Lily\Application\RoutedApplication;

use Lily\Util\Request;
use Lily\Util\Response;

class DescribeTestingTest extends \PHPUnit_Framework_TestCase
{
    private function crawler($html)
    {
        return new Crawler($html);
    }

    private function applicationToTest()
    {
        $html = file_get_contents(dirname(__FILE__).'/example.html');
        return
            new MiddlewareApplication(
                [new RoutedApplication(
                    [['POST', '/form', $html]])]);
    }

    public function testFormShouldSuccessfullySubmit()
    {
        $application = $this->applicationToTest();
        $response = $application(Request::post('/form'));
        $crawler = $this->crawler($response['body']);
        $this->assertSame(1, $crawler->filter('h1.success')->count());
    }
}<commit_msg>Refactor some test logic out of test<commit_after><?php

namespace Lily\Test\Usage;

use Symfony\Component\DomCrawler\Crawler;

use Lily\Application\MiddlewareApplication;
use Lily\Application\RoutedApplication;

use Lily\Util\Request;
use Lily\Util\Response;

class DescribeTestingTest extends \PHPUnit_Framework_TestCase
{
    private function crawler($html)
    {
        return new Crawler($html);
    }

    private function applicationToTest()
    {
        $html = file_get_contents(dirname(__FILE__).'/example.html');
        return
            new MiddlewareApplication(
                [new RoutedApplication(
                    [['POST', '/form', $html]])]);
    }

    private function applicationResponse($request)
    {
        $application = $this->applicationToTest();
        return $application($request);
    }

    public function testFormShouldSuccessfullySubmit()
    {
        $response = $this->applicationResponse(Request::post('/form'));
        $crawler = $this->crawler($response['body']);
        $this->assertSame(1, $crawler->filter('h1.success')->count());
    }
}
{'fraction_non_alphanumeric': 0.13047711781888996, 'fraction_numerical': 0.0019474196689386564, 'mean_word_length': 3.1431451612903225, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '6604195', 'n_tokens_mistral': 579, 'n_tokens_neox': 570, 'n_words': 105}