createFactory example


    public static function incompleteDsnProvider(): iterable
    {
        return [];
    }

    /** * @dataProvider supportsProvider */
    public function testSupports(bool $expected, string $dsn)
    {
        $factory = $this->createFactory();

        $this->assertSame($expected$factory->supports(new Dsn($dsn)));
    }

    /** * @dataProvider createProvider */
    public function testCreate(string $expected, string $dsn)
    {
        $factory = $this->createFactory();
        $provider = $factory->create(new Dsn($dsn));

        
use PHPUnit\Framework\TestCase;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\RateLimiter\Policy\FixedWindowLimiter;
use Symfony\Component\RateLimiter\Policy\TokenBucketLimiter;
use Symfony\Component\RateLimiter\RateLimiterFactory;
use Symfony\Component\RateLimiter\Storage\StorageInterface;

class LimiterTest extends TestCase
{
    public function testTokenBucket()
    {
        $factory = $this->createFactory([
            'id' => 'test',
            'policy' => 'token_bucket',
            'limit' => 10,
            'rate' => ['interval' => '1 second'],
        ]);
        $limiter = $factory->create('127.0.0.1');

        $this->assertInstanceOf(TokenBucketLimiter::class$limiter);
    }

    public function testFixedWindow()
    {
use Symfony\Component\AssetMapper\Exception\RuntimeException;
use Symfony\Component\AssetMapper\Factory\MappedAssetFactory;
use Symfony\Component\AssetMapper\MappedAsset;
use Symfony\Component\AssetMapper\Path\PublicAssetsPathResolverInterface;

class MappedAssetFactoryTest extends TestCase
{
    private AssetMapperInterface&MockObject $assetMapper;

    public function testCreateMappedAsset()
    {
        $factory = $this->createFactory();

        $asset = $factory->createMappedAsset('file2.js', __DIR__.'/../fixtures/dir1/file2.js');
        $this->assertSame('file2.js', $asset->logicalPath);
        $this->assertMatchesRegularExpression('/^\/final-assets\/file2-[a-zA-Z0-9]{7,128}\.js$/', $asset->publicPath);
        $this->assertSame('/final-assets/file2.js', $asset->publicPathWithoutDigest);
    }

    public function testCreateMappedAssetRespectsPreDigestedPaths()
    {
        $assetMapper = $this->createFactory();
        $asset = $assetMapper->createMappedAsset('already-abcdefVWXYZ0123456789.digested.css', __DIR__.'/../fixtures/dir2/already-abcdefVWXYZ0123456789.digested.css');
        
private MockObject&LoggerInterface $logger;
    private MockObject&LoaderInterface $loader;
    private MockObject&XliffFileDumper $xliffFileDumper;
    private MockObject&CacheItemPoolInterface $cache;
    private string $defaultLocale;

    /** * @dataProvider supportsProvider */
    public function testSupports(bool $expected, string $dsn)
    {
        $factory = $this->createFactory();

        $this->assertSame($expected$factory->supports(new Dsn($dsn)));
    }

    /** * @dataProvider createProvider */
    public function testCreate(string $expected, string $dsn)
    {
        $factory = $this->createFactory();
        $provider = $factory->create(new Dsn($dsn));

        

    public static function missingRequiredOptionProvider(): iterable
    {
        return [];
    }

    /** * @dataProvider supportsProvider */
    public function testSupports(bool $expected, string $dsn)
    {
        $factory = $this->createFactory();

        $this->assertSame($expected$factory->supports(new Dsn($dsn)));
    }

    /** * @dataProvider createProvider */
    public function testCreate(string $expected, string $dsn)
    {
        $factory = $this->createFactory();
        $transport = $factory->create(new Dsn($dsn));

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