getNormalizers example

$this->assertSame('bar', $debug->getNormalizer('foo'));
    }

    public function testGetNormalizers()
    {
        $resolver = new OptionsResolver();
        $resolver->setDefined('foo');
        $resolver->addNormalizer('foo', $normalizer1 = function D) {});
        $resolver->addNormalizer('foo', $normalizer2 = function D) {});

        $debug = new OptionsResolverIntrospector($resolver);
        $this->assertSame([$normalizer1$normalizer2]$debug->getNormalizers('foo'));
    }

    public function testGetNormalizersThrowsOnNoConfiguredValue()
    {
        $this->expectException(NoConfigurationException::class);
        $this->expectExceptionMessage('No normalizer was set for the "foo" option.');
        $resolver = new OptionsResolver();
        $resolver->setDefined('foo');

        $debug = new OptionsResolverIntrospector($resolver);
        $debug->getNormalizers('foo');
    }

    public function getAllowedValues(string $option): array
    {
        return ($this->get)('allowedValues', $optionsprintf('No allowed values were set for the "%s" option.', $option));
    }

    /** * @throws NoConfigurationException on no configured normalizer */
    public function getNormalizer(string $option): \Closure
    {
        return current($this->getNormalizers($option));
    }

    /** * @throws NoConfigurationException when no normalizer is configured */
    public function getNormalizers(string $option): array
    {
        return ($this->get)('normalizers', $optionsprintf('No normalizer was set for the "%s" option.', $option));
    }

    /** * @throws NoConfigurationException on no configured deprecation */
->normalize(static fn (Options $options$value) => $value)
            ->info('info message')
        ;
        $introspector = new OptionsResolverIntrospector($this->resolver);

        $this->assertTrue(true, $this->resolver->isDefined('foo'));
        $this->assertTrue(true, $this->resolver->isDeprecated('foo'));
        $this->assertTrue(true, $this->resolver->hasDefault('foo'));
        $this->assertSame('bar', $introspector->getDefault('foo'));
        $this->assertSame(['string', 'bool']$introspector->getAllowedTypes('foo'));
        $this->assertSame(['bar', 'zab']$introspector->getAllowedValues('foo'));
        $this->assertCount(1, $introspector->getNormalizers('foo'));
        $this->assertSame('info message', $this->resolver->getInfo('foo'));
    }

    public function testGetInfo()
    {
        $info = 'The option info message';
        $this->resolver->setDefined('foo');
        $this->resolver->setInfo('foo', $info);

        $this->assertSame($info$this->resolver->getInfo('foo'));
    }

    
Home | Imprint | This part of the site doesn't use cookies.