Repository: symfony/symfony
File: src/Symfony/Component/JsonStreamer/Tests/Write/StreamWriterGeneratorTest.php (PHP)

Code before:
        yield ['nullable_backed_enum', Type::nullable(Type::enum(DummyBackedEnum::class, Type::string()))];

        yield ['list', Type::list()];
        yield ['bool_list', Type::list(Type::bool())];
        yield ['null_list', Type::list(Type::null())];
        yield ['object_list', Type::list(Type::object(DummyWithNameAttributes::class))];
        yield ['nullable_object_list', Type::nullable(Type::list(Type::object(DummyWithNameAttributes::class)))];
        yield ['nested_list', Type::list(Type::object(DummyWithArray::class))];
        yield ['double_nested_list', Type::list(Type::object(DummyWithNestedArray::class))];
        yield ['object_with_nested_self', Type::object(DummyWithNestedDummies::class)];
        yield ['object_with_nested_dict_self', Type::object(DummyWithNestedDictDummies::class)];

        yield ['dict', Type::dict()];
        yield ['object_dict', Type::dict(Type::object(DummyWithNameAttributes::class))];
        yield ['nullable_object_dict', Type::nullable(Type::dict(Type::object(DummyWithNameAttributes::class)))];

        yield ['iterable', Type::iterable()];
        yield ['object_iterable', Type::iterable(Type::object(ClassicDummy::class))];

        yield ['object', Type::object(DummyWithNameAttributes::class)];
        yield ['nullable_object', Type::nullable(Type::object(DummyWithNameAttributes::class))];
        yield ['object_in_object', Type::object(DummyWithOtherDummies::class)];
        yield ['object_with_value_transformer', Type::object(DummyWithValueTransformerAttributes::class)];
        yield ['self_referencing_object', Type::object(SelfReferencingDummy::class)];
        yield ['self_referencing_object_list', Type::object(SelfReferencingDummyList::class)];
        yield ['object_with_dollar_named_properties', Type::object(DummyWithDollarNamedProperties::class)];
        yield ['object_with_synthetic_properties', Type::object(DummyWithSyntheticProperties::class), new SyntheticPropertyMetadataLoader()];

        yield ['union', Type::union(Type::int(), Type::list(Type::enum(DummyBackedEnum::class)), Type::object(DummyWithNameAttributes::class))];
        yield ['object_with_union', Type::object(DummyWithUnionProperties::class)];
    }

    public function testDoNotSupportIntersectionType()
    {
        $generator = new StreamWriterGenerator(new PropertyMetadataLoader(TypeResolver::create()), $this->streamWritersDir);

        $this->expectException(UnsupportedException::class);
        $this->expectExceptionMessage('"Stringable&Traversable" type is not supported.');

        $generator->generate(Type::intersection(Type::object(\Traversable::class), Type::object(\Stringable::class)));
    }

    public function testDoNotSupportEnumType()
    {
        $generator = new StreamWriterGenerator(new PropertyMetadataLoader(TypeResolver::create()), $this->streamWritersDir);

        $this->expectException(UnsupportedException::class);
        $this->expectExceptionMessage(\sprintf('"%s" type is not supported.', DummyEnum::class));

        $generator->generate(Type::enum(DummyEnum::class));
    }

Review comment (suggestion):
```suggestion
        yield ['self_referencing_object_list', Type::object(SelfReferencingDummyList::class)];
        yield ['self_referencing_object_dict', Type::object(SelfReferencingDummyDict::class)];
```

Code after:
        yield ['backed_enum', Type::enum(DummyBackedEnum::class, Type::string())];
        yield ['nullable_backed_enum', Type::nullable(Type::enum(DummyBackedEnum::class, Type::string()))];

        yield ['list', Type::list()];
        yield ['bool_list', Type::list(Type::bool())];
        yield ['null_list', Type::list(Type::null())];
        yield ['object_list', Type::list(Type::object(DummyWithNameAttributes::class))];
        yield ['nullable_object_list', Type::nullable(Type::list(Type::object(DummyWithNameAttributes::class)))];
        yield ['nested_list', Type::list(Type::object(DummyWithArray::class))];
        yield ['double_nested_list', Type::list(Type::object(DummyWithNestedArray::class))];
        yield ['object_with_nested_list_self', Type::object(DummyWithNestedListDummies::class)];
        yield ['object_with_nested_dict_self', Type::object(DummyWithNestedDictDummies::class)];

        yield ['dict', Type::dict()];
        yield ['object_dict', Type::dict(Type::object(DummyWithNameAttributes::class))];
        yield ['nullable_object_dict', Type::nullable(Type::dict(Type::object(DummyWithNameAttributes::class)))];

        yield ['iterable', Type::iterable()];
        yield ['object_iterable', Type::iterable(Type::object(ClassicDummy::class))];

        yield ['object', Type::object(DummyWithNameAttributes::class)];
        yield ['nullable_object', Type::nullable(Type::object(DummyWithNameAttributes::class))];
        yield ['object_in_object', Type::object(DummyWithOtherDummies::class)];
        yield ['object_with_value_transformer', Type::object(DummyWithValueTransformerAttributes::class)];
        yield ['self_referencing_object', Type::object(SelfReferencingDummy::class)];
        yield ['self_referencing_object_list', Type::object(SelfReferencingDummyList::class)];
        yield ['self_referencing_object_dict', Type::object(SelfReferencingDummyDict::class)];
        yield ['object_with_dollar_named_properties', Type::object(DummyWithDollarNamedProperties::class)];
        yield ['object_with_synthetic_properties', Type::object(DummyWithSyntheticProperties::class), new SyntheticPropertyMetadataLoader()];

        yield ['union', Type::union(Type::int(), Type::list(Type::enum(DummyBackedEnum::class)), Type::object(DummyWithNameAttributes::class))];
        yield ['object_with_union', Type::object(DummyWithUnionProperties::class)];
    }

    public function testDoNotSupportIntersectionType()
    {
        $generator = new StreamWriterGenerator(new PropertyMetadataLoader(TypeResolver::create()), $this->streamWritersDir);

        $this->expectException(UnsupportedException::class);
        $this->expectExceptionMessage('"Stringable&Traversable" type is not supported.');

        $generator->generate(Type::intersection(Type::object(\Traversable::class), Type::object(\Stringable::class)));
    }

    public function testDoNotSupportEnumType()
    {
        $generator = new StreamWriterGenerator(new PropertyMetadataLoader(TypeResolver::create()), $this->streamWritersDir);

        $this->expectException(UnsupportedException::class);
        $this->expectExceptionMessage(\sprintf('"%s" type is not supported.', DummyEnum::class));