<commit_before><?php

namespace Nohex\Eix\Core;

class ApplicationTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @expectedException \Nohex\Eix\Core\Exception
     */
    public function testEmptyStaticInstance()
    {
        $application = Application::getCurrent();
    }

    public function testSingleton()
    {
        $applicationA = new MockApplication;
        $applicationB = Application::getCurrent();

        $this->assertSame($applicationA, $applicationB);
    }

    /**
     * @expectedException PHPUnit_Framework_Error
     */
    public function testErrorWithRawErrorsOn()
    {
        $settings = new MockSettings;
        $settings->application->rawErrors = 'on';
        $application = new MockApplication($settings);

        $currentHandler = set_error_handler('handler');
        restore_error_handler();
        $this->assertNotNull($currentHandler, 'The error handler was not assigned.');

        // The error handler should not catch this one.
        trigger_error('Testing rawErrors');
    }

    /**
     * @expectedException Exception
     */
    public function testExceptionWithRawErrorsOn()
    {
        $settings = new MockSettings;
        $settings->application->rawErrors = 'on';
        $application = new MockApplication($settings);

        $currentHandler = set_exception_handler('handler');
        restore_exception_handler();
        $this->assertNull($currentHandler, 'The exception handler is assigned.');

        // The error handler should not catch this one.
        throw new Exception('Testing rawErrors');
    }

// DEBUG! Temporarily disabled until it can be determined how to make them pass.
// 
//    public function testErrorWithRawErrorsOff()
//    {
//        $this->expectOutputRegex('/Template .* was not found/');
//
//        $settings = new MockSettings;
//        $settings->application->rawErrors = 'off';
//        $application = new MockApplication($settings);
//
//        $currentHandler = set_error_handler('handler');<commit_msg>Fix callbacks in `Application` tests.<commit_after><?php

namespace Nohex\Eix\Core;

class ApplicationTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @expectedException \Nohex\Eix\Core\Exception
     */
    public function testEmptyStaticInstance()
    {
        $application = Application::getCurrent();
    }

    public function testSingleton()
    {
        $applicationA = new MockApplication;
        $applicationB = Application::getCurrent();

        $this->assertSame($applicationA, $applicationB);
    }

    /**
     * @expectedException PHPUnit_Framework_Error
     */
    public function testErrorWithRawErrorsOn()
    {
        $settings = new MockSettings;
        $settings->application->rawErrors = 'on';
        $application = new MockApplication($settings);

        $currentHandler = set_error_handler(function() {});
        restore_error_handler();
        $this->assertNotNull($currentHandler, 'The error handler was not assigned.');

        // The error handler should not catch this one.
        trigger_error('Testing rawErrors');
    }

    /**
     * @expectedException Exception
     */
    public function testExceptionWithRawErrorsOn()
    {
        $settings = new MockSettings;
        $settings->application->rawErrors = 'on';
        $application = new MockApplication($settings);

        $currentHandler = set_exception_handler(function() {});
        restore_exception_handler();
        $this->assertNull($currentHandler, 'The exception handler is assigned.');

        // The error handler should not catch this one.
        throw new Exception('Testing rawErrors');
    }

// DEBUG! Temporarily disabled until it can be determined how to make them pass.
// 
//    public function testErrorWithRawErrorsOff()
//    {
//        $this->expectOutputRegex('/Template .* was not found/');
//
//        $settings = new MockSettings;
//        $settings->application->rawErrors = 'off';
//        $application = new MockApplication($settings);
//
//        $currentHandler = set_error_handler('handler');
{'fraction_non_alphanumeric': 0.11737204724409449, 'fraction_numerical': 0.0, 'mean_word_length': 2.8204887218045114, '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': '3863197', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1017, 'n_words': 245}