<commit_before><?php
/**
 * PHPTAL templating engine
 *
 * PHP Version 5
 *
 * @category HTML
 * @package  PHPTAL
 * @author   <NAME> <<EMAIL>>
 * @license  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
 * @version  SVN: $Id: $
 * @link     http://phptal.org/
 */


class TalesRegistryTest extends PHPTAL_TestCase
{
    function testInstance()
    {
        $this->assertSame(PHPTAL_TalesRegistry::getInstance(), PHPTAL_TalesRegistry::getInstance());
        $this->assertInstanceOf('PHPTAL_TalesRegistry',PHPTAL_TalesRegistry::getInstance());
    }

    function testRegisterFunction()
    {
        PHPTAL_TalesRegistry::getInstance()->registerPrefix('registry_test', 'registry_test_callback');

        $this->assertEquals('<p>ok1</p>', $this->newPHPTAL()->setSource('<p tal:content="registry_test:number:1"/>')->execute());
    }

    /**
     * @expectedException PHPTAL_UnknownModifierException
     */
    function testUnregisterFunction()
    {
        PHPTAL_TalesRegistry::getInstance()->unregisterPrefix('php');
        $this->newPHPTAL()->setSource('<p tal:content="php:1"/>')->execute();
    }

    /**
     * @expectedException PHPTAL_ConfigurationException
     */
    function testCantUnregisterNonRegistered()
    {
        PHPTAL_TalesRegistry::getInstance()->unregisterPrefix('doesnotexist');
    }

    /**
     * @expectedException PHPTAL_ConfigurationException
     */
    function testCantRegisterNonExistant()
    {
        PHPTAL_TalesRegistry::getInstance()->registerPrefix('registry_test_2', 'doesnotexist');
    }

    /**<commit_msg>Stop test side effects<commit_after><?php
/**
 * PHPTAL templating engine
 *
 * PHP Version 5
 *
 * @category HTML
 * @package  PHPTAL
 * @author   <NAME> <<EMAIL>>
 * @license  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
 * @version  SVN: $Id: $
 * @link     http://phptal.org/
 */


class TalesRegistryTest extends PHPTAL_TestCase
{
    function testInstance()
    {
        $this->assertSame(PHPTAL_TalesRegistry::getInstance(), PHPTAL_TalesRegistry::getInstance());
        $this->assertInstanceOf('PHPTAL_TalesRegistry',PHPTAL_TalesRegistry::getInstance());
    }

    function testRegisterFunction()
    {
        PHPTAL_TalesRegistry::getInstance()->registerPrefix('registry_test', 'registry_test_callback');

        $this->assertEquals('<p>ok1</p>', $this->newPHPTAL()->setSource('<p tal:content="registry_test:number:1"/>')->execute());
    }

    /**
     * Define constants after requires/includes
     * @param Text_Template $template
     * @return void
     */
    public function prepareTemplate( Text_Template $template ) {
        $template->setVar( array(
            'constants'    => '',
            'zz_constants' => PHPUnit_Util_GlobalState::getConstantsAsString()
        ));
        parent::prepareTemplate( $template );
    }

    /**
     * @runInSeparateProcess
     * @expectedException PHPTAL_UnknownModifierException
     */
    function testUnregisterFunction()
    {
        PHPTAL_TalesRegistry::getInstance()->unregisterPrefix('php');
        $this->newPHPTAL()->setSource('<p tal:content="php:1"/>')->execute();
    }

    /**
     * @expectedException PHPTAL_ConfigurationException
     */
    function testCantUnregisterNonRegistered()
    {
        PHPTAL_TalesRegistry::getInstance()->unregisterPrefix('doesnotexist');
    }

    /**
     * @expectedException PHPTAL_ConfigurationException
     */
    function testCantRegisterNonExistant()
    {
        PHPTAL_TalesRegistry::getInstance()->registerPrefix('registry_test_2', 'doesnotexist');
    }

    /**
{'fraction_non_alphanumeric': 0.14281760309991698, 'fraction_numerical': 0.0027677830058123443, 'mean_word_length': 3.5921219822109274, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1525472', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1044, 'n_words': 145}