<commit_before><?php

namespace Psy\Test\CodeCleaner;

use Psy\CodeCleaner\LeavePsyshAlonePass;
use PHPParser_Node_Expr_FuncCall as FuncCall;
use PHPParser_Node_Expr_Variable as Variable;

class LeavePsyshAlonePassTest extends \PHPUnit_Framework_TestCase
{
    private $pass;

    public function setUp()
    {
        $this->pass = new LeavePsyshAlonePass;
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testInvalidProcessArgumentsThrowsException()
    {
        $string = 'Some random string.';
        $this->pass->process($string);
    }

    /**
     * @dataProvider validStatements
     */
    public function testProcessStatementPasses($stmt)
    {
        $stmts = array($stmt);
        $this->pass->process($stmts);
    }

    public function validStatements()
    {
        return array(
            array(new FuncCall('array_merge')),
            array(new FuncCall('__psysh__')),
            array(new Variable('this')),
            array(new Variable('psysh')),
            array(new Variable('__psysh')),
            array(new Variable('banana')),
        );
    }

    /**
     * @expectedException \Psy\Exception\RuntimeException
     */
    public function testProcessStatementFails()
    {
        $stmts = array(new Variable('__psysh__'));
        $this->pass->process($stmts);
    }
}<commit_msg>Update LeavePsyshAlonePassTest to use new test case.<commit_after><?php

namespace Psy\Test\CodeCleaner;

use Psy\CodeCleaner\LeavePsyshAlonePass;

class LeavePsyshAlonePassTest extends CodeCleanerTestCase
{
    private $pass;

    public function setUp()
    {
        $this->pass = new LeavePsyshAlonePass;
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testInvalidProcessArgumentsThrowsException()
    {
        $string = 'Some random string.';
        $this->pass->process($string);
    }

    public function testPassesInlineHtmlThroughJustFine()
    {
        $inline = $this->parse('not php at all!', '');
        $this->pass->process($inline);
    }

    /**
     * @dataProvider validStatements
     */
    public function testProcessStatementPasses($code)
    {
        $stmts = $this->parse($code);
        $this->pass->process($stmts);
    }

    public function validStatements()
    {
        return array(
            array('array_merge()'),
            array('__psysh__()'),
            array('$this'),
            array('$psysh'),
            array('$__psysh'),
            array('$banana'),
        );
    }

    /**
     * @dataProvider invalidStatements
     * @expectedException \Psy\Exception\RuntimeException
     */
    public function testProcessStatementFails($code)
    {
        $stmts = $this->parse($code);
        $this->pass->process($stmts);
    }

    public function invalidStatements()
    {
        return array(
            array('$__psysh__'),
            array('var_dump($__psysh__)'),
            array('$__psysh__ = "your mom"'),
            array('$__psysh__->fakeFunctionCall()'),
        );
    }
}
{'fraction_non_alphanumeric': 0.12798690671031096, 'fraction_numerical': 0.0, 'mean_word_length': 2.4337078651685395, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '5996123', 'n_tokens_mistral': 911, 'n_tokens_neox': 906, 'n_words': 151}