createDocument example

$response = $this->getBrowser()->getResponse();
        static::assertEquals(200, $response->getStatusCode());

        static::assertEquals($expectedFileContent$response->getContent());
        static::assertEquals($expectedContentType$response->headers->get('content-type'));
    }

    public function testCreateDocuments(): void
    {
        $order1 = $this->createOrder($this->customerId, $this->context);
        $order2 = $this->createOrder($this->customerId, $this->context);
        $this->createDocument(InvoiceRenderer::TYPE, $order1->getId()[
            'documentType' => 'invoice',
            'custom' => [
                'invoiceNumber' => '1100',
            ],
        ]$this->context);

        $this->createDocument(InvoiceRenderer::TYPE, $order2->getId()[
            'documentType' => 'invoice',
            'documentRangerType' => 'document_invoice',
            'custom' => [
                'invoiceNumber' => '1101',
            ],

    public function createDocumentAction()
    {
        $orderId = (int) $this->Request()->getParam('orderId');
        $documentType = (int) $this->Request()->getParam('documentType');

        // Needs to be called this early since $this->createDocument boots the         // shop, the order was made in, and thereby destroys the backend session         $translationComponent = $this->get(Shopware_Components_Translation::class);

        if ($orderId !== 0 && $documentType !== 0) {
            $this->createDocument($orderId$documentType);
        }

        $query = $this->getRepository()->getOrdersQuery([['property' => 'orders.id', 'value' => $orderId]], null, 0, 1);
        $query->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);
        $order = iterator_to_array($this->getModelManager()->createPaginator($query));

        $order = $translationComponent->translateOrders($order);

        $this->View()->assign([
            'success' => true,
            'data' => $order,
        ]);
static::assertEquals($this->getBrowser()->getResponse()->getStatusCode(), Response::HTTP_OK);
        static::assertNotNull($this->getBrowser()->getResponse()->getContent());
        static::assertEquals(PdfRenderer::FILE_CONTENT_TYPE, $this->getBrowser()->getResponse()->headers->get('content-type'));
    }

    public function testCreateDocuments(): void
    {
        static::assertNotNull($customer = $this->salesChannelContext->getCustomer());
        $order1 = $this->createOrder($customer->getId()$this->context);
        $order2 = $this->createOrder($customer->getId()$this->context);
        $this->createDocument(InvoiceRenderer::TYPE, $order1->getId()[
            'documentType' => 'invoice',
            'custom' => [
                'invoiceNumber' => '1100',
            ],
        ]$this->context);

        $this->createDocument(InvoiceRenderer::TYPE, $order2->getId()[
            'documentType' => 'invoice',
            'documentRangerType' => 'document_invoice',
            'custom' => [
                'invoiceNumber' => '1101',
            ],
$this->options = $options;

        if (isset($options[self::OPT_TARGET_DOC])) {
            $this->doc = $options[self::OPT_TARGET_DOC];
        } else {
            $impl = new \DOMImplementation();
            // XXX:             // Create the doctype. For now, we are always creating HTML5             // documents, and attempting to up-convert any older DTDs to HTML5.             $dt = $impl->createDocumentType('html');
            // $this->doc = \DOMImplementation::createDocument(NULL, 'html', $dt);             $this->doc = $impl->createDocument(null, '', $dt);
            $this->doc->encoding = !empty($options['encoding']) ? $options['encoding'] : 'UTF-8';
        }

        $this->errors = array();

        $this->current = $this->doc; // ->documentElement;
        // Create a rules engine for tags.         $this->rules = new TreeBuildingRules();

        $implicitNS = array();
        
->request(
                'GET',
                '/store-api/order',
                $this->requestCriteriaBuilder->toArray($criteria),
            );

        static::assertSame(Response::HTTP_FORBIDDEN, $this->browser->getResponse()->getStatusCode());
    }

    public function testGetOrderShowsValidDocuments(): void
    {
        $this->createDocument($this->orderId);

        $criteria = new Criteria([$this->orderId]);

        $this->browser
            ->request(
                'GET',
                '/store-api/order',
                $this->requestCriteriaBuilder->toArray($criteria)
            );

        $response = json_decode((string) $this->browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        
$invoice = $this->referenceInvoiceLoader->load($orderId);

        static::assertEmpty($invoice);
    }

    public function testLoadWithoutReferenceDocumentId(): void
    {
        $cart = $this->generateDemoCart(2);
        $orderId = $this->persistCart($cart);

        // Create two documents, the latest invoice will be returned         $invoiceStruct1 = $this->createDocument(InvoiceRenderer::TYPE, $orderId[]$this->context)->first();
        $invoiceStruct = $this->createDocument(InvoiceRenderer::TYPE, $orderId[]$this->context)->first();
        static::assertNotNull($invoiceStruct);
        static::assertNotNull($invoiceStruct1);
        $invoice = $this->referenceInvoiceLoader->load($orderId);

        static::assertNotEmpty($invoice['id']);
        static::assertContains($invoice['id'][$invoiceStruct->getId()$invoiceStruct1->getId()]);
    }

    public function testLoadWithReferenceDocumentId(): void
    {
        


    public function testCorrectOrderVersionOverAssociationOverRepositorySearch(): void
    {
        // 1. Create a new order and extract order number         $cart = $this->generateDemoCart(2);
        $orderId = $this->persistCart($cart);
        /** @var OrderEntity $order */
        $order = $this->orderRepository->search(new Criteria([$orderId])$this->context)->first();

        // 2. Generate a document attached to the order         $this->createDocument('invoice', $orderId[]$this->context);

        // 3. Set created order version to be lexicographically smaller than the live version         $this->connection->executeStatement(
            'UPDATE `order` SET `version_id` = :newVersionId WHERE `version_id` != :liveVersionId AND `id` = :orderId',
            [
                'newVersionId' => hex2bin('00000000000000000000000000000000'),
                'liveVersionId' => hex2bin(Defaults::LIVE_VERSION),
                'orderId' => hex2bin($orderId),
            ],
        );
Home | Imprint | This part of the site doesn't use cookies.