<commit_before><?php

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

namespace Composer\Test\Json;

use JsonSchema\Validator;
use Composer\Test\TestCase;

/**
 * @author <NAME> <<EMAIL>>
 */
class ComposerSchemaTest extends TestCase
{
    public function testNamePattern()
    {
        $expectedError = array(
            array(
                'property' => 'name',
                'message' => 'Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$',
                'constraint' => 'pattern',
                'pattern' => '^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$',
            ),
        );

        $json = '{"name": "vendor/-pack__age", "description": "description"}';
        $this->assertEquals($expectedError, $this->check($json));
        $json = '{"name": "Vendor/Package", "description": "description"}';
        $this->assertEquals($expectedError, $this->check($json));
    }

    public function testRequiredProperties()
    {
        $json = '{ }';
        $result = $this->check($json);
        $this->assertContains(array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'), $result);

        $json = '{ "name": "vendor/package" }';
        $this->assertEquals(array(
            array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'),
            array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'),<commit_msg>Add more tests<commit_after><?php

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

namespace Composer\Test\Json;

use JsonSchema\Validator;
use Composer\Test\TestCase;

/**
 * @author <NAME> <<EMAIL>>
 */
class ComposerSchemaTest extends TestCase
{
    public function testNamePattern()
    {
        $expectedError = array(
            array(
                'property' => 'name',
                'message' => 'Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$',
                'constraint' => 'pattern',
                'pattern' => '^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$',
            ),
        );

        $json = '{"name": "vendor/-pack__age", "description": "description"}';
        $this->assertEquals($expectedError, $this->check($json));
        $json = '{"name": "Vendor/Package", "description": "description"}';
        $this->assertEquals($expectedError, $this->check($json));
    }

    public function testRequiredProperties()
    {
        $json = '{ }';
        $result = $this->check($json);
        $this->assertContains(array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'), $result);
        $this->assertContains(array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'), $result);
        $this->assertContains(array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'), $result);
        $this->assertContains(array('property' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'), $result);

        $json = '{ "name": "vendor/package" }';
        $this->assertEquals(array(
            array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'),
            array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'),
{'fraction_non_alphanumeric': 0.20831195484864032, 'fraction_numerical': 0.01026167265264238, 'mean_word_length': 3.023735810113519, 'pattern_counts': {'":': 10, '<': 23, '<?xml version=': 0, '>': 73, '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': '1453127', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1175, 'n_words': 272}