<commit_before><?php

/*
 * This file is part of the xAPI package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Xabbuh\LRSBundle\Tests\DependencyInjection;

use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
use Symfony\Component\DependencyInjection\Reference;
use Xabbuh\XApi\Bundle\LrsBundle\DependencyInjection\XabbuhLrsExtension;

/**
 * @author <NAME> <<EMAIL>>
 */
class XabbuhLrsExtensionTest extends AbstractExtensionTestCase
{
    /**
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
     */
    public function testStorageDriverIsRequired()
    {
        $this->load();

        $this->validateContainerBuilder();
    }

    public function testMongoDBStorageDriver()
    {
        $this->load(array('driver' => 'mongodb'));

        $this->validateContainerBuilder();
        $this->assertContainerBuilderHasService(
            'xabbuh_lrs.statement_manager',
            'Xabbuh\XApi\Storage\MongoDB\Manager\StatementManager'
        );
        $this->assertContainerBuilderHasServiceDefinitionWithArgument(
            'xabbuh_lrs.statement_manager',
            0,
            new Reference('xabbuh_lrs.statement_object_manager')
        );
        $this->assertContainerBuilderHasService('xabbuh_lrs.statement_object_manager');
    }

    protected function getContainerExtensions()
    {
        return array(new XabbuhLrsExtension());
    }

    private function validateContainerBuilder()
    {
        $this->validateSerializers();
        $this->validateControllers();
    }

    private function validateSerializers()
    {
        $serializers = array(
            'xabbuh_lrs.actor_serializer' => 'Xabbuh\XApi\Common\Serializer\ActorSerializer',
            'xabbuh_lrs.document_serializer' => 'Xabbuh\XApi\Common\Serializer\DocumentSerializer',
            'xabbuh_lrs.statement_result_serializer' => 'Xabbuh\XApi\Common\Serializer\StatementResultSerializer',
            'xabbuh_lrs.statement_serializer' => 'Xabbuh\XApi\Common\Serializer\StatementSerializer',
        );

        foreach ($serializers as $id => $class) {
            $this->assertContainerBuilderHasService(
                $id,
                $class
            );
            $this->assertContainerBuilderHasServiceDefinitionWithArgument(
                $id,
                0,
                new Reference('jms_serializer')
            );
        }
    }

    private function validateControllers()
    {
        $this->assertContainerBuilderHasService(
            'xabbuh_lrs.statements_controller',
            'Xabbuh\XApi\Bundle\LrsBundle\Controller\StatementsController'
        );
        $this->assertContainerBuilderHasServiceDefinitionWithArgument(
            'xabbuh_lrs.statements_controller',
            0,
            new Reference('xabbuh_lrs.statement_manager')
        );
        $this->assertContainerBuilderHasServiceDefinitionWithArgument(
            'xabbuh_lrs.statements_controller',
            1,
            new Reference('xabbuh_lrs.statement_serializer')
        );
    }
}<commit_msg>remove tests for not yet published classes<commit_after><?php

/*
 * This file is part of the xAPI package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Xabbuh\LRSBundle\Tests\DependencyInjection;

use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
use Symfony\Component\DependencyInjection\Reference;
use Xabbuh\XApi\Bundle\LrsBundle\DependencyInjection\XabbuhLrsExtension;

/**
 * @author <NAME> <<EMAIL>>
 */
class XabbuhLrsExtensionTest extends AbstractExtensionTestCase
{
    /**
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
     */
    public function testStorageDriverIsRequired()
    {
        $this->load();

        $this->validateContainerBuilder();
    }

    public function testMongoDBStorageDriver()
    {
        $this->load(array('driver' => 'mongodb'));

        $this->validateContainerBuilder();
        $this->assertContainerBuilderHasService(
            'xabbuh_lrs.statement_manager',
            'Xabbuh\XApi\Storage\MongoDB\Manager\StatementManager'
        );
        $this->assertContainerBuilderHasServiceDefinitionWithArgument(
            'xabbuh_lrs.statement_manager',
            0,
            new Reference('xabbuh_lrs.statement_object_manager')
        );
        $this->assertContainerBuilderHasService('xabbuh_lrs.statement_object_manager');
    }

    protected function getContainerExtensions()
    {
        return array(new XabbuhLrsExtension());
    }

    private function validateContainerBuilder()
    {
        $this->validateSerializers();
    }

    private function validateSerializers()
    {
        $serializers = array(
            'xabbuh_lrs.actor_serializer' => 'Xabbuh\XApi\Common\Serializer\ActorSerializer',
            'xabbuh_lrs.document_serializer' => 'Xabbuh\XApi\Common\Serializer\DocumentSerializer',
            'xabbuh_lrs.statement_result_serializer' => 'Xabbuh\XApi\Common\Serializer\StatementResultSerializer',
            'xabbuh_lrs.statement_serializer' => 'Xabbuh\XApi\Common\Serializer\StatementSerializer',
        );

        foreach ($serializers as $id => $class) {
            $this->assertContainerBuilderHasService(
                $id,
                $class
            );
            $this->assertContainerBuilderHasServiceDefinitionWithArgument(
                $id,
                0,
                new Reference('jms_serializer')
            );
        }
    }
}
{'fraction_non_alphanumeric': 0.10029345762126704, 'fraction_numerical': 0.0010357327809425167, 'mean_word_length': 2.7918848167539267, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 51, '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': '4940901', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1553, 'n_words': 231}