<commit_before><?php declare(strict_types=1); # -*- coding: utf-8 -*-

namespace Bueltge\Marksimple\Tests\Unit;

use Bueltge\Marksimple\Exception\UnknownRuleException;
use Bueltge\Marksimple\Marksimple;
use Bueltge\Marksimple\Rule\ElementRuleInterface;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Exception;
use Psr\Log\NullLogger;

class MarksimpleTest extends AbstractTestCase
{

    public function testBasic()
    {
        $testee = new Marksimple();
        try {
            static::assertInternalType('object', $testee);
        } catch (Exception $e) {
        }
    }

    public function testAddRule()
    {
        $expectedName = 'foo';

        $stub = $this->getMockBuilder(ElementRuleInterface::class)->getMock();

        $testee = new Marksimple();

        try {
            static::assertFalse($testee->hasRule($expectedName));
        } catch (AssertionFailedError $e) {
        }

        $testee->addRule($expectedName, $stub);

        try {
            static::assertTrue($testee->hasRule($expectedName));
        } catch (AssertionFailedError $e) {
        }
    }

    public function testRemoveRule()
    {
        $expected_name = 'foo';

        $stub = $this->getMockBuilder(ElementRuleInterface::class)->getMock();

        $testee = new Marksimple();
        $testee->addRule($expected_name, $stub);
        try {
            static::assertTrue($testee->removeRule($expected_name));
        } catch (UnknownRuleException $e) {
        } catch (AssertionFailedError $e) {
        }
    }

    /**
     * @expectedException \Bueltge\Marksimple\Exception\UnknownRuleException
     */
    public function testRemoveUnknownRule()
    {
        (new Marksimple())->removeRule('unknown_rule');
    }

    /**
     * Test if basic text input will be parsed and wrapped by paragraphs.
     */
    public function testParse()
    {
        $testee = new Marksimple();
        $input = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,';
        $input .= ' diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam';
        $expected = '<p>'.$input.'</p>';
        static::assertSame($expected, $testee->parse($input));
    }

    public function testGetLogger()
    {
        $markSimple = new Marksimple();

        try {
            $this->assertInstanceOf(NullLogger::class, $markSimple->getLogger());
        } catch (Exception $e) {
        }
    }
}<commit_msg>Add test for missing method removeAllRules()<commit_after><?php declare(strict_types=1); # -*- coding: utf-8 -*-

namespace Bueltge\Marksimple\Tests\Unit;

use Bueltge\Marksimple\Exception\UnknownRuleException;
use Bueltge\Marksimple\Marksimple;
use Bueltge\Marksimple\Rule\ElementRuleInterface;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Exception;
use Psr\Log\NullLogger;

class MarksimpleTest extends AbstractTestCase
{

    public function testBasic()
    {
        $testee = new Marksimple();
        try {
            static::assertInternalType('object', $testee);
        } catch (Exception $error) {
        }
    }

    public function testAddRule()
    {
        $expectedName = 'foo';

        $stub = $this->getMockBuilder(ElementRuleInterface::class)->getMock();

        $testee = new Marksimple();

        try {
            static::assertFalse($testee->hasRule($expectedName));
        } catch (AssertionFailedError $error) {
        }

        $testee->addRule($expectedName, $stub);

        try {
            static::assertTrue($testee->hasRule($expectedName));
        } catch (AssertionFailedError $error) {
        }
    }

    public function testRemoveRule()
    {
        $expectedName = 'foo';

        $stub = $this->getMockBuilder(ElementRuleInterface::class)->getMock();

        $testee = new Marksimple();
        $testee->addRule($expectedName, $stub);
        try {
            static::assertTrue($testee->removeRule($expectedName));
        } catch (UnknownRuleException $error) {
        } catch (AssertionFailedError $error) {
        }
    }

    /**
     * Simple test, no parameters, only get a bool.
     */
    public function testRemoveAllRules()
    {
        $testee = new Marksimple();
        try {
            $this->assertTrue($testee->removeAllRules());
        } catch (AssertionFailedError $error) {
        }
    }

    /**
     * @expectedException \Bueltge\Marksimple\Exception\UnknownRuleException
     */
    public function testRemoveUnknownRule()
    {
        (new Marksimple())->removeRule('unknown_rule');
    }

    /**
     * Test if basic text input will be parsed and wrapped by paragraphs.
     */
    public function testParse()
    {
        $testee = new Marksimple();
        $input = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,';
        $input .= ' diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam';
        $expected = '<p>'.$input.'</p>';
        static::assertSame($expected, $testee->parse($input));
    }

    public function testGetLogger()
    {
        $markSimple = new Marksimple();

        try {
            $this->assertInstanceOf(NullLogger::class, $markSimple->getLogger());
        } catch (Exception $error) {
        }
    }
}
{'fraction_non_alphanumeric': 0.1282642089093702, 'fraction_numerical': 0.0007680491551459293, 'mean_word_length': 2.560492139439508, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '395115', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1492, 'n_words': 300}