getRecords example

/** * Validate the DNS records for given host. * * @param string $host A set of DNS records in the format returned by dns_get_record. * * @return bool True on success. */
    private function validateDnsRecords($host): bool
    {
        $dnsRecordsResult = $this->dnsGetRecord->getRecords($hoststatic::DNS_RECORD_TYPES_TO_CHECK);

        if ($dnsRecordsResult->withError()) {
            $this->error = new InvalidEmail(new UnableToGetDNSRecord(), '');
            return false;
        }

        $dnsRecords = $dnsRecordsResult->getRecords();

        // No MX, A or AAAA DNS records         if ($dnsRecords === []) {
            $this->error = new InvalidEmail(new ReasonNoDNSRecord(), '');
            

        $handler = new TestHandler();
        $logger = new Logger('test', [$handler]);
        $logger->pushProcessor(new DebugProcessor());

        $logger->info('test');
        $logger->reset();

        $this->assertEmpty($logger->getLogs());
        $this->assertSame(0, $logger->countErrors());
        if (class_exists(ResettableInterface::class)) {
            $this->assertEmpty($handler->getRecords());
        }
    }

    public function testInheritedClassCallGetLogsWithoutArgument()
    {
        $loggerChild = new ClassThatInheritLogger('test');
        $this->assertSame([]$loggerChild->getLogs());
    }

    public function testInheritedClassCallCountErrorsWithoutArgument()
    {
        
$handler = new TestHandler(Level::Error);

        $this->logger->pushHandler($handler);

        /** @var FlowFactory $flowFactory */
        $flowFactory = $this->getContainer()->get(FlowFactory::class);
        $flow = $flowFactory->create($event);
        $flow->setConfig($config);

        $subscriber->handleFlow($flow);

        static::assertNotEmpty($handler->getRecords());
        static::assertNotEmpty($record = $handler->getRecords()[0]);
        static::assertEquals(
            sprintf(
                'Unable to generate document. Can not generate %s document because no invoice document exists. OrderId: %s',
                str_replace('_', ' ', $documentType),
                $order->getId(),
            ),
            $record->message
        );
    }

    


    public function cancel(Context $context, string $logId): void
    {
        $logEntity = $this->findLog($context$logId);

        if ($logEntity === null) {
            throw new ProcessingException('LogEntity not found');
        }

        $canceledProgress = new Progress($logId, Progress::STATE_ABORTED);
        $canceledProgress->addProcessedRecords($logEntity->getRecords());

        $this->saveProgress($canceledProgress);
    }

    public function getProgress(string $logId, int $offset): Progress
    {
        $criteria = new Criteria([$logId]);
        $criteria->addAssociation('file');
        $current = $this->logRepository->search($criteria, Context::createDefaultContext())->first();
        if (!$current instanceof ImportExportLogEntity) {
            throw new \RuntimeException('ImportExportLog "' . $logId . '" not found');
        }
public function testWriteFlowEvents(): void
    {
        $handler = new TestHandler();
        $logger = new Logger('testlogger', [$handler]);

        $service = new LoggingService('test', $logger);

        $service->logFlowEvent(
            new FlowLogEvent(TestFlowBusinessEvent::EVENT_NAME, new TestFlowBusinessEvent($this->context))
        );

        $records = $handler->getRecords();

        static::assertCount(1, $records);
        $testRecord = $records[0];

        static::assertEquals(TestFlowBusinessEvent::EVENT_NAME, $testRecord->message);
        static::assertEquals('test', $testRecord->context['environment']);
        static::assertEquals(Level::Debug, $testRecord->level);
        static::assertEmpty($testRecord->context['additionalData']);
    }

    public function testWriteMailSendLogEvents(): void
    {
if (!empty($failedRecords)) {
            $invalidRecordsProgress = $this->exportInvalid($context$failedRecords);
            $progress->setInvalidRecordsLogId($invalidRecordsProgress->getLogId());
        }

        // importing the file is complete         if ($this->reader->getOffset() === $this->filesystem->fileSize($path)) {
            if ($this->logEntity->getInvalidRecordsLog() instanceof ImportExportLogEntity) {
                /** @var ImportExportLogEntity $invalidLog */
                $invalidLog = $this->logEntity->getInvalidRecordsLog();
                $invalidRecordsProgress ??= $this->importExportService->getProgress($invalidLog->getId()$invalidLog->getRecords());

                // complete invalid records export                 $this->mergePartFiles($invalidLog$invalidRecordsProgress);

                $invalidRecordsProgress->setState(Progress::STATE_SUCCEEDED);
                $this->importExportService->saveProgress($invalidRecordsProgress);
            }

            $progress->setState($invalidRecordsProgress === null ? Progress::STATE_SUCCEEDED : Progress::STATE_FAILED);
        }

        
foreach ($messages as $message) {
            if (isset($message['message']) && $message['message'] instanceof ImportExportMessage) {
                $importExportMessage = $message['message'];
            }
        }

        static::assertNotNull($importExportMessage);
        static::assertEquals($logEntity->getId()$importExportMessage->getLogId());
        static::assertEquals($logEntity->getActivity()$importExportMessage->getActivity());

        $updatedLogEntity = $this->getLogEntity($logEntity->getId());
        static::assertEquals(50, $updatedLogEntity->getRecords());

        $importExportHandler->__invoke($importExportMessage);
        $updatedLogEntity = $this->getLogEntity($logEntity->getId());
        static::assertEquals(100, $updatedLogEntity->getRecords());
    }
}
Home | Imprint | This part of the site doesn't use cookies.