<commit_before><?php

namespace Concrete\Tests\Error;

use Core;
use Concrete\Tests\TestCase;

class ErrorTest extends TestCase
{
    public function testErrorMethodsBackwardCompatibility()
    {
        $e = Core::make('error');
        $this->assertInstanceOf('JsonSerializable', $e);
        $this->assertInstanceOf('ArrayAccess', $e);
        $this->assertTrue(method_exists($e, 'getList'));
        $this->assertTrue(method_exists($e, 'add'));
        $this->assertTrue(method_exists($e, 'has'));
        $this->assertTrue(method_exists($e, 'output'));
        $this->assertTrue(method_exists($e, 'outputJSON'));
        $e1 = Core::make('helper/validation/error');
        $this->assertEquals($e, $e1);

        $e = new \Concrete\Core\Error\Error();
        $this->assertInstanceOf('Concrete\Core\Error\ErrorList\ErrorList', $e);
    }

    public function testBasicErrorFunctionality()
    {
        $e = Core::make('error');
        $this->assertEquals(false, $e->has());
        $e->add('This is a test.');
        $this->assertEquals(1, count($e->getList()));
        $this->assertEquals(true, $e->has());
        $text = $e->getList()[0];
        $this->assertEquals('This is a test.', (string) $text);
        $this->assertInstanceOf('Concrete\Core\Error\ErrorList\Error\Error', $text);
        ob_start();
        $e->outputJSON();
        $output = ob_get_contents();
        ob_end_clean();
        ob_start();
        $e->output();
        $html = ob_get_contents();
        ob_end_clean();
        $json = json_encode($e);
        $this->assertEquals('{"error":true,"errors":["This is a test."]}', $json);<commit_msg>Add new list property to error response<commit_after><?php

namespace Concrete\Tests\Error;

use Core;
use Concrete\Tests\TestCase;

class ErrorTest extends TestCase
{
    public function testErrorMethodsBackwardCompatibility()
    {
        $e = Core::make('error');
        $this->assertInstanceOf('JsonSerializable', $e);
        $this->assertInstanceOf('ArrayAccess', $e);
        $this->assertTrue(method_exists($e, 'getList'));
        $this->assertTrue(method_exists($e, 'add'));
        $this->assertTrue(method_exists($e, 'has'));
        $this->assertTrue(method_exists($e, 'output'));
        $this->assertTrue(method_exists($e, 'outputJSON'));
        $e1 = Core::make('helper/validation/error');
        $this->assertEquals($e, $e1);

        $e = new \Concrete\Core\Error\Error();
        $this->assertInstanceOf('Concrete\Core\Error\ErrorList\ErrorList', $e);
    }

    public function testBasicErrorFunctionality()
    {
        $e = Core::make('error');
        $this->assertEquals(false, $e->has());
        $e->add('This is a test.');
        $this->assertEquals(1, count($e->getList()));
        $this->assertEquals(true, $e->has());
        $text = $e->getList()[0];
        $this->assertEquals('This is a test.', (string) $text);
        $this->assertInstanceOf('Concrete\Core\Error\ErrorList\Error\Error', $text);
        ob_start();
        $e->outputJSON();
        $output = ob_get_contents();
        ob_end_clean();
        ob_start();
        $e->output();
        $html = ob_get_contents();
        ob_end_clean();
        $json = json_encode($e);
        $this->assertEquals('{"error":true,"errors":["This is a test."],"list":[{"message":"This is a test.","messageContainsHtml":false}]}', $json);
{'fraction_non_alphanumeric': 0.18971156705322628, 'fraction_numerical': 0.0023788284269997025, 'mean_word_length': 3.137761377613776, 'pattern_counts': {'":': 7, '<': 5, '<?xml version=': 0, '>': 47, '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': '1663079', 'n_tokens_mistral': 1016, 'n_tokens_neox': 1022, 'n_words': 170}