<commit_before><?php

use Clue\React\Buzz\Io\Sender;
use RingCentral\Psr7\Request;
use React\Promise;
use Clue\React\Block;

class SenderTest extends TestCase
{
    private $loop;

    public function setUp()
    {
        $this->loop = $this->getMock('React\EventLoop\LoopInterface');
    }

    public function testCreateFromLoop()
    {
        $sender = Sender::createFromLoop($this->loop);

        $this->assertInstanceOf('Clue\React\Buzz\Io\Sender', $sender);
    }

    public function testCreateFromLoopConnectors()
    {
        $connector = $this->getMock('React\SocketClient\ConnectorInterface');

        $sender = Sender::createFromLoopConnectors($this->loop, $connector);

        $this->assertInstanceOf('Clue\React\Buzz\Io\Sender', $sender);
    }

    public function testCreateFromLoopUnix()
    {
        $sender = Sender::createFromLoopUnix($this->loop, 'unix:///run/daemon.sock');

        $this->assertInstanceOf('Clue\React\Buzz\Io\Sender', $sender);
    }

    public function testSenderRejection()
    {
        $connector = $this->getMock('React\SocketClient\ConnectorInterface');
        $connector->expects($this->once())->method('create')->willReturn(Promise\reject(new RuntimeException('Rejected')));

        $sender = Sender::createFromLoopConnectors($this->loop, $connector);

        $request = new Request('GET', 'http://www.google.com/');

        $promise = $sender->send($request, $this->getMock('Clue\React\Buzz\Message\MessageFactory'));

        $this->setExpectedException('RuntimeException');
        Block\await($promise, $this->loop);
    }
}
<commit_msg>Test protocol version passing into http client request creation call<commit_after><?php

use Clue\React\Buzz\Io\Sender;
use React\HttpClient\RequestData;
use RingCentral\Psr7\Request;
use React\Promise;
use Clue\React\Block;

class SenderTest extends TestCase
{
    private $loop;

    public function setUp()
    {
        $this->loop = $this->getMock('React\EventLoop\LoopInterface');
    }

    public function testCreateFromLoop()
    {
        $sender = Sender::createFromLoop($this->loop);

        $this->assertInstanceOf('Clue\React\Buzz\Io\Sender', $sender);
    }

    public function testCreateFromLoopConnectors()
    {
        $connector = $this->getMock('React\SocketClient\ConnectorInterface');

        $sender = Sender::createFromLoopConnectors($this->loop, $connector);

        $this->assertInstanceOf('Clue\React\Buzz\Io\Sender', $sender);
    }

    public function testCreateFromLoopUnix()
    {
        $sender = Sender::createFromLoopUnix($this->loop, 'unix:///run/daemon.sock');

        $this->assertInstanceOf('Clue\React\Buzz\Io\Sender', $sender);
    }

    public function testSenderRejection()
    {
        $connector = $this->getMock('React\SocketClient\ConnectorInterface');
        $connector->expects($this->once())->method('create')->willReturn(Promise\reject(new RuntimeException('Rejected')));

        $sender = Sender::createFromLoopConnectors($this->loop, $connector);

        $request = new Request('GET', 'http://www.google.com/');

        $promise = $sender->send($request, $this->getMock('Clue\React\Buzz\Message\MessageFactory'));

        $this->setExpectedException('RuntimeException');
        Block\await($promise, $this->loop);
    }

    public function provideRequestProtocolVersion()
    {
        return array(
            array(
                new Request('GET', 'http://www.google.com/'),
                'GET',
                'http://www.google.com/',
                array(
                    'Host' => 'www.google.com',
                ),
                '1.1',
            ),
            array(
                new Request('GET', 'http://www.google.com/', array(), '', '1.0'),
                'GET',
                'http://www.google.com/',
                array(
                    'Host' => 'www.google.com',
                ),
                '1.0',
            ),
        );
    }

    /**
     * @dataProvider provideRequestProtocolVersion
     */
    public function testRequestProtocolVersion(Request $Request, $method, $uri, $headers, $protocolVersion)
    {
        $http = $this->getMock(
            'React\HttpClient\Client',
            array(
                'request',
            ),
            array(
                $this->getMock('React\SocketClient\ConnectorInterface'),
                $this->getMock('React\SocketClient\ConnectorInterface')
            )
        );
        $request = $this->getMock(
            'React\HttpClient\Request',
            array(),
            array(
                $this->getMock('React\SocketClient\ConnectorInterface'),
                new RequestData($method, $uri, $headers, $protocolVersion)
            )
        );
        $http->expects($this->once())->method('request')->with($method, $uri, $headers, $protocolVersion)->willReturn($request);

        $sender = new Sender($http);
        $sender->send($Request, $this->getMock('Clue\React\Buzz\Message\MessageFactory'));
    }
}

{'fraction_non_alphanumeric': 0.1554269752593775, 'fraction_numerical': 0.0015961691939345571, 'mean_word_length': 2.500698324022346, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, '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': '5414021', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1440, 'n_words': 206}