<commit_before><?php
/**
 * Test the Formatter Factory
 * @author <NAME>
 * @copyright <NAME>, 2014
 */

namespace AyeAye\Formatter\Tests;

use AyeAye\Formatter\FormatFactory;
use AyeAye\Formatter\Formats\Json;

class FormatFactoryTest extends TestCase
{

    /**
     * Test that the factory can return objects previously given to it
     */
    public function testFactoryObjects()
    {
        $factory = new FormatFactory([
            'json' => new Json(),
        ]);
        $this->assertTrue($factory->getFormatterFor('json') instanceof Json, 'Formatter for json not returned correctly');
    }

    /**
     * Test that the factory can return objects based on class names as strings
     */
    public function testFactoryStrings()
    {
        $factory = new FormatFactory([
            'json' => '\AyeAye\Formatter\Formats\Json',
        ]);
        $this->assertTrue($factory->getFormatterFor('json') instanceof Json, 'Formatter for json not returned correctly');
    }

    /**
     * @expectedException        \Exception
     * @expectedExceptionMessage Formatter for 'json' not a Formatter object or class
     */
    public function testNonFormatClassException()
    {
        $factory = new FormatFactory([
            'json' => new \stdClass(),
        ]);
        $factory->getFormatterFor('json');
    }

    /**
     * @expectedException        \Exception
     * @expectedExceptionMessage Formatter for 'json' not a Formatter object or class
     */
    public function testInvalidClassException()
    {
        $factory = new FormatFactory([
            'json' => 'this-is-an-invalid-class-name',
        ]);
        $factory->getFormatterFor('json');
    }

    /**
     * @expectedException        \Exception
     * @expectedExceptionMessage Formatter not found
     */
    public function testInvalidExtensionException()
    {
        $factory = new FormatFactory([]);
        $factory->getFormatterFor('json');
    }
}<commit_msg>Updated FormatFactory tests<commit_after><?php
/**
 * Test the Formatter Factory
 * @author <NAME>
 * @copyright <NAME>, 2014
 */

namespace AyeAye\Formatter\Tests;

use AyeAye\Formatter\FormatFactory;
use AyeAye\Formatter\Formats\Json;

/**
 * Class FormatFactoryTest
 * @package AyeAye\Formatter\Tests
 * @coversDefaultClass \AyeAye\Formatter\FormatFactory
 */
class FormatFactoryTest extends TestCase
{

    /**
     * @test
     * @covers ::__construct
     */
    public function testConstruct()
    {
        $formats = [
            'test' => new Json()
        ];
        $formatFactory = new FormatFactory($formats);
        $this->assertSame(
            $formats,
            $this->getObjectAttribute($formatFactory, 'formats')
        );
    }

    /**
     * @test
     * @covers ::getFormatterFor
     * @uses \AyeAye\Formatter\FormatFactory
     */
    public function testGetFormatterFor()
    {
        $factory = new FormatFactory([
            'json' => new Json(),
        ]);
        $this->assertInstanceOf(
            '\AyeAye\Formatter\Formats\Json',
            $factory->getFormatterFor('json')
        );

        $factory = new FormatFactory([
            'json' => '\AyeAye\Formatter\Formats\Json',
        ]);
        $this->assertInstanceOf(
            '\AyeAye\Formatter\Formats\Json',
            $factory->getFormatterFor('json')
        );
    }

    /**
     * @test
     * @covers ::getFormatterFor
     * @uses \AyeAye\Formatter\FormatFactory
     * @expectedException        \Exception
     * @expectedExceptionMessage Formatter not found
     */
    public function testInvalidExtensionException()
    {
        $factory = new FormatFactory([]);
        $factory->getFormatterFor('json');
    }

    /**
     * @test
     * @covers ::getSpecificFormatterFor
     * @uses \AyeAye\Formatter\FormatFactory
     */
    public function testGetSpecificFormatterFor()
    {
        $factory = new FormatFactory([
            'json' => new Json(),
        ]);
        $getSpecificFormatterFor = $this->getObjectMethod($factory, 'getSpecificFormatterFor');
        $this->assertInstanceOf(
            '\AyeAye\Formatter\Formats\Json',
            $getSpecificFormatterFor('json')
        );

        $factory = new FormatFactory([
            'json' => '\AyeAye\Formatter\Formats\Json',
        ]);
        $getSpecificFormatterFor = $this->getObjectMethod($factory, 'getSpecificFormatterFor');
        $this->assertInstanceOf(
            '\AyeAye\Formatter\Formats\Json',
            $getSpecificFormatterFor('json')
        );
    }

    /**
     * @test
     * @covers ::getSpecificFormatterFor
     * @uses \AyeAye\Formatter\FormatFactory
     * @expectedException        \Exception
     * @expectedExceptionMessage Formatter for 'json' not a Formatter object or class
     */
    public function testGetSpecificFormatterForNonFormatClassException()
    {
        $factory = new FormatFactory([
            'json' => new \stdClass(),
        ]);
        $factory->getFormatterFor('json');
    }

    /**
     * @test
     * @covers ::getSpecificFormatterFor
     * @uses \AyeAye\Formatter\FormatFactory
     * @expectedException        \Exception
     * @expectedExceptionMessage Formatter for 'json' not a Formatter object or class
     */
    public function testGetSpecificFormatterForInvalidClassException()
    {
        $factory = new FormatFactory([
            'json' => 'this-is-an-invalid-class-name',
        ]);
        $factory->getFormatterFor('json');
    }
}
{'fraction_non_alphanumeric': 0.12262426900584796, 'fraction_numerical': 0.0014619883040935672, 'mean_word_length': 2.331101643335362, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 38, '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': '1977201', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1440, 'n_words': 307}