<commit_before><?php
/**
 * Breeze Framework - View test case
 *
 * This file contains the {@link Breeze\View\Tests\ViewTest} class.
 *
 * LICENSE
 *
 * This file is part of the Breeze Framework package and is subject to the new
 * BSD license.  For full copyright and license information, please see the
 * LICENSE file that is distributed with this package.
 *
 * @author     <NAME> <<EMAIL>>
 * @category   Breeze
 * @package    View
 * @subpackage Tests
 * @copyright  Copyright (c) 2010, Breeze Framework
 * @license    New BSD License
 * @version    $Id$
 */

namespace Breeze\View\Tests {

    /**
     * @see Breeze\View\View
     */
    use Breeze\View\View;

    /**
     * The test case for the {@link Breeze\View\View} class.
     *
     * @category    Breeze
     * @package     View
     * @subpackage  Tests
     */
    class ViewTest extends \PHPUnit_Extensions_OutputTestCase
    {
        /**
         * The application stub for testing {@link Breeze\Application}.
         *
         * @access protected
         * @param  Breeze\Application
         */
        protected $_application;
        /**
         * The view object for testing.
         *
         * @access protected
         * @param  Breeze\View\View
         */
        protected $_view;

        /**
         * Configuration values for testsing {@link Breeze\View\View}.
         *
         * @access protected
         * @param  array
         */
        protected $_config = array(
            'template_engine'       => '',
            'template_options'      => array(),
            'template_directory'    => \Breeze\Tests\FIXTURES_PATH,
            'template_extension'    => '.php',
            'template_layout'       => 'layout',
            'application_variable'  => 'breeze',
            'errors_backtrace'      => true
        );

        /**
         * Sets up the test case for {@link Breeze\View\View}.
         *
         * @access public
         * @return void
         */
        public function setUp()
        {
            $this->_application = $this->getMock('Breeze\\Application', array(), array(), '', FALSE);
            $this->_application->expects($this->any())
                               ->method('config')
                               ->will($this->returnCallback(array($this, 'getConfig')));

            $this->_config['template_engine'] = $this->getMock('Breeze\\View\\Driver\\PHP', array(), array($this->_application), '', FALSE);
            $this->_view = new View($this->_application);
        }

        /**
         * Tests {@link Breeze\View\View::__get()} with a template variable that
         * hasn't been set.
         */
        public function testGetWithUnsetVariable()
        {
            $this->assertNull($this->_view->does_not_exist);
        }

        /**
         * Tests {@link Breeze\View\View::__get()} with a template variable that
         * has been set.
         */
        public function testGetWithSetVariable()
        {
            $this->_view->addVariables(array('this_is_a' => 'test'));
            $this->assertSame('test', $this->_view->this_is_a);
        }

        /**
         * Tests {@link Breeze\View\View::__isset()} with a template variable
         * that has been set.
         */
        public function testIssetWithSetVariable()
        {
            $this->_view->addVariables(array('this_is_a' => 'test'));
            $this->assertTrue(isset($this->_view->this_is_a));
        }

        /**
         * Tests {@link Breeze\View\View::__isset()} with a template variable
         * that has not been set.
         */
        public function testIssetWithUnsetVariable()
        {
            $this->assertFalse(isset($this->_view->does_not_exist));
        }

        /**
         * Tests {@link Breeze\View\View::__unset()} to unset a set template
         * variable.
         */
        public function testUnsetVariable()
        {
            $this->_view->addVariables(array('this_is_a' => 'test'));
            $this->assertTrue(isset($this->_view->this_is_a));

            unset($this->_view->this_is_a);
            $this->assertFalse(isset($this->_view->this_is_a));
        }

        /**
         * Tests {@link Breeze\View\View::__set()} to set a template variable.
         */
        public function testSet()
        {
            $this->_view->this_is_a = 'test';
            $this->assertSame('test', $this->_view->this_is_a);
        }

        /**
         * Tests {@link Breeze\View\View::getEngine()} with an bad template
         * engine.
         */
        public function testGetEngineWithBadEngine()
        {
            $this->setExpectedException('\\UnexpectedValueException', 'is not a valid template engine.');
            $this->_config['template_engine'] = 'INVALID';
            $this->_view->getEngine();
        }

        /**
         * Tests {@link Breeze\View\View::getEngine()} with a good template
         * engine.
         */
        public function testGetEngineWithGoodEngine()
        {
            $this->assertType('Breeze\\View\\Driver\\DriverInterface', $this->_view->getEngine());
        }

        /**
         * Tests {@link Breeze\View\View::getEngine()} with a string-based engine.
         */
        public function testGetEngineWithString()
        {
            $this->_config['template_engine'] = 'Tests\\Stub';
            $this->assertType('Breeze\\View\\Driver\\Tests\\Stub', $this->_view->getEngine());
        }

