<commit_before><?php

namespace CybozuHttpBundle\Tests\DependencyInjection;

use CybozuHttpBundle\DependencyInjection\CybozuHttpExtension;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;

/**
 * @author ochi51 <<EMAIL>>
 */
class CybozuHttpExtensionTest extends AbstractExtensionTestCase
{
    /**
     * @var array
     */
    private static $config = [
        'domain'            => 'cybozu.com',
        'subdomain'         => 'test',
        'use_api_token'     => false,
        'login'             => '<EMAIL>',
        'password'          => 'password',
        'token'             => null,
        'use_basic'         => true,
        'basic_login'       => 'basic_login',
        'basic_password'    => 'password',
        'use_client_cert'   => false,
        'cert_file'         => '/path/to/cert.pem',
        'cert_password'     => 'password'
    ];

    public function testParameters()
    {
        $this->load([
            'config' => self::$config,
            'cert_dir' => '/path/to/cert_dir',
            'debug' => true,
            'logfile' => '/path/to/logfile.log',
            'test' => true
        ]);

        $this->assertContainerBuilderHasParameter('cybozu_http.config', self::$config);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.domain');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.subdomain');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_api_token');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.login');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.password');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.token');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_basic');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.basic_login');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.basic_password');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_client_cert');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.cert_file');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.cert_password');
        $this->assertContainerBuilderHasParameter('cybozu_http.cert_dir');
        $this->assertContainerBuilderHasParameter('cybozu_http.debug');
        $this->assertContainerBuilderHasParameter('cybozu_http.logfile');
        $this->assertContainerBuilderHasParameter('cybozu_http.test', true);
    }

    public function testServiceDefinitions()
    {
        $this->load([
            'config' => self::$config
        ]);

        $this->assertContainerBuilderHasService('cybozu_http.client', 'CybozuHttp\Client');
        $this->assertContainerBuilderHasService('cybozu_http.kintone_api_client', 'CybozuHttp\Api\KintoneApi');
        $this->assertContainerBuilderHasService('cybozu_http.user_api_client', 'CybozuHttp\Api\UserApi');
    }

    /**
     * {@inheritdoc}
     */
    protected function getContainerExtensions()
    {
        return [new CybozuHttpExtension()];
    }
}
<commit_msg>Add tests<commit_after><?php

namespace CybozuHttpBundle\Tests\DependencyInjection;

use CybozuHttpBundle\DependencyInjection\CybozuHttpExtension;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;

/**
 * @author ochi51 <<EMAIL>>
 */
class CybozuHttpExtensionTest extends AbstractExtensionTestCase
{
    /**
     * @var array
     */
    private static $config = [
        'domain'            => 'cybozu.com',
        'subdomain'         => 'test',
        'use_api_token'     => false,
        'login'             => '<EMAIL>',
        'password'          => 'password',
        'token'             => null,
        'use_basic'         => true,
        'basic_login'       => 'basic_login',
        'basic_password'    => 'password',
        'use_client_cert'   => false,
        'cert_file'         => '/path/to/cert.pem',
        'cert_password'     => 'password'
    ];

    public function testParameters()
    {
        $this->load([
            'config' => self::$config,
            'cert_dir' => '/path/to/cert_dir',
            'debug' => true,
            'logfile' => '/path/to/logfile.log',
            'test' => true
        ]);

        $this->assertContainerBuilderHasParameter('cybozu_http.config', self::$config);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.domain', 'cybozu.com');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.subdomain', 'test');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_api_token', false);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.login', '<EMAIL>');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.password', 'password');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.token');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_basic', true);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.basic_login', 'basic_login');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.basic_password', 'password');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_client_cert', false);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.cert_file', '/path/to/cert.pem');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.cert_password', 'password');
        $this->assertContainerBuilderHasParameter('cybozu_http.cert_dir', '/path/to/cert_dir');
        $this->assertContainerBuilderHasParameter('cybozu_http.debug', true);
        $this->assertContainerBuilderHasParameter('cybozu_http.logfile', '/path/to/logfile.log');
        $this->assertContainerBuilderHasParameter('cybozu_http.test', true);
    }

    public function testNoneParameters()
    {
        $this->load();
        $this->assertContainerBuilderHasParameter('cybozu_http.config', []);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.domain', 'cybozu.com');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.subdomain');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_api_token', false);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.login');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.password');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.token');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_basic', false);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.basic_login');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.basic_password');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.use_client_cert', false);
        $this->assertContainerBuilderHasParameter('cybozu_http.config.cert_file');
        $this->assertContainerBuilderHasParameter('cybozu_http.config.cert_password');
        $this->assertContainerBuilderHasParameter('cybozu_http.cert_dir');
        $this->assertContainerBuilderHasParameter('cybozu_http.debug', false);
        $this->assertContainerBuilderHasParameter('cybozu_http.logfile');
        $this->assertContainerBuilderHasParameter('cybozu_http.test', false);
    }

    public function testServiceDefinitions()
    {
        $this->load([
            'config' => self::$config
        ]);

        $this->assertContainerBuilderHasService('cybozu_http.client', 'CybozuHttp\Client');
        $this->assertContainerBuilderHasService('cybozu_http.kintone_api_client', 'CybozuHttp\Api\KintoneApi');
        $this->assertContainerBuilderHasService('cybozu_http.user_api_client', 'CybozuHttp\Api\UserApi');
    }

    /**
     * {@inheritdoc}
     */
    protected function getContainerExtensions()
    {
        return [new CybozuHttpExtension()];
    }
}

{'fraction_non_alphanumeric': 0.13454317897371715, 'fraction_numerical': 0.0005006257822277847, 'mean_word_length': 3.5019718309859154, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 108, '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': '4149141', 'n_tokens_mistral': 2294, 'n_tokens_neox': 2284, 'n_words': 232}