createSalesChannelContextWithLoggedInCustomerAndWithNavigation example

/** * @internal */
class PaymentMethodPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testItlLoadsTheRequestedCustomersData(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        /** @var AccountPaymentMethodPageLoadedEvent $event */
        $event = null;
        $this->catchEvent(AccountPaymentMethodPageLoadedEvent::class$event);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(AccountPaymentMethodPage::class$page);
        static::assertSame(StorefrontPageTestConstants::PAYMENT_METHOD_COUNT, $page->getPaymentMethods()->count());
        self::assertPageEvent(AccountPaymentMethodPageLoadedEvent::class$event$context$request$page);
    }

    
/** * @internal */
class LoginPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testItLoadsWithACustomer(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        /** @var AccountLoginPageLoadedEvent $event */
        $event = null;
        $this->catchEvent(AccountLoginPageLoadedEvent::class$event);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(AccountLoginPage::class$page);
        static::assertSame(StorefrontPageTestConstants::COUNTRY_COUNT, $page->getCountries()->count());
        static::assertInstanceOf(CountryStateCollection::class$page->getCountries()->first()->getStates());
        self::assertPageEvent(AccountLoginPageLoadedEvent::class$event$context$request$page);
    }
/** * @internal */
class FinishPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testItRequiresAOrderId(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        $this->expectParamMissingException('orderId');
        $this->getPageLoader()->load($request$context);
    }

    public function testMissingOrderThrows(): void
    {
        $request = new Request([][]['orderId' => 'foo']);
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        $this->expectException(OrderException::class);

        

class OverviewPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;
    private const LAST_TRANSACTION_ID = '00000000000000000000000000000000';

    public function testItLoadsTheOverview(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);
        $this->getContainer()->get('order_transaction.repository')->create([
            [
                // this id would result in being the first transaction with wrong sorting                 'id' => self::LAST_TRANSACTION_ID,
                'orderId' => $orderId,
                'amount' => new CalculatedPrice(10.0, 10.0, new CalculatedTaxCollection()new TaxRuleCollection()),
                'paymentMethodId' => $this->getValidPaymentMethodId(),
                'stateId' => $this->getStateMachineState(OrderTransactionStates::STATE_MACHINE, OrderTransactionStates::STATE_OPEN),
            ],
        ]$context->getContext());

        
/** * @internal */
class OrderPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testItLoadsOrders(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        /** @var AccountOrderPageLoadedEvent $event */
        $event = null;
        $this->catchEvent(AccountOrderPageLoadedEvent::class$event);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(AccountOrderPage::class$page);
        static::assertSame(0, $page->getOrders()->count());
        self::assertPageEvent(AccountOrderPageLoadedEvent::class$event$context$request$page);
    }

    
$matrix = $page->getReviews()->getMatrix();

        static::assertEquals(3.333, \round($matrix->getAverageRating(), 3));
        static::assertEquals(6, $matrix->getTotalReviewCount());
    }

    public function testItLoadsReviewsWithCustomer(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);

        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $product = $this->getRandomProduct($context);

        $this->createReviews($product$context);

        $request = new Request([][]['productId' => $product->getId()]);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(ReviewLoaderResult::class$page->getReviews());
        static::assertCount(7, $page->getReviews());
        static::assertInstanceOf(RatingMatrix::class$page->getReviews()->getMatrix());
        
/** * @internal */
class EditOrderPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testEditOrderPageShouldLoad(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);

        /** @var AccountEditOrderPageLoader $event */
        $event = null;
        $this->catchEvent(AccountEditOrderPageLoadedEvent::class$event);

        $request->request->set('orderId', $orderId);
        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(AccountEditOrderPage::class$page);
        self::assertPageEvent(AccountEditOrderPageLoadedEvent::class$event$context$request$page);

        
private SystemConfigService $systemConfigService;

    protected function setUp(): void
    {
        $this->systemConfigService = $this->getContainer()->get(SystemConfigService::class);
    }

    public function testInActiveWishlist(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        $this->systemConfigService->set('core.cart.wishlistEnabled', false);

        $this->expectException(CustomerException::class);

        $customer = $context->getCustomer();
        static::assertInstanceOf(CustomerEntity::class$customer);

        $this->getPageLoader()->load($request$context$customer);
    }

    
/** * @internal */
class OrderDetailPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testItLoadsOrders(): void
    {
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);

        $request = new Request();
        $request->query->set('id', $orderId);

        /** @var AccountOrderPageLoadedEvent|null $accountOrderDetailEvent */
        $accountOrderDetailEvent = null;
        $this->catchEvent(AccountOrderDetailPageLoadedEvent::class$accountOrderDetailEvent);

        /** @var OrderRouteRequestEvent|null $orderRequestEvent */
        $orderRequestEvent = null;
        

class ConfirmPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testItLoadsTheConfirmPage(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        /** @var CheckoutConfirmPageLoadedEvent $event */
        $event = null;
        $this->catchEvent(CheckoutConfirmPageLoadedEvent::class$event);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(CheckoutConfirmPage::class$page);
        static::assertSame(0.0, $page->getCart()->getPrice()->getNetPrice());
        static::assertSame($context->getToken()$page->getCart()->getToken());
        static::assertCount(StorefrontPageTestConstants::AVAILABLE_SHIPPING_METHOD_COUNT, $page->getShippingMethods());
        
/** * @internal */
class ProfilePageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testItLoadsTheProfilePage(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        /** @var AccountProfilePageLoadedEvent $event */
        $event = null;
        $this->catchEvent(AccountProfilePageLoadedEvent::class$event);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(AccountProfilePage::class$page);
        self::assertPageEvent(AccountProfilePageLoadedEvent::class$event$context$request$page);
    }

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