        /**
         * Tests {@link Breeze\View\View::getEngine()} caches the engine if
         * no options have changed.<commit_msg>Removed all references to the deprecated `PHPUnit_Framework_TestCase::assertType()`.<commit_after><?php
/**
 * Breeze Framework - View test case
 *
 * This file contains the {@link Breeze\View\Tests\ViewTest} class.
 *
 * LICENSE
 *
 * This file is part of the Breeze Framework package and is subject to the new
 * BSD license.  For full copyright and license information, please see the
 * LICENSE file that is distributed with this package.
 *
 * @author     <NAME> <<EMAIL>>
 * @category   Breeze
 * @package    View
 * @subpackage Tests
 * @copyright  Copyright (c) 2010, Breeze Framework
 * @license    New BSD License
 * @version    $Id$
 */

namespace Breeze\View\Tests {

    /**
     * @see Breeze\View\View
     */
    use Breeze\View\View;

    /**
     * The test case for the {@link Breeze\View\View} class.
     *
     * @category    Breeze
     * @package     View
     * @subpackage  Tests
     */
    class ViewTest extends \PHPUnit_Extensions_OutputTestCase
    {
        /**
         * The application stub for testing {@link Breeze\Application}.
         *
         * @access protected
         * @param  Breeze\Application
         */
        protected $_application;
        /**
         * The view object for testing.
         *
         * @access protected
         * @param  Breeze\View\View
         */
        protected $_view;

        /**
         * Configuration values for testsing {@link Breeze\View\View}.
         *
         * @access protected
         * @param  array
         */
        protected $_config = array(
            'template_engine'       => '',
            'template_options'      => array(),
            'template_directory'    => \Breeze\Tests\FIXTURES_PATH,
            'template_extension'    => '.php',
            'template_layout'       => 'layout',
            'application_variable'  => 'breeze',
            'errors_backtrace'      => true
        );

        /**
         * Sets up the test case for {@link Breeze\View\View}.
         *
         * @access public
         * @return void
         */
        public function setUp()
        {
            $this->_application = $this->getMock('Breeze\\Application', array(), array(), '', FALSE);
            $this->_application->expects($this->any())
                               ->method('config')
                               ->will($this->returnCallback(array($this, 'getConfig')));

            $this->_config['template_engine'] = $this->getMock('Breeze\\View\\Driver\\PHP', array(), array($this->_application), '', FALSE);
            $this->_view = new View($this->_application);
        }

        /**
         * Tests {@link Breeze\View\View::__get()} with a template variable that
         * hasn't been set.
         */
        public function testGetWithUnsetVariable()
        {
            $this->assertNull($this->_view->does_not_exist);
        }

        /**
         * Tests {@link Breeze\View\View::__get()} with a template variable that
         * has been set.
         */
        public function testGetWithSetVariable()
        {
            $this->_view->addVariables(array('this_is_a' => 'test'));
            $this->assertSame('test', $this->_view->this_is_a);
        }

        /**
         * Tests {@link Breeze\View\View::__isset()} with a template variable
         * that has been set.
         */
        public function testIssetWithSetVariable()
        {
            $this->_view->addVariables(array('this_is_a' => 'test'));
            $this->assertTrue(isset($this->_view->this_is_a));
        }

        /**
         * Tests {@link Breeze\View\View::__isset()} with a template variable
         * that has not been set.
         */
        public function testIssetWithUnsetVariable()
        {
            $this->assertFalse(isset($this->_view->does_not_exist));
        }

        /**
         * Tests {@link Breeze\View\View::__unset()} to unset a set template
         * variable.
         */
        public function testUnsetVariable()
        {
            $this->_view->addVariables(array('this_is_a' => 'test'));
            $this->assertTrue(isset($this->_view->this_is_a));

            unset($this->_view->this_is_a);
            $this->assertFalse(isset($this->_view->this_is_a));
        }

        /**
         * Tests {@link Breeze\View\View::__set()} to set a template variable.
         */
        public function testSet()
        {
            $this->_view->this_is_a = 'test';
            $this->assertSame('test', $this->_view->this_is_a);
        }

        /**
         * Tests {@link Breeze\View\View::getEngine()} with an bad template
         * engine.
         */
        public function testGetEngineWithBadEngine()
        {
            $this->setExpectedException('\\UnexpectedValueException', 'is not a valid template engine.');
            $this->_config['template_engine'] = 'INVALID';
            $this->_view->getEngine();
        }

        /**
         * Tests {@link Breeze\View\View::getEngine()} with a good template
         * engine.
         */
        public function testGetEngineWithGoodEngine()
        {
            $this->assertInstanceOf('Breeze\\View\\Driver\\DriverInterface', $this->_view->getEngine());
        }

        /**
         * Tests {@link Breeze\View\View::getEngine()} with a string-based engine.
         */
        public function testGetEngineWithString()
        {
            $this->_config['template_engine'] = 'Tests\\Stub';
            $this->assertInstanceOf('Breeze\\View\\Driver\\Tests\\Stub', $this->_view->getEngine());
        }

        /**
         * Tests {@link Breeze\View\View::getEngine()} caches the engine if
         * no options have changed.
{'fraction_non_alphanumeric': 0.13764069839581672, 'fraction_numerical': 0.0007090312860054949, 'mean_word_length': 1.797223599405057, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 139, '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': '3373225', 'n_tokens_mistral': 3097, 'n_tokens_neox': 3091, 'n_words': 669}