<commit_before><?php

namespace Rhubarb\Crown\Response;

use Rhubarb\Crown\Tests\Fixtures\TestCases\RhubarbTestCase;

class JsonResponseTest extends RhubarbTestCase
{
    public function testResponseIsJsonEncoded()
    {
        $response = new JsonResponse();
        $test = new \stdClass();
        $test->Forename = "abc";
        $test->Surname = "123";
        $response->setContent($test);

        ob_start();
        $response->send();
        $buffer = ob_get_clean();

        $this->assertEquals('{
    "Forename": "' . $test->Forename . '",
    "Surname": "123"
}', $buffer);
    }

    public function testResponseCanCodeNonModels()
    {
        $response = new JsonResponse();
        $test = ["abc", "123"];
        $response->setContent($test);

        ob_start();
        $response->send();
        $buffer = ob_get_clean();

        $this->assertEquals('[
    "abc",
    "123"
]', $buffer);

        $response = new JsonResponse();
        $test = new \stdClass();
        $test->abc = "123";

        $response->setContent($test);

        ob_start();
        $response->send();
        $buffer = ob_get_clean();

        $this->assertEquals('{
    "abc": "123"
}', $buffer);
    }
}<commit_msg>Changed tests now that JsonResponse doesn't use pretty printed JSON<commit_after><?php

namespace Rhubarb\Crown\Response;

use Rhubarb\Crown\Tests\Fixtures\TestCases\RhubarbTestCase;

class JsonResponseTest extends RhubarbTestCase
{
    public function testResponseIsJsonEncoded()
    {
        $response = new JsonResponse();
        $test = new \stdClass();
        $test->Forename = "abc";
        $test->Surname = "123";
        $response->setContent($test);

        ob_start();
        $response->send();
        $buffer = ob_get_clean();

        $this->assertEquals('{"Forename":"' . $test->Forename . '","Surname":"123"}', $buffer);
    }

    public function testResponseCanCodeNonModels()
    {
        $response = new JsonResponse();
        $test = ["abc", "123"];
        $response->setContent($test);

        ob_start();
        $response->send();
        $buffer = ob_get_clean();

        $this->assertEquals('["abc","123"]', $buffer);

        $response = new JsonResponse();
        $test = new \stdClass();
        $test->abc = "123";

        $response->setContent($test);

        ob_start();
        $response->send();
        $buffer = ob_get_clean();

        $this->assertEquals('{"abc":"123"}', $buffer);
    }
}
{'fraction_non_alphanumeric': 0.17053317053317052, 'fraction_numerical': 0.014652014652014652, 'mean_word_length': 2.4766619519094766, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 29, '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': '7378840', 'n_tokens_mistral': 776, 'n_tokens_neox': 731, 'n_words': 139}