<commit_before><?php

namespace CultuurNet\UDB3\Variations\Command;

use CultuurNet\UDB3\Variations\Model\Properties\Description;
use CultuurNet\UDB3\Variations\Model\Properties\Id;
use ValueObjects\Identity\UUID;
use ValueObjects\String\String;

class EditDescriptionJSONDeserializerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var EditDescriptionJSONDeserializer
     */
    private $deserializer;

    /**
     * @var Id
     */
    private $variationId;

    public function setUp()
    {
        $this->variationId = new Id(UUID::generateAsString());
        $this->deserializer = new EditDescriptionJSONDeserializer(
            $this->variationId
        );
    }

    /**
     * @test
     */
    public function it_deserializes_a_json_command()
    {
        $jsonData = '{"description": "An edited description."}';
        $jsonCommand = new String($jsonData);
        $deserializedCommand = $this->deserializer->deserialize($jsonCommand);

        $expectedCommand = new EditDescription(
            $this->variationId,
            new Description('An edited description.')
        );

        $this->assertEquals($expectedCommand, $deserializedCommand);
    }

    /**
     * @test
     */
    public function it_validates_the_json_command()
    {
        $jsonData = '{"unwanted": "What am I doing here."}';
        $jsonCommand = new String($jsonData);

        try {
            $this->deserializer->deserialize($jsonCommand);
        } catch (ValidationException $e) {
            $this->assertEquals(
                [
                    'the property description is required',
                    'The property unwanted is not defined and the definition does not allow additional properties'
                ],
                $e->getErrors()
            );
        }
    }
}
<commit_msg>III-327: Update test after library update<commit_after><?php

namespace CultuurNet\UDB3\Variations\Command;

use CultuurNet\UDB3\Variations\Model\Properties\Description;
use CultuurNet\UDB3\Variations\Model\Properties\Id;
use ValueObjects\Identity\UUID;
use ValueObjects\String\String;

class EditDescriptionJSONDeserializerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var EditDescriptionJSONDeserializer
     */
    private $deserializer;

    /**
     * @var Id
     */
    private $variationId;

    public function setUp()
    {
        $this->variationId = new Id(UUID::generateAsString());
        $this->deserializer = new EditDescriptionJSONDeserializer(
            $this->variationId
        );
    }

    /**
     * @test
     */
    public function it_deserializes_a_json_command()
    {
        $jsonData = '{"description": "An edited description."}';
        $jsonCommand = new String($jsonData);
        $deserializedCommand = $this->deserializer->deserialize($jsonCommand);

        $expectedCommand = new EditDescription(
            $this->variationId,
            new Description('An edited description.')
        );

        $this->assertEquals($expectedCommand, $deserializedCommand);
    }

    /**
     * @test
     */
    public function it_validates_the_json_command()
    {
        $jsonData = '{"unwanted": "What am I doing here."}';
        $jsonCommand = new String($jsonData);

        try {
            $this->deserializer->deserialize($jsonCommand);
        } catch (ValidationException $e) {
            $this->assertEquals(
                [
                    'the property description is required',
                    'The property - unwanted - is not defined and the definition does not allow additional properties'
                ],
                $e->getErrors()
            );
        }
    }
}

{'fraction_non_alphanumeric': 0.1110506260206859, 'fraction_numerical': 0.0024496461622210124, 'mean_word_length': 2.272484416740873, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 25, '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': '4626482', 'n_tokens_mistral': 1019, 'n_tokens_neox': 998, 'n_words': 199}