<commit_before><?php

/**
 * This file is part of phpcq/autoload-validation.
 *
 * (c) 2014 <NAME>, <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * This project is provided in good faith and hope to be usable by anyone.
 *
 * @package    phpcq/autoload-validation
 * @author     <NAME> <<EMAIL>>
 * @copyright  2014-2016 <NAME> <<EMAIL>>
 * @license    https://github.com/phpcq/autoload-validation/blob/master/LICENSE MIT
 * @link       https://github.com/phpcq/autoload-validation
 * @filesource
 */

namespace PhpCodeQuality\AutoloadValidation\Test\AutoloadValidator;

use PhpCodeQuality\AutoloadValidation\AutoloadValidator\AutoloadValidatorFactory;
use PhpCodeQuality\AutoloadValidation\Report\Report;

/**
 * This class tests the AutoloadValidatorFactory.
 */
class AutoloadValidatorFactoryTest extends ValidatorTestCase
{
    /**
     * Mock the factory.
     *
     * @return AutoloadValidatorFactory
     */
    public function mockFactory()
    {
        $factory = new AutoloadValidatorFactory(
            '/some/dir',
            $this->mockClassMapGenerator(),
            new Report(array())
        );

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\AutoloadValidatorFactory',
            $factory
        );

        return $factory;
    }

    /**
     * Test that the factory creates a ClassMapValidator.
     *
     * @return void
     */
    public function testClassMapValidatorCreation()
    {
        $factory = $this->mockFactory();

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\ClassMapValidator',
            $factory->createValidator('autoload', 'classmap', array())
        );
    }

    /**
     * Test that the factory creates a FilesValidator.
     *
     * @return void
     */
    public function testFilesValidatorCreation()
    {
        $factory = $this->mockFactory();

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\FilesValidator',
            $factory->createValidator('autoload', 'files', array())
        );
    }

    /**
     * Test that the factory creates a Psr0Validator.
     *
     * @return void
     */
    public function testPsr0ValidatorCreation()
    {
        $factory = $this->mockFactory();

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\Psr0Validator',
            $factory->createValidator('autoload', 'psr-0', array())
        );
    }

    /**
     * Test that the factory creates a Psr4Validator.
     *
     * @return void
     */
    public function testPsr4ValidatorCreation()
    {
        $factory = $this->mockFactory();

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\Psr4Validator',
            $factory->createValidator('autoload', 'psr-4', array())
        );
    }

    /**
     * Test that the factory throws an exception for unknown type names.
     *
     * @return void
     *
     * @expectedException \InvalidArgumentException
     *
     * @expectedExceptionMessage Unknown auto loader type
     */
    public function testFactoryThrowsExceptionForUnknownType()
    {
        $factory = $this->mockFactory();

        $factory->createValidator('autoload', '----unkown-----type---name----', array());
    }

    /**<commit_msg>Coverage in Factory to 100%<commit_after><?php

/**
 * This file is part of phpcq/autoload-validation.
 *
 * (c) 2014 <NAME>, <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * This project is provided in good faith and hope to be usable by anyone.
 *
 * @package    phpcq/autoload-validation
 * @author     <NAME> <<EMAIL>>
 * @copyright  2014-2016 <NAME> <<EMAIL>>
 * @license    https://github.com/phpcq/autoload-validation/blob/master/LICENSE MIT
 * @link       https://github.com/phpcq/autoload-validation
 * @filesource
 */

namespace PhpCodeQuality\AutoloadValidation\Test\AutoloadValidator;

use PhpCodeQuality\AutoloadValidation\AutoloadValidator\AutoloadValidatorFactory;
use PhpCodeQuality\AutoloadValidation\Report\Report;

/**
 * This class tests the AutoloadValidatorFactory.
 */
class AutoloadValidatorFactoryTest extends ValidatorTestCase
{
    /**
     * Mock the factory.
     *
     * @return AutoloadValidatorFactory
     */
    public function mockFactory()
    {
        $factory = new AutoloadValidatorFactory(
            '/some/dir',
            $this->mockClassMapGenerator(),
            new Report(array())
        );

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\AutoloadValidatorFactory',
            $factory
        );

        return $factory;
    }

    /**
     * Test that the factory creates a ClassMapValidator.
     *
     * @return void
     */
    public function testClassMapValidatorCreation()
    {
        $factory = $this->mockFactory();

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\ClassMapValidator',
            $factory->createValidator('autoload', 'classmap', array())
        );
    }

    /**
     * Test that the factory creates a FilesValidator.
     *
     * @return void
     */
    public function testFilesValidatorCreation()
    {
        $factory = $this->mockFactory();

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\FilesValidator',
            $factory->createValidator('autoload', 'files', array())
        );
    }

    /**
     * Test that the factory creates a Psr0Validator.
     *
     * @return void
     */
    public function testPsr0ValidatorCreation()
    {
        $factory = $this->mockFactory();

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\Psr0Validator',
            $factory->createValidator('autoload', 'psr-0', array())
        );
    }

    /**
     * Test that the factory creates a Psr4Validator.
     *
     * @return void
     */
    public function testPsr4ValidatorCreation()
    {
        $factory = $this->mockFactory();

        $this->assertInstanceOf(
            'PhpCodeQuality\AutoloadValidation\AutoloadValidator\Psr4Validator',
            $factory->createValidator('autoload', 'psr-4', array())
        );
    }

    /**
     * Test that the factory creates a Psr4Validator.
     *
     * @return void
     */
    public function testExcludeFromClassmapSkippedInCreation()
    {
        $this->assertEmpty($this->mockFactory()->createValidator('autoload', 'exclude-from-classmap', array()));
    }

    /**
     * Test that the factory throws an exception for unknown type names.
     *
     * @return void
     *
     * @expectedException \InvalidArgumentException
     *
     * @expectedExceptionMessage Unknown auto loader type
     */
    public function testFactoryThrowsExceptionForUnknownType()
    {
        $factory = $this->mockFactory();

        $factory->createValidator('autoload', '----unkown-----type---name----', array());
    }

    /**
{'fraction_non_alphanumeric': 0.11551246537396122, 'fraction_numerical': 0.006094182825484765, 'mean_word_length': 2.522439024390244, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 54, 'https://': 4, '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': '6717211', 'n_tokens_mistral': 2053, 'n_tokens_neox': 1985, 'n_words': 415}