<commit_before><?php
/**
 * This file is part of the PHP Rebilly API package.
 *
 * (c) 2015 Rebilly SRL
 *
 * For the full copyright and license information, please view the LICENSE.md
 * file that was distributed with this source code.
 */

namespace Rebilly\Tests;

use ArrayObject;
use Rebilly\ApiKeyProvider;
use Rebilly\Client;
use Rebilly\Http\Exception\HttpException;
use Rebilly\Http\Exception\UnprocessableEntityException;
use Rebilly\ParamBag;
use Rebilly\Rest\Service;
use RuntimeException;
use Psr\Http\Message\RequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\UriInterface as Uri;

/**
 * Class ClientTest.
 *
 * @author <NAME> <<EMAIL>>
 * @version 0.1
 */
final class ClientTest extends TestCase
{
    /**
     * @test
     */
    public function autoloadClasses()
    {
        $this->assertEquals(true, class_exists(Client::class));

        Client::autoload(ParamBag::class);

        $this->assertEquals(true, class_exists(ParamBag::class, false));

        Client::registerAutoloader();
        $this->assertTrue(in_array([Client::class, 'autoload'], spl_autoload_functions()));

        Client::unregisterAutoloader();
        $this->assertFalse(in_array([Client::class, 'autoload'], spl_autoload_functions()));
    }

    /**
     * @test
     */
    public function initClient()
    {
        try {
            new Client([]);
        } catch (RuntimeException $e) {
            $this->assertEquals('Missed API Key', $e->getMessage());
        }

        try {
            new Client([
                'apiKey' => ApiKeyProvider::env(),
                'httpHandler' => 'invalid',
            ]);
        } catch (RuntimeException $e) {
            $this->assertEquals('HTTP handler should be callable', $e->getMessage());
        }
<commit_msg>Improve Client unit tests<commit_after><?php
/**
 * This file is part of the PHP Rebilly API package.
 *
 * (c) 2015 Rebilly SRL
 *
 * For the full copyright and license information, please view the LICENSE.md
 * file that was distributed with this source code.
 */

namespace Rebilly\Tests;

use ArrayObject;
use Rebilly\ApiKeyProvider;
use Rebilly\Client;
use Rebilly\Http\Exception\HttpException;
use Rebilly\Http\Exception\UnprocessableEntityException;
use Rebilly\ParamBag;
use Rebilly\Rest\Service;
use RuntimeException;
use Psr\Http\Message\RequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\UriInterface as Uri;

/**
 * Class ClientTest.
 *
 * @author <NAME> <<EMAIL>>
 * @version 0.1
 */
final class ClientTest extends TestCase
{
    /**
     * @test
     */
    public function autoloadClasses()
    {
        $this->assertEquals(true, class_exists(Client::class));

        Client::autoload(ParamBag::class);

        $this->assertEquals(true, class_exists(ParamBag::class, false));

        Client::registerAutoloader();
        $this->assertTrue(in_array([Client::class, 'autoload'], spl_autoload_functions()));

        Client::unregisterAutoloader();
        $this->assertFalse(in_array([Client::class, 'autoload'], spl_autoload_functions()));
    }

    /**
     * @test
     */
    public function initClient()
    {
        try {
            new Client([]);
        } catch (RuntimeException $e) {
            $this->assertEquals('Missed API Key', $e->getMessage());
        }

        try {
            new Client([
                'apiKey' => ApiKeyProvider::env(),
                'httpHandler' => 'invalid',
            ]);
        } catch (RuntimeException $e) {
            $this->assertEquals('HTTP handler should be callable', $e->getMessage());
        }

        try {
            new Client([
                'apiKey' => ApiKeyProvider::env(),
                'middleware' => 'invalid',
            ]);
        } catch (RuntimeException $e) {
            $this->assertEquals('Middleware should be callable', $e->getMessage());
        }

{'fraction_non_alphanumeric': 0.1325545962417471, 'fraction_numerical': 0.0030472320975114273, 'mean_word_length': 2.740740740740741, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, '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': '5070682', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1132, 'n_words': 266}