<commit_before><?php
/*
 * This file is part of the runopencode/sax, an RunOpenCode project.
 *
 * (c) 2017 RunOpenCode
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace RunOpenCode\Sax\Test\Handler;

use GuzzleHttp\Psr7\Stream;
use PHPUnit\Framework\TestCase;
use RunOpenCode\Sax\Test\Fixtures\SampleXmlHandler;

class SampleHandlerTest extends TestCase
{
    /**
     * @test
     */
    public function parse()
    {
        $handler = new SampleXmlHandler();

        $result = $handler->parse(new Stream(fopen(__DIR__ . '/../Fixtures/sample.xml', 'r+b')));

        $this->assertSame(include_once __DIR__ . '/../Fixtures/sample_output.php', $result);
    }

    /**
     * @test
     *
     * @expectedException \RunOpenCode\Sax\Exception\ParseException
     * @expectedExceptionMessage Unable to parse provided document stream
     */
    public function broken()
    {
        $handler = new SampleXmlHandler();
        $handler->parse(new Stream(fopen(__DIR__ . '/../Fixtures/broken.xml', 'rb+')));
    }<commit_msg>Fixed test for broken doc.<commit_after><?php
/*
 * This file is part of the runopencode/sax, an RunOpenCode project.
 *
 * (c) 2017 RunOpenCode
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace RunOpenCode\Sax\Test\Handler;

use GuzzleHttp\Psr7\Stream;
use PHPUnit\Framework\TestCase;
use RunOpenCode\Sax\Test\Fixtures\SampleXmlHandler;

class SampleHandlerTest extends TestCase
{
    /**
     * @test
     */
    public function parse()
    {
        $handler = new SampleXmlHandler();

        $result = $handler->parse(new Stream(fopen(__DIR__ . '/../Fixtures/sample.xml', 'r+b')));

        $this->assertSame(include_once __DIR__ . '/../Fixtures/sample_output.php', $result);
    }

    /**
     * @test
     *
     * @expectedException \RuntimeException
     * @expectedExceptionMessage Parser error "mismatched tag", lineno: 10
     */
    public function broken()
    {
        $handler = new SampleXmlHandler();
        $handler->parse(new Stream(fopen(__DIR__ . '/../Fixtures/broken.xml', 'rb')));
    }
{'fraction_non_alphanumeric': 0.1298876404494382, 'fraction_numerical': 0.005393258426966292, 'mean_word_length': 3.0253164556962027, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2745119', 'n_tokens_mistral': 681, 'n_tokens_neox': 660, 'n_words': 166}