@@ -96,6 +96,7 @@ public function testNormalize()
96
96
97
97
$ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
98
98
$ resourceClassResolverProphecy ->getResourceClass ($ dummy , null , true )->willReturn (Dummy::class)->shouldBeCalled ();
99
+ $ resourceClassResolverProphecy ->getResourceClass ($ dummy , Dummy::class, true )->willReturn (Dummy::class)->shouldBeCalled ();
99
100
100
101
$ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
101
102
$ serializerProphecy ->willImplement (NormalizerInterface::class);
@@ -119,4 +120,47 @@ public function testNormalize()
119
120
];
120
121
$ this ->assertEquals ($ expected , $ normalizer ->normalize ($ dummy ));
121
122
}
123
+
124
+ public function testNormalizeWithoutCache ()
125
+ {
126
+ $ dummy = new Dummy ();
127
+ $ dummy ->setName ('hello ' );
128
+
129
+ $ propertyNameCollection = new PropertyNameCollection (['name ' ]);
130
+ $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
131
+ $ propertyNameCollectionFactoryProphecy ->create (Dummy::class, [])->willReturn ($ propertyNameCollection )->shouldBeCalled ();
132
+
133
+ $ propertyMetadataFactory = new PropertyMetadata (null , null , true );
134
+ $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
135
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'name ' , [])->willReturn ($ propertyMetadataFactory )->shouldBeCalled ();
136
+
137
+ $ iriConverterProphecy = $ this ->prophesize (IriConverterInterface::class);
138
+ $ iriConverterProphecy ->getIriFromItem ($ dummy )->willReturn ('/dummies/1988 ' )->shouldBeCalled ();
139
+
140
+ $ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
141
+ $ resourceClassResolverProphecy ->getResourceClass ($ dummy , null , true )->willReturn (Dummy::class)->shouldBeCalled ();
142
+ $ resourceClassResolverProphecy ->getResourceClass ($ dummy , Dummy::class, true )->willReturn (Dummy::class)->shouldBeCalled ();
143
+
144
+ $ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
145
+ $ serializerProphecy ->willImplement (NormalizerInterface::class);
146
+ $ serializerProphecy ->normalize ('hello ' , null , Argument::type ('array ' ))->willReturn ('hello ' )->shouldBeCalled ();
147
+
148
+ $ normalizer = new ItemNormalizer (
149
+ $ propertyNameCollectionFactoryProphecy ->reveal (),
150
+ $ propertyMetadataFactoryProphecy ->reveal (),
151
+ $ iriConverterProphecy ->reveal (),
152
+ $ resourceClassResolverProphecy ->reveal ()
153
+ );
154
+ $ normalizer ->setSerializer ($ serializerProphecy ->reveal ());
155
+
156
+ $ expected = [
157
+ '_links ' => [
158
+ 'self ' => [
159
+ 'href ' => '/dummies/1988 ' ,
160
+ ],
161
+ ],
162
+ 'name ' => 'hello ' ,
163
+ ];
164
+ $ this ->assertEquals ($ expected , $ normalizer ->normalize ($ dummy , null , ['not_serializable ' => function () {}]));
165
+ }
122
166
}
0 commit comments