<commit_before><?php

/*
 * This file is part of Laravel Exceptions.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace GrahamCampbell\Tests\Exceptions\Displayers;

use Exception;
use GrahamCampbell\Exceptions\Displayers\ViewDisplayer;
use GrahamCampbell\Tests\Exceptions\AbstractTestCase;
use Illuminate\Contracts\View\Factory;
use Mockery;
use Symfony\Component\HttpKernel\Exception\HttpException;

/**
 * This is the view displayer test class.
 *
 * @author <NAME> <<EMAIL>>
 */
class ViewDisplayerTest extends AbstractTestCase
{
    public function testError()
    {
        $displayer = new ViewDisplayer($factory = Mockery::mock(Factory::class));

        $factory->shouldReceive('make')->once()->with('errors.502')->andReturn("Gutted.\n");

        $response = $displayer->display(new HttpException(502, 'Oh noes!'), 'foo', 502, []);

        $this->assertSame("Gutted.\n", $response->getContent());
        $this->assertSame(502, $response->getStatusCode());
        $this->assertSame('text/html', $response->headers->get('Content-Type'));
    }

    public function testPropertiesTrue()
    {
        $displayer = new ViewDisplayer($factory = Mockery::mock(Factory::class));

        $factory->shouldReceive('exists')->once()->with('errors.500')->andReturn(true);

        $this->assertFalse($displayer->isVerbose());
        $this->assertTrue($displayer->canDisplay(new Exception(), new HttpException(500), 500));
        $this->assertSame('text/html', $displayer->contentType());
    }

    public function testPropertiesFalse()
    {
        $displayer = new ViewDisplayer($factory = Mockery::mock(Factory::class));

        $factory->shouldReceive('exists')->once()->with('errors.500')->andReturn(false);

        $this->assertFalse($displayer->isVerbose());
        $this->assertFalse($displayer->canDisplay(new Exception(), new HttpException(500), 500));
        $this->assertSame('text/html', $displayer->contentType());
    }
}<commit_msg>Updated tests<commit_after><?php

/*
 * This file is part of Laravel Exceptions.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace GrahamCampbell\Tests\Exceptions\Displayers;

use Exception;
use GrahamCampbell\Exceptions\Displayers\ViewDisplayer;
use GrahamCampbell\Tests\Exceptions\AbstractTestCase;
use Illuminate\Contracts\View\Factory;
use Mockery;
use Symfony\Component\HttpKernel\Exception\HttpException;

/**
 * This is the view displayer test class.
 *
 * @author <NAME> <<EMAIL>>
 */
class ViewDisplayerTest extends AbstractTestCase
{
    public function testError()
    {
        $displayer = new ViewDisplayer(new ExceptionInfo(__DIR__.'/../../resources/errors.json'), $factory = Mockery::mock(Factory::class));

        $factory->shouldReceive('make')->once()->with('errors.502')->andReturn("Gutted.\n");

        $response = $displayer->display(new HttpException(502, 'Oh noes!'), 'foo', 502, []);

        $this->assertSame("Gutted.\n", $response->getContent());
        $this->assertSame(502, $response->getStatusCode());
        $this->assertSame('text/html', $response->headers->get('Content-Type'));
    }

    public function testPropertiesTrue()
    {
        $displayer = new ViewDisplayer(new ExceptionInfo(__DIR__.'/../../resources/errors.json'), $factory = Mockery::mock(Factory::class));

        $factory->shouldReceive('exists')->once()->with('errors.500')->andReturn(true);

        $this->assertFalse($displayer->isVerbose());
        $this->assertTrue($displayer->canDisplay(new Exception(), new HttpException(500), 500));
        $this->assertSame('text/html', $displayer->contentType());
    }

    public function testPropertiesFalse()
    {
        $displayer = new ViewDisplayer(new ExceptionInfo(__DIR__.'/../../resources/errors.json'), $factory = Mockery::mock(Factory::class));

        $factory->shouldReceive('exists')->once()->with('errors.500')->andReturn(false);

        $this->assertFalse($displayer->isVerbose());
        $this->assertFalse($displayer->canDisplay(new Exception(), new HttpException(500), 500));
        $this->assertSame('text/html', $displayer->contentType());
    }
}
{'fraction_non_alphanumeric': 0.1701685522973909, 'fraction_numerical': 0.013853613484183791, 'mean_word_length': 4.257281553398058, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 79, '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': '6525739', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1214, 'n_words': 229}