/** * @param ExtensionInterface $extension * @throws \Exception */ public function extend(ExtensionInterface $extension) { foreach ($extension->getTypes() as $type) { $this->resolver->addType($type); } foreach ($extension->getEncoders() as $encoder) { $this->encoder->addFormat($encoder); } }
public function testGetDefinitionByName() { $options = array('foo' => 'bar'); $type = $this->getTypeMock(); $type->expects($this->atLeastOnce())->method('getName')->will($this->returnValue('foo')); $type->expects($this->once())->method('setDefaultOptions')->will($this->returnCallback(function (OptionsResolver $resolver) { $resolver->setDefaults(array('foo' => 'baz')); })); $type->expects($this->once())->method('build')->with($this->isInstanceOf('Bcn\\Component\\Serializer\\Definition\\Builder'), $options)->will($this->returnCallback(function (Builder $builder) { $builder->node('test'); })); $resolver = new Resolver(); $resolver->addType($type); $definition = $resolver->getDefinition('foo', $options); $this->assertTrue($definition->hasProperty('test')); }