loadFromFile example

$currentMedia,
            $destination,
            $mediaFile->getFileExtension(),
            $context
        );

        $this->validateFileExtension($mediaFile$mediaId$currentMedia->isPrivate());

        $this->removeOldMediaData($currentMedia$context);

        $mediaType = $this->typeDetector->detect($mediaFile);
        $metaData = $this->metadataLoader->loadFromFile($mediaFile$mediaType);

        $media = $this->updateMediaEntity(
            $mediaFile,
            $destination,
            $currentMedia,
            $metaData,
            $mediaType,
            $context
        );

        $this->saveFileToMediaDir($mediaFile$media);

        
/** * @internal */
class MetadataLoaderTest extends TestCase
{
    use IntegrationTestBehaviour;

    public function testJpg(): void
    {
        $result = $this
            ->getMetadataLoader()
            ->loadFromFile($this->createMediaFile(__DIR__ . '/../fixtures/shopware.jpg')new ImageType());

        $expected = [
            'type' => \IMAGETYPE_JPEG,
            'width' => 1530,
            'height' => 1021,
        ];

        static::assertIsArray($result);
        static::assertEquals($expected$result);
    }

    
public function testPropertyInfoCacheDisabled()
    {
        $container = $this->createContainerFromFile('property_info', ['kernel.debug' => true, 'kernel.container_class' => __CLASS__]);
        $this->assertFalse($container->hasDefinition('property_info.cache'));
    }

    public function testEventDispatcherService()
    {
        $container = $this->createContainer(['kernel.charset' => 'UTF-8', 'kernel.secret' => 'secret']);
        $container->registerExtension(new FrameworkExtension());
        $container->getCompilerPassConfig()->setBeforeOptimizationPasses([new LoggerPass()]);
        $this->loadFromFile($container, 'default_config');
        $container
            ->register('foo', \stdClass::class)
            ->setPublic(true)
            ->setProperty('dispatcher', new Reference('event_dispatcher'));
        $container->compile();
        $this->assertInstanceOf(EventDispatcherInterface::class$container->get('foo')->dispatcher);
    }

    public function testCacheDefaultRedisProvider()
    {
        $container = $this->createContainerFromFile('cache');

        
$this->assertCount(1, $container->getDefinition('twig.mime_body_renderer')->getArguments());
        }
    }

    /** * @dataProvider getFormats */
    public function testLoadFullConfiguration($format)
    {
        $container = $this->createContainer();
        $container->registerExtension(new TwigExtension());
        $this->loadFromFile($container, 'full', $format);
        $this->compileContainer($container);

        $this->assertEquals(Environment::class$container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file');

        // Form resources         $resources = $container->getParameter('twig.form.resources');
        $this->assertContains('form_div_layout.html.twig', $resources, '->load() includes default template for form resources');
        $this->assertContains('MyBundle::form.html.twig', $resources, '->load() merges new templates into form resources');

        // Globals         $calls = $container->getDefinition('twig')->getMethodCalls();
        
Home | Imprint | This part of the site doesn't use cookies.