<commit_before><?php

/*
 * This file is part of the WobbleCodeRestBundle package.
 *
 * (c) WobbleCode <http://www.wobblecode.com/>
 *
 * For the full copyright and license information, please view the LICENSE file
 * that was distributed with this source code.
 */

namespace WobbleCode\RestBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DeserializeControllerTest extends WebTestCase
{
    /**
     * @dataProvider urlsProvider
     */
    public function testSerializationTriggering($method, $url, $accept, $expected, $data = null, $code = 200)
    {
        $client = static::createClient();
        $client->request(
            $method,
            $url,
            [],
            [],
            [
                'HTTP_ACCEPT' => $accept,
                'CONTENT_TYPE' => 'application/json'
            ],
            $data
        );

        $this->assertEquals($code, $client->getResponse()->getStatusCode());
        $this->assertContains($expected, $client->getResponse()->getContent());
    }

    public function urlsProvider()
    {
        $task = ['title' => 'My Task'];

        return [
            ['POST', 'serialize/1', 'application/json', '"title":"Untitled"', null],
            ['POST', 'serialize/1', 'text/html', 'Task Untitled', null],
            ['POST', 'deserialize/1', 'application/json', '"title":"Untitled"', null],
            ['POST', 'deserialize/1', 'application/json', '"title":"My Task"', json_encode($task)]
        ];
    }
}<commit_msg>Add some test for converter<commit_after><?php

/*
 * This file is part of the WobbleCodeRestBundle package.
 *
 * (c) WobbleCode <http://www.wobblecode.com/>
 *
 * For the full copyright and license information, please view the LICENSE file
 * that was distributed with this source code.
 */

namespace WobbleCode\RestBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DeserializeControllerTest extends WebTestCase
{
    /**
     * @dataProvider urlsProvider
     */
    public function testSerializationTriggering($method, $url, $accept, $expected, $data = null, $code = 200)
    {
        $client = static::createClient();
        $client->request(
            $method,
            $url,
            [],
            [],
            [
                'HTTP_ACCEPT' => $accept,
                'CONTENT_TYPE' => 'application/json'
            ],
            $data
        );

        $this->assertEquals($code, $client->getResponse()->getStatusCode());
        $this->assertContains($expected, $client->getResponse()->getContent());
    }

    public function urlsProvider()
    {
        $task = [
            'title' => 'My Task',
            'completed' => true
        ];

        return [
            ['POST', 'serialize/1', 'application/json', '"title":"Untitled"', null],
            ['POST', 'serialize/1', 'text/html', 'Task Untitled', null],
            ['POST', 'deserialize/1', 'application/json', '"title":"Untitled"', null],
            ['POST', 'deserialize/1', 'application/json', '"title":"My Task"', json_encode($task)],
            ['POST', 'deserialize/1', 'application/json', '"completed":true', json_encode($task)],
            ['POST', 'deserialize/1', 'text/html', 'Task My Task', json_encode($task)]
        ];
    }
}
{'fraction_non_alphanumeric': 0.1599030890369473, 'fraction_numerical': 0.004845548152634767, 'mean_word_length': 2.440625, 'pattern_counts': {'":': 7, '<': 7, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6531281', 'n_tokens_mistral': 931, 'n_tokens_neox': 924, 'n_words': 208}