<commit_before><commit_msg>Add unit tests for factory<commit_after><?php

use Socks\Factory;

class FactoryTest extends TestCase
{
    /** @var Factory */
    private $factory;
    
    public function setUp()
    {
        $this->factory = new Factory($this->createLoop(), $this->createResolver());
    }
    
    public function testCreateClient()
    {
        $client = $this->factory->createClient('localhost', 9050);

        $this->assertInstanceOf('Socks\Client', $client);
    }
    
    public function testCreateServer()
    {
        $server = $this->factory->createServer($this->createSocket());
        
        $this->assertInstanceOf('Socks\Server', $server);
    }
    
    private function createLoop()
    {
        return React\EventLoop\Factory::create();
    }
    
    private function createResolver()
    {
        return $this->getMockBuilder('React\Dns\Resolver\Resolver')
            ->disableOriginalConstructor()
            ->getMock();
    }
    
    private function createSocket()
    {
        return $this->getMockBuilder('React\Socket\Server')
            ->disableOriginalConstructor()
            ->getMock();
    }
}
{'fraction_non_alphanumeric': 0.13494809688581316, 'fraction_numerical': 0.0034602076124567475, 'mean_word_length': 2.4332344213649852, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 19, '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': '3704278', 'n_tokens_mistral': 316, 'n_tokens_neox': 314, 'n_words': 56}