<commit_before><?php

/*
 * This file is part of the DNS package for Icicle, a library for writing asynchronous code in PHP.
 *
 * @copyright 2015 <NAME>. All rights reserved.
 * @license MIT See the LICENSE file that was distributed with this source code for more information.
 */

namespace Icicle\Tests\Dns;

use Icicle\Dns;
use Icicle\Dns\Connector\ConnectorInterface;
use Icicle\Dns\Executor\ExecutorInterface;
use Icicle\Dns\Resolver\ResolverInterface;
use Icicle\Socket\SocketInterface;
use LibDNS\Messages\Message;

class FunctionsTest extends TestCase
{
    public function testGetExecutor()
    {
        $this->assertInstanceOf(ExecutorInterface::class, Dns\executor());
    }

    /**
     * @depends testGetExecutor
     */
    public function testSetExecutor()
    {
        $executor = $this->getMock(ExecutorInterface::class);
        Dns\executor($executor);

        $this->assertSame($executor, Dns\executor());
    }

    /**
     * @depends testSetExecutor
     */
    public function testExecute()
    {
        $executor = Dns\executor();

        $domain = 'icicle.io';
        $type = 'A';
        $options = ['timeout' => 1];

        $executor->expects($this->once())
            ->method('execute')
            ->with($this->identicalTo($domain), $this->identicalTo($type), $this->identicalTo($options))
            ->will($this->returnCallback(function () {
                yield $this->getMockBuilder(Message::class)
                    ->disableOriginalConstructor()
                    ->getMock();
            }));

        $this->assertInstanceOf(\Generator::class, Dns\execute($domain, $type, $options));
    }

    public function testGetResolver()
    {
        $this->assertInstanceOf(ResolverInterface::class, Dns\resolver());
    }

    /**
     * @depends testGetResolver
     */
    public function testSetResolver()
    {
        $resolver = $this->getMock(ResolverInterface::class);
        Dns\resolver($resolver);

        $this->assertSame($resolver, Dns\resolver());
    }

    /**
     * @depends testSetResolver
     */
    public function testResolve()
    {
        $resolver = Dns\resolver();

        $domain = 'icicle.io';
        $options = ['timeout' => 1];

        $resolver->expects($this->once())
            ->method('resolve')
            ->with($this->identicalTo($domain), $this->identicalTo($options))
            ->will($this->returnCallback(function () {
                yield [];
            }));

        $this->assertInstanceOf(\Generator::class, Dns\resolve($domain, $options));
    }

    public function testGetConnector()
    {
        $this->assertInstanceOf(ConnectorInterface::class, Dns\connector());
    }

    /**
     * @depends testGetConnector
     */
    public function testSetConnector()
    {
        $connector = $this->getMock(ConnectorInterface::class);
        Dns\connector($connector);

        $this->assertSame($connector, Dns\connector());
    }

    /**
     * @depends testSetConnector
     */
    public function testConnect()
    {
        $connector = Dns\connector();

        $domain = 'icicle.io';
        $port = 80;
        $options = ['timeout' => 1];

        $connector->expects($this->once())
            ->method('connect')
            ->with($this->identicalTo($domain), $this->identicalTo($port), $this->identicalTo($options))
            ->will($this->returnCallback(function () {
                yield $this->getMock(SocketInterface::class);
            }));<commit_msg>Update tests for 7<commit_after><?php

/*
 * This file is part of the DNS package for Icicle, a library for writing asynchronous code in PHP.
 *
 * @copyright 2015 <NAME>. All rights reserved.
 * @license MIT See the LICENSE file that was distributed with this source code for more information.
 */

namespace Icicle\Tests\Dns;

use Icicle\Dns;
use Icicle\Dns\Connector\ConnectorInterface;
use Icicle\Dns\Executor\ExecutorInterface;
use Icicle\Dns\Resolver\ResolverInterface;
use Icicle\Socket\SocketInterface;
use LibDNS\Messages\Message;

class FunctionsTest extends TestCase
{
    public function testGetExecutor()
    {
        $this->assertInstanceOf(ExecutorInterface::class, Dns\executor());
    }

    /**
     * @depends testGetExecutor
     */
    public function testSetExecutor()
    {
        $executor = $this->getMock(ExecutorInterface::class);
        Dns\executor($executor);

        $executor->expects($this->once())
            ->method('execute');

        Dns\executor()->execute('icicle.io', 'A');
    }

    /**
     * @depends testSetExecutor
     */
    public function testExecute()
    {
        $executor = Dns\executor();

        $domain = 'icicle.io';
        $type = 'A';
        $options = ['timeout' => 1];

        $executor->expects($this->once())
            ->method('execute')
            ->with($this->identicalTo($domain), $this->identicalTo($type), $this->identicalTo($options))
            ->will($this->returnCallback(function () {
                return yield $this->getMockBuilder(Message::class)
                    ->disableOriginalConstructor()
                    ->getMock();
            }));

        $this->assertInstanceOf(\Generator::class, Dns\execute($domain, $type, $options));
    }

    public function testGetResolver()
    {
        $this->assertInstanceOf(ResolverInterface::class, Dns\resolver());
    }

    /**
     * @depends testGetResolver
     */
    public function testSetResolver()
    {
        $resolver = $this->getMock(ResolverInterface::class);
        Dns\resolver($resolver);

        $resolver->expects($this->once())
            ->method('resolve');

        Dns\resolver()->resolve('icicle.io');
    }

    /**
     * @depends testSetResolver
     */
    public function testResolve()
    {
        $resolver = Dns\resolver();

        $domain = 'icicle.io';
        $options = ['timeout' => 1];

        $resolver->expects($this->once())
            ->method('resolve')
            ->with($this->identicalTo($domain), $this->identicalTo($options))
            ->will($this->returnCallback(function () {
                return yield [];
            }));

        $this->assertInstanceOf(\Generator::class, Dns\resolve($domain, $options));
    }

    public function testGetConnector()
    {
        $this->assertInstanceOf(ConnectorInterface::class, Dns\connector());
    }

    /**
     * @depends testGetConnector
     */
    public function testSetConnector()
    {
        $connector = $this->getMock(ConnectorInterface::class);
        Dns\connector($connector);

        $connector->expects($this->once())
            ->method('connect');

        Dns\connector()->connect('icicle.io', 80);
    }

    /**
     * @depends testSetConnector
     */
    public function testConnect()
    {
        $connector = Dns\connector();

        $domain = 'icicle.io';
        $port = 80;
        $options = ['timeout' => 1];

        $connector->expects($this->once())
            ->method('connect')
            ->with($this->identicalTo($domain), $this->identicalTo($port), $this->identicalTo($options))
            ->will($this->returnCallback(function () {
                return yield $this->getMock(SocketInterface::class);
            }));
{'fraction_non_alphanumeric': 0.15296075440299542, 'fraction_numerical': 0.0029122174455692693, 'mean_word_length': 2.4261282660332544, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 102, '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': '5796635', 'n_tokens_mistral': 2078, 'n_tokens_neox': 2023, 'n_words': 361}