getTxt example

$this->deleteMediaService = new DeleteNotUsedMediaService(
            $this->mediaRepo,
            $this->getContainer()->get('media_default_folder.repository')
        );
    }

    public function testCountNotUsedMedia(): void
    {
        $this->setFixtureContext($this->context);

        $this->getTxt();
        $this->getPngWithoutExtension();
        $this->getMediaWithProduct();
        $this->getMediaWithManufacturer();

        static::assertEquals(2, $this->deleteMediaService->countNotUsedMedia($this->context));
    }

    public function testDeleteNotUsedMedia(): void
    {
        $this->setFixtureContext($this->context);

        
$tempFile = tempnam(sys_get_temp_dir(), '');
        static::assertIsString($tempFile);
        copy(self::TEST_IMAGE, $tempFile);

        $fileSize = filesize($tempFile);
        static::assertIsInt($fileSize);
        $mediaFile = new MediaFile($tempFile, 'image/png', 'png', $fileSize);

        $context = Context::createDefaultContext();

        $this->setFixtureContext($context);
        $media = $this->getTxt();

        $oldMediaFilePath = $this->urlGenerator->getRelativeMediaUrl($media);
        $this->getPublicFilesystem()->write($oldMediaFilePath, 'Some ');

        static::assertIsString($media->getFileName());

        try {
            $this->fileSaver->persistFileToMedia(
                $mediaFile,
                $media->getFileName(),
                $media->getId(),
                
$this->unusedMediaPurger = new UnusedMediaPurger(
            $this->mediaRepo,
            new EventDispatcher()
        );
    }

    public function testDeleteNotUsedMedia(): void
    {
        $this->setFixtureContext($this->context);

        $txt = $this->getTxt();
        $png = $this->getPng();
        $withProduct = $this->getMediaWithProduct();
        $withManufacturer = $this->getMediaWithManufacturer();

        $urlGenerator = $this->getContainer()->get(UrlGeneratorInterface::class);
        $firstPath = $urlGenerator->getRelativeMediaUrl($txt);
        $secondPath = $urlGenerator->getRelativeMediaUrl($png);
        $thirdPath = $urlGenerator->getRelativeMediaUrl($withProduct);
        $fourthPath = $urlGenerator->getRelativeMediaUrl($withManufacturer);

        $this->getPublicFilesystem()->writeStream($firstPath, \fopen(self::FIXTURE_FILE, 'rb'));
        


    public function testUuidFilename(): void
    {
        $this->assertFilenameGenerator($this->getUuidPathnameStrategy());
    }

    public function testUuidEncoding(): void
    {
        $this->assertHashGenerator($this->getUuidPathnameStrategy()$this->getJpgWithFolder(), 8);
        $this->assertHashGenerator($this->getUuidPathnameStrategy()$this->getJpg(), 8);
        $this->assertHashGenerator($this->getUuidPathnameStrategy()$this->getTxt(), 8);
    }

    public function testMd5CacheBuster(): void
    {
        $this->assertCacheBusterGenerator($this->getMd5PathnameStrategy());
    }

    public function testMd5Filename(): void
    {
        $this->assertFilenameGenerator($this->getMd5PathnameStrategy());
    }

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