<commit_before><?php namespace PascalKleindienst\FormListGenerator\Generators;

use PascalKleindienst\FormListGenerator\Support\Config;

/**
 * FormGenerator Testcase
 * @package \PascalKleindienst\FormListGenerator\Generators
 */
class FormGeneratorTest extends \PHPUnit_Framework_TestCase
{
    protected $generator;

    public function setup()
    {
        Config::set(['root' => __DIR__]);
        $this->generator = new FormGenerator('form.yaml');
    }

    /**
     * @param  mixed $obj
     * @param  string $propertyName
     * @return mixed
     */
    public function getProperty($obj, $propertyName)
    {
        $reflector = new \ReflectionClass($obj);
        $property = $reflector->getProperty($propertyName);
        $property->setAccessible(true);
 
        return $property->getValue($obj);
    }

    public function mockView($generator)
    {
        $generator->view = $this->getMock('stdClass', ['render']);
        $generator->view->expects($this->any())
                ->method('render')
                ->will($this->returnValue(''));

        return $generator;
    }

    public function testGetFactory()
    {
        $this->assertInstanceOf(\PascalKleindienst\FormListGenerator\Fields\FieldFactory::class, $this->generator->getFactory());
    }

    public function testRemoveField()
    {
        // Mock View Class so we do not output anything
        $generator = $this->mockView($this->generator);

        // Remove Fields
        $generator->removeField('test');
        <commit_msg>changed deprecated way of creating mocks to new one<commit_after><?php namespace PascalKleindienst\FormListGenerator\Generators;

use PascalKleindienst\FormListGenerator\Support\Config;

/**
 * FormGenerator Testcase
 * @package \PascalKleindienst\FormListGenerator\Generators
 */
class FormGeneratorTest extends \PHPUnit_Framework_TestCase
{
    protected $generator;

    public function setup()
    {
        Config::set(['root' => __DIR__]);
        $this->generator = new FormGenerator('form.yaml');
    }

    /**
     * @param  mixed $obj
     * @param  string $propertyName
     * @return mixed
     */
    public function getProperty($obj, $propertyName)
    {
        $reflector = new \ReflectionClass($obj);
        $property = $reflector->getProperty($propertyName);
        $property->setAccessible(true);
 
        return $property->getValue($obj);
    }

    public function mockView($generator)
    {
        $generator->view = $this->getMockBuilder('stdClass', ['render'])->getMock();
        $generator->view->expects($this->any())
                ->method('render')
                ->will($this->returnValue(''));

        return $generator;
    }

    public function testGetFactory()
    {
        $this->assertInstanceOf(\PascalKleindienst\FormListGenerator\Fields\FieldFactory::class, $this->generator->getFactory());
    }

    public function testRemoveField()
    {
        // Mock View Class so we do not output anything
        $generator = $this->mockView($this->generator);

        // Remove Fields
        $generator->removeField('test');
        
{'fraction_non_alphanumeric': 0.13346228239845262, 'fraction_numerical': 0.0, 'mean_word_length': 2.869077306733167, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, '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': '4539975', 'n_tokens_mistral': 856, 'n_tokens_neox': 838, 'n_words': 160}