<commit_before><?php

namespace Hmaus\Spas\Tests\Request;

use GuzzleHttp\Client;
use Hmaus\Spas\Request\HttpClient;
use Hmaus\Spas\SpasApplication;
use Hmaus\SpasParser\SpasRequest;
use Prophecy\Argument;
use Psr\Log\LoggerInterface;

class HttpClientTest extends \PHPUnit_Framework_TestCase
{
    public function testCanBuildGuzzleRequest()
    {
        $guzzle = $this->prophesize(Client::class);
        $logger = $this->prophesize(LoggerInterface::class);
        $app = $this->prophesize(SpasApplication::class);

        $app
            ->getName()
            ->willReturn('spas')
            ->shouldBeCalledTimes(1);

        $app
            ->getVersion()
            ->willReturn('0.1.0')
            ->shouldBeCalledTimes(1);

        $client = new HttpClient(
            $guzzle->reveal(),
            $logger->reveal(),
            $app->reveal()
        );

        $parsedRequest = new SpasRequest();
        $parsedRequest->setMethod('GET');
        $parsedRequest->setBaseUrl('http://example.com');
        $parsedRequest->setHref('/health');
        $parsedRequest->headers->set('X-Trv-Test0', 'zero');
        $parsedRequest->headers->set('X-Trv-Test1', 'one');
        $parsedRequest->setContent('I am content');

        $guzzle
            ->request(
                Argument::exact($parsedRequest->getMethod()),
                Argument::exact(
                    $parsedRequest->getBaseUrl().
                    $parsedRequest->getHref()
                ),
                Argument::exact([
                    'connect_timeout' => 10,
                    'timeout' => 10,
                    'headers' => [
                        'x-trv-test0' => ['zero'],
                        'x-trv-test1' => ['one'],
                        'User-Agent' => 'spas/v0.1.0', // user agent is added by the http client
                    ],
                    'body' => $parsedRequest->getContent()
                ])
            )
            ->shouldBeCalledTimes(1);

        $client->request($parsedRequest);
    }
}<commit_msg>Use a more generic header example<commit_after><?php

namespace Hmaus\Spas\Tests\Request;

use GuzzleHttp\Client;
use Hmaus\Spas\Request\HttpClient;
use Hmaus\Spas\SpasApplication;
use Hmaus\SpasParser\SpasRequest;
use Prophecy\Argument;
use Psr\Log\LoggerInterface;

class HttpClientTest extends \PHPUnit_Framework_TestCase
{
    public function testCanBuildGuzzleRequest()
    {
        $guzzle = $this->prophesize(Client::class);
        $logger = $this->prophesize(LoggerInterface::class);
        $app = $this->prophesize(SpasApplication::class);

        $app
            ->getName()
            ->willReturn('spas')
            ->shouldBeCalledTimes(1);

        $app
            ->getVersion()
            ->willReturn('0.1.0')
            ->shouldBeCalledTimes(1);

        $client = new HttpClient(
            $guzzle->reveal(),
            $logger->reveal(),
            $app->reveal()
        );

        $parsedRequest = new SpasRequest();
        $parsedRequest->setMethod('GET');
        $parsedRequest->setBaseUrl('http://example.com');
        $parsedRequest->setHref('/health');
        $parsedRequest->headers->set('X-Vnd-Test0', 'zero');
        $parsedRequest->headers->set('X-Vnd-Test1', 'one');
        $parsedRequest->setContent('I am content');

        $guzzle
            ->request(
                Argument::exact($parsedRequest->getMethod()),
                Argument::exact(
                    $parsedRequest->getBaseUrl().
                    $parsedRequest->getHref()
                ),
                Argument::exact([
                    'connect_timeout' => 10,
                    'timeout' => 10,
                    'headers' => [
                        'x-vnd-test0' => ['zero'],
                        'x-vnd-test1' => ['one'],
                        'User-Agent' => 'spas/v0.1.0', // user agent is added by the http client
                    ],
                    'body' => $parsedRequest->getContent()
                ])
            )
            ->shouldBeCalledTimes(1);

        $client->request($parsedRequest);
    }
}
{'fraction_non_alphanumeric': 0.14590402326708676, 'fraction_numerical': 0.008240426563257392, 'mean_word_length': 1.7222955145118735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, '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': '2342197', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1160, 'n_words': 175}