<commit_before><?php
/**
 * Enlight
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://enlight.de/license
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * @category   Enlight
 * @package    Enlight_Test
 * @copyright  Copyright (c) 2011, shopware AG (http://www.shopware.de)
 * @license    http://enlight.de/license     New BSD License
 * @version    $Id$
 * @author     <NAME>
 * @author     $Author$
 */

/**
 * Test case for Enlight controller.
 *
 * The Enlight_Components_Test_Controller_TestCase extends the basic Enlight_Components_Test_TestCase
 * with controller specified functions to grant an easily access to standard controller actions.
 *
 * @category   Enlight
 * @package    Enlight_Test
 * @copyright  Copyright (c) 2011, shopware AG (http://www.shopware.de)
 * @license    http://enlight.de/license     New BSD License
 */
abstract class Enlight_Components_Test_Controller_TestCase extends Enlight_Components_Test_TestCase
{
    /**
     * Instance of the Front resource
     * @var Enlight_Controller_Front
     */
    protected $_front;

    /**
     * Instance of the View resource
     * @var Enlight_Template_Manager
     */
    protected $_template;

    /**
     * Instance of the enlight view. Is filled in the dispatch function with the template.
     * @var Enlight_View_Default
     */
    protected $_view;

    /**
     * Instance of the enlight request. Filled in the dispatch function.
     * @var Zend_Controller_Request_Http
     */
    protected $_request;

    /**
     * Instance of the enlight response. Filled in the dispatch function.
     * @var Zend_Controller_Response_Http
     */
    protected $_response;

    /**
     * Tests set up method
     */
    public function setUp()
    {
        parent::setUp();

        $app = Enlight_Application::Instance();
        $app->Bootstrap()
                ->resetResource('Session')
                ->resetResource('Auth');

        $this->reset();
    }

    /**
     * Dispatch the request
     *
     * @param   string|null $url
     * @return  Zend_Controller_Response_Abstract
     */
    public function dispatch($url = null)
    {
        $request = $this->Request();
        if (null !== $url) {
            $request->setRequestUri($url);
        }
        $request->setPathInfo(null);

        $response = $this->Response();

        $front = $this->Front()
                ->setRequest($request)
                ->setResponse($response);
        $front->dispatch();

        /** @var $viewRenderer Enlight_Controller_Plugins_ViewRenderer_Bootstrap */
        $viewRenderer = $front->Plugins()->get('ViewRenderer');
        $this->_view = $viewRenderer->Action()->View();

        /*
        if (!$front->getParam('noErrorHandler')) {
            $front->Plugins()->load('ErrorHandler');
        }
        if (!$front->getParam('noViewRenderer')) {
            $front->Plugins()->load('ViewRenderer');
        }

        $dispatcher = $front->Dispatcher();

        $dispatcher->dispatch($request, $response);
        */
        return $response;
    }

    /**
     * Reset all instances, resources and init the internal view, template and front properties
     */
    public function reset()
    {
        $app = Enlight_Application::Instance();

        $this->resetRequest();
        $this->resetResponse();


        $this->_view = null;
        $this->_template = null;
        $this->_front = null;

        $app->Plugins()->reset();
        //$app->Hooks()->resetHooks();
        $app->Events()->reset();
        //$app->Db()->getProfiler()->clear();

        $app->Bootstrap()<commit_msg>NTR - Force view assignments to be cleared when resetting<commit_after><?php
/**
 * Enlight
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://enlight.de/license
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * @category   Enlight
 * @package    Enlight_Test
 * @copyright  Copyright (c) 2011, shopware AG (http://www.shopware.de)
 * @license    http://enlight.de/license     New BSD License
 * @version    $Id$
 * @author     <NAME>
 * @author     $Author$
 */

/**
 * Test case for Enlight controller.
 *
 * The Enlight_Components_Test_Controller_TestCase extends the basic Enlight_Components_Test_TestCase
 * with controller specified functions to grant an easily access to standard controller actions.
 *
 * @category   Enlight
 * @package    Enlight_Test
 * @copyright  Copyright (c) 2011, shopware AG (http://www.shopware.de)
 * @license    http://enlight.de/license     New BSD License
 */
abstract class Enlight_Components_Test_Controller_TestCase extends Enlight_Components_Test_TestCase
{
    /**
     * Instance of the Front resource
     * @var Enlight_Controller_Front
     */
    protected $_front;

    /**
     * Instance of the View resource
     * @var Enlight_Template_Manager
     */
    protected $_template;

    /**
     * Instance of the enlight view. Is filled in the dispatch function with the template.
     * @var Enlight_View_Default
     */
    protected $_view;

    /**
     * Instance of the enlight request. Filled in the dispatch function.
     * @var Zend_Controller_Request_Http
     */
    protected $_request;

    /**
     * Instance of the enlight response. Filled in the dispatch function.
     * @var Zend_Controller_Response_Http
     */
    protected $_response;

    /**
     * Tests set up method
     */
    public function setUp()
    {
        parent::setUp();

        $app = Enlight_Application::Instance();
        $app->Bootstrap()
                ->resetResource('Session')
                ->resetResource('Auth');

        $this->reset();
    }

    /**
     * Dispatch the request
     *
     * @param   string|null $url
     * @return  Zend_Controller_Response_Abstract
     */
    public function dispatch($url = null)
    {
        $request = $this->Request();
        if (null !== $url) {
            $request->setRequestUri($url);
        }
        $request->setPathInfo(null);

        $response = $this->Response();

        $front = $this->Front()
                ->setRequest($request)
                ->setResponse($response);
        $front->dispatch();

        /** @var $viewRenderer Enlight_Controller_Plugins_ViewRenderer_Bootstrap */
        $viewRenderer = $front->Plugins()->get('ViewRenderer');
        $this->_view = $viewRenderer->Action()->View();

        /*
        if (!$front->getParam('noErrorHandler')) {
            $front->Plugins()->load('ErrorHandler');
        }
        if (!$front->getParam('noViewRenderer')) {
            $front->Plugins()->load('ViewRenderer');
        }

        $dispatcher = $front->Dispatcher();

        $dispatcher->dispatch($request, $response);
        */
        return $response;
    }

    /**
     * Reset all instances, resources and init the internal view, template and front properties
     */
    public function reset()
    {
        $app = Enlight_Application::Instance();

        $this->resetRequest();
        $this->resetResponse();

        // Force the assignments to be cleared. Needed for some test cases
        if ($this->_view && $this->_view->hasTemplate()) {
            $this->_view->clearAssign();
        }

        $this->_view = null;
        $this->_template = null;
        $this->_front = null;

        $app->Plugins()->reset();
        //$app->Hooks()->resetHooks();
        $app->Events()->reset();
        //$app->Db()->getProfiler()->clear();

        $app->Bootstrap()
{'fraction_non_alphanumeric': 0.12710700461980273, 'fraction_numerical': 0.001997752528405544, 'mean_word_length': 2.3740522325189555, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 92, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6959738', 'n_tokens_mistral': 2226, 'n_tokens_neox': 2165, 'n_words': 598}