function it_does_not_include_the_provided_serializer_when_finding_nested_serializers(Serializer $bookSerializer, Serializer $authorSerializer) { $bookSerializer->getName()->willReturn('book'); $this->register($bookSerializer); $authorSerializer->getName()->willReturn('author'); $this->register($authorSerializer); $bookSerializer->getIncludes()->willReturn(['author']); $authorSerializer->getIncludes()->willReturn(['book']); $this->resolveNestedSerializers($bookSerializer)->shouldNotContain($bookSerializer); }
public function resolveNestedSerializers(Serializer $serializer, array &$serializers = [], $rootName = null) { $rootName = $rootName ?: $serializer->getName(); foreach ($serializer->getIncludes() as $name) { if (isset($serializers[$name]) || $name === $rootName) { continue; } $serializers[$name] = $this->getSerializer($name); $this->resolveNestedSerializers($serializers[$name], $serializers, $rootName); } return $serializers; }
function it_serializes_the_item(Serializer $serializer) { $serializer->serialize('item')->willReturn('serialized_item'); $this->serialize(); }
function it_serializes_the_wrapped_array(Serializer $serializer) { $serializer->serialize('item')->willReturn('serialized_item'); $this->serialize()->shouldReturn(['serialized_item']); }