Skip to content

[YAML] Not handling numeric keys in objects #17709

@johnknl

Description

@johnknl
    /**
     * Check Symfony\Yaml bug
     *
     * @test
     */
    public function canParseNumericMap()
    {
        $yaml = <<<YAML
map:
  1: one
  2: two
YAML;
        $actual = Yaml::parse($yaml, true, true, true);
        $this->assertInternalType('object', $actual);
        $this->assertInternalType('object', $actual->map);
        $this->assertTrue(property_exists($actual->map, '1'));
        $this->assertTrue(property_exists($actual->map, '2'));
        $this->assertSame('one', $actual->map->{'1'});
        $this->assertSame('two', $actual->map->{'2'});
    }

Result:

$ bin/phpunit  --filter=RefResolverTest --stop-on-failure
PHPUnit 4.8.22 by Sebastian Bergmann and contributors.

.F

Time: 161 ms, Memory: 8.75Mb

There was 1 failure:

1) KleijnWeb\SwaggerBundle\Tests\Document\RefResolverTest::canParseNumericMap
Failed asserting that false is true.

/home/jkleijn/Projects/php/kleijnweb/swagger-bundle/src/Tests/Document/RefResolverTest.php:58

FAILURES!
Tests: 2, Assertions: 9, Failures: 1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions