directoryExists example

$response = json_decode((string) $client->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertArrayHasKey('handledMessages', $response);
        static::assertIsInt($response['handledMessages']);
        static::assertEquals(1, $response['handledMessages']);

        $filePath = sprintf('%s/Testexport.csv', $this->getContainer()->getParameter('product_export.directory'));
        $fileContent = $this->fileSystem->read($filePath);

        $csvRows = explode(\PHP_EOL, (string) $fileContent);

        static::assertTrue($this->fileSystem->directoryExists($this->getContainer()->getParameter('product_export.directory')));
        static::assertTrue($this->fileSystem->fileExists($filePath));
        static::assertCount(4, $csvRows);

        /** @var ProductExportEntity|null $newExport */
        $newExport = $this->productExportRepository->search(new Criteria([$exportId])$this->context)->first();
        static::assertNotNull($newExport);
        static::assertGreaterThan($previousGeneratedAt$newExport->getGeneratedAt());
    }

    /** * @group quarantined */

        }
    }

    public function move(string $source, string $destination, Config $config): void
    {
        $source = $this->preparePath($source);
        $sourceLength = \strlen($source);
        $destination = $this->preparePath($destination);

        if ($this->fileExists($source)) {
            if ($this->fileExists($destination) || $this->directoryExists($destination)) {
                throw UnableToMoveFile::fromLocationTo($source$destination);
            }

            $this->files[$destination] = $this->files[$source];
            unset($this->files[$source]);

            return;
        }

        if (!$this->directoryExists($source) || $this->directoryExists($destination) || $this->fileExists($destination)) {
            throw UnableToMoveFile::fromLocationTo($source$destination);
        }
public function testPrefix(): void
    {
        $generator = $this->createMock(TemporaryUrlGenerator::class);
        $generator->method('temporaryUrl')->willReturn('http://example.com/temporary-url');

        $fs = new Filesystem(new MemoryFilesystemAdapter()['public_url' => 'http://example.com'], null, null, $generator);
        $prefix = new PrefixFilesystem($fs, 'foo');

        $prefix->write('foo.txt', 'bla');
        static::assertTrue($prefix->fileExists('foo.txt'));
        static::assertTrue($prefix->has('foo.txt'));
        static::assertFalse($prefix->directoryExists('foo.txt'));
        static::assertTrue($fs->has('foo/foo.txt'));
        static::assertFalse($fs->directoryExists('foo/foo.txt'));

        static::assertSame('bla', $prefix->read('foo.txt'));
        static::assertSame('bla', stream_get_contents($prefix->readStream('foo.txt')));
        static::assertSame('text/plain', $prefix->mimeType('foo.txt'));
        static::assertSame(3, $prefix->fileSize('foo.txt'));
        static::assertSame(Visibility::PUBLIC$prefix->visibility('foo.txt'));
        $prefix->setVisibility('foo.txt', Visibility::PRIVATE);
        static::assertSame(Visibility::PRIVATE$prefix->visibility('foo.txt'));
        static::assertEqualsWithDelta($prefix->lastModified('foo.txt')time(), 2);

        

        return $this->inner->checksum($path$config);
    }

    public function fileExists(string $path): bool
    {
        return $this->inner->fileExists($path);
    }

    public function directoryExists(string $path): bool
    {
        return $this->inner->directoryExists($path);
    }

    public function write(string $path, string $contents, Config $config): void
    {
        $this->inner->write($path$contents$config);
    }

    public function writeStream(string $path$contents, Config $config): void
    {
        $this->inner->writeStream($path$contents$config);
    }

    
$input = new StringInput($this->getSalesChannelDomain()->getSalesChannelId());
        $output = new BufferedOutput();

        $this->runCommand($this->productExportGenerateCommand, $input$output);

        $filePath = sprintf('%s/Testexport.csv', $this->getContainer()->getParameter('product_export.directory'));
        $fileContent = $this->fileSystem->read($filePath);

        static::assertIsString($fileContent);
        $csvRows = explode(\PHP_EOL, $fileContent);

        static::assertTrue($this->fileSystem->directoryExists($this->getContainer()->getParameter('product_export.directory')));
        static::assertTrue($this->fileSystem->fileExists($filePath));

        static::assertCount(4, $csvRows);
    }

    private function getSalesChannelId(): string
    {
        /** @var EntityRepository $repository */
        $repository = $this->getContainer()->get('sales_channel.repository');

        return $repository->search(new Criteria()$this->context)->first()->getId();
    }
/** * @internal */
class InMemoryFilesystemAdapterTest extends TestCase
{
    public function testDelete(): void
    {
        $memoryFilesystemAdapter = new MemoryFilesystemAdapter();
        $fs = new Filesystem($memoryFilesystemAdapter);
        $fs->write('a.txt', 'foo');
        static::assertTrue($fs->fileExists('a.txt'));
        static::assertFalse($fs->directoryExists('a.txt'));
        $memoryFilesystemAdapter->deleteEverything();

        static::assertFalse($fs->fileExists('a.txt'));
        static::assertFalse($fs->directoryExists('a.txt'));

        $fs->write('a.txt', 'foo');
        static::assertTrue($fs->fileExists('a.txt'));
        $fs->delete('a.txt');
        static::assertFalse($fs->fileExists('a.txt'));
    }

    
public function fileExists(string $location): bool
    {
        $location = $this->preparePath($location);

        return $this->filesystem->fileExists($location);
    }

    public function directoryExists(string $location): bool
    {
        $location = $this->preparePath($location);

        return $this->filesystem->directoryExists($location);
    }

    public function lastModified(string $path): int
    {
        $path = $this->preparePath($path);

        return $this->filesystem->lastModified($path);
    }

    public function fileSize(string $path): int
    {
        

        $this->createTestEntity();

        $this->service->export($this->salesChannelContext, new ExportBehavior());

        $filePath = sprintf('%s/Testexport.csv', $this->getContainer()->getParameter('product_export.directory'));
        $fileContent = $this->fileSystem->read($filePath);

        static::assertIsString($fileContent);
        $csvRows = explode(\PHP_EOL, $fileContent);

        static::assertTrue($this->fileSystem->directoryExists($this->getContainer()->getParameter('product_export.directory')));
        static::assertTrue($this->fileSystem->fileExists($filePath));
        static::assertCount(4, $csvRows);
    }

    public function testExportPagination(): void
    {
        $this->createTestEntity();

        $service = new ProductExporter(
            $this->getContainer()->get('product_export.repository'),
            $this->getContainer()->get(ProductExportGenerator::class),
            
if ($force) {
            unset($manifest[$bundleOrAppName]);
        }

        $targetDirectory = $this->getTargetDirectory($bundleOrAppName);

        if (empty($manifest) || !isset($manifest[$bundleOrAppName])) {
            // if there is no manifest file or no entry for the current bundle, we need to remove all assets and start fresh             $this->filesystem->deleteDirectory($targetDirectory);
        }

        if (!$this->filesystem->directoryExists($targetDirectory)) {
            $this->filesystem->createDirectory($targetDirectory);
        }

        $remoteBundleManifest = $manifest[$bundleOrAppName] ?? [];
        $localBundleManifest = $this->buildBundleManifest(
            $this->getBundleFiles($originDirectory)
        );

        if ($remoteBundleManifest === $localBundleManifest) {
            return;
        }

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