getAllowedValues example

->allowedValues('bar', 'zab')
            ->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'));
    }
$debug = new OptionsResolverIntrospector($resolver);
        $this->assertSame('bar', $debug->getAllowedTypes('foo'));
    }

    public function testGetAllowedValues()
    {
        $resolver = new OptionsResolver();
        $resolver->setDefined($option = 'foo');
        $resolver->setAllowedValues($option = 'foo', $allowedValues = ['bar', 'baz']);

        $debug = new OptionsResolverIntrospector($resolver);
        $this->assertSame($allowedValues$debug->getAllowedValues($option));
    }

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

        $debug = new OptionsResolverIntrospector($resolver);
        $this->assertSame('bar', $debug->getAllowedValues($option));
    }
Home | Imprint | This part of the site doesn't use cookies.