prepareImportExportFileTestData example


        $commandTester = new CommandTester($this->deleteExpiredFilesCommand);
        $commandTester->execute([]);

        $message = $commandTester->getDisplay();
        static::assertMatchesRegularExpression('/\/\/ No expired files found./', $message);
    }

    public function testExecuteWithAllFilesExpired(): void
    {
        $num = 5;
        $data = $this->prepareImportExportFileTestData($num);

        $filePathes = [];
        foreach (array_keys($data) as $key) {
            $filePathes[] = $data[$key]['path'];
            $data[$key]['expireDate'] = date('Y-m-d H:i:s', strtotime('-1 second'));
        }

        $this->fileRepository->create(array_values($data)$this->context);

        $commandTester = new CommandTester($this->deleteExpiredFilesCommand);
        $commandTester->setInputs(['y']);
        
private Context $context;

    protected function setUp(): void
    {
        $this->repository = $this->getContainer()->get('import_export_file.repository');
        $this->connection = $this->getContainer()->get(Connection::class);
        $this->context = Context::createDefaultContext();
    }

    public function testImportExportFileSingleCreateSuccess(): void
    {
        $data = $this->prepareImportExportFileTestData();

        $id = array_key_first($data);

        $this->repository->create([$data[$id]]$this->context);

        $record = $this->connection->fetchAssociative('SELECT * FROM import_export_file WHERE id = :id', ['id' => $id]);

        $expect = $data[$id];
        static::assertNotEmpty($record);
        static::assertEquals($id$record['id']);
        static::assertEquals($expect['originalName']$record['original_name']);
        
protected function setUp(): void
    {
        $this->repository = $this->getContainer()->get('import_export_file.repository');
        $this->connection = $this->getContainer()->get(Connection::class);
        $this->context = Context::createDefaultContext();
    }

    public function testImportExportFileCreateSuccess(): void
    {
        $num = 3;
        $data = $this->prepareImportExportFileTestData($num);

        foreach ($data as $entry) {
            $this->getBrowser()->request('POST', $this->prepareRoute()[][][]json_encode($entry, \JSON_THROW_ON_ERROR));
            $response = $this->getBrowser()->getResponse();
            static::assertSame(Response::HTTP_NO_CONTENT, $response->getStatusCode()$response->getContent());
        }
        $records = $this->connection->fetchAllAssociative('SELECT * FROM import_export_file');

        static::assertCount($num$records);
        foreach ($records as $record) {
            $expect = $data[$record['id']];
            
Home | Imprint | This part of the site doesn't use cookies.