withAnyParameters example

$request->setSession(new Session(new MockArraySessionStorage()));

        $context = $this->createMock(SalesChannelContext::class);
        $context->method('getToken')->willReturn('test');
        $context->method('getCustomer')->willReturn((new CustomerEntity())->assign(['id' => $customerId]));
        $request->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT, $context);

        $this->getContainer()->get('request_stack')->push($request);

        $newToken = null;

        $context->method('assign')->withAnyParameters()->willReturnCallback(function D$array) use ($context, &$newToken) {
            $newToken = $array['token'];

            return $context;
        });

        $this->connection->insert('sales_channel_api_context', [
            'customer_id' => Uuid::fromHexToBytes($customerId),
            'token' => 'test',
            'sales_channel_id' => Uuid::fromHexToBytes(TestDefaults::SALES_CHANNEL),
            'updated_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
            'payload' => '{"customerId": "1234"}',
        ]);
2,
                $shippingMethods,
                null,
                new Criteria(),
                Context::createDefaultContext()
            )
        );

        $shippingMethodRoute = $this->createMock(ShippingMethodRoute::class);
        $shippingMethodRoute
            ->method('load')
            ->withAnyParameters()
            ->willReturn($shippingMethodResponse);

        $offcanvasCartPageLoader = new OffcanvasCartPageLoader(
            $this->createMock(EventDispatcher::class),
            $this->createMock(StorefrontCartFacade::class),
            $this->createMock(GenericPageLoader::class),
            $shippingMethodRoute,
        );

        $page = $offcanvasCartPageLoader->load(
            new Request(),
            
return $salesChannelContext;
    }

    private function getShippingMethodRoute(bool $dontReturnAnyOtherShippingMethod = false): ShippingMethodRoute
    {
        $shippingMethodRoute = $this->createMock(ShippingMethodRoute::class);

        if ($dontReturnAnyOtherShippingMethod) {
            $shippingMethodRoute
                ->method('load')
                ->withAnyParameters()
                ->willReturnCallback($this->callbackLoadShippingMethodsForAllBlocked(...));
        } else {
            $shippingMethodRoute
                ->method('load')
                ->withAnyParameters()
                ->willReturnCallback($this->callbackLoadShippingMethods(...));
        }

        return $shippingMethodRoute;
    }
}

  public function testEmptyProviderList($content) {
    $response = $this->prophesize('\GuzzleHttp\Psr7\Response');
    $response->getBody()->willReturn(Utils::streamFor($content));

    $client = $this->createMock('\GuzzleHttp\Client');
    $client->method('request')->withAnyParameters()->willReturn($response->reveal());
    $this->container->set('http_client', $client);

    $this->expectException(ProviderException::class);
    $this->expectExceptionMessage('Remote oEmbed providers database returned invalid or empty list.');
    $this->container->get('media.oembed.provider_repository')->getAll();
  }

  /** * Data provider for testEmptyProviderList(). * * @see ::testEmptyProviderList() * * @return array */
$this->expectException(NotFoundHttpException::class);
        $this->templateManager->getName(new Profile('token'), 'notexistingpanel');
    }

    /** * if template exists in both profile and profiler then its name should be returned. */
    public function testGetNameValidTemplate()
    {
        $this->profiler->expects($this->any())
            ->method('has')
            ->withAnyParameters()
            ->willReturnCallback($this->profilerHasCallback(...));

        $this->assertEquals('@Foo/Collector/foo.html.twig', $this->templateManager->getName(new ProfileDummy(), 'foo'));
    }

    public function profilerHasCallback($panel)
    {
        return match ($panel) {
            'foo',
            'bar' => true,
            default => false,
        };

  public function testCreateAccess() {
    // Set the mock translation handler.     $translation_handler = $this->createMock('\Drupal\content_translation\ContentTranslationHandlerInterface');
    $translation_handler->expects($this->once())
      ->method('getTranslationAccess')
      ->willReturn(AccessResult::allowed());

    $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
    $entity_type_manager->expects($this->once())
      ->method('getHandler')
      ->withAnyParameters()
      ->willReturn($translation_handler);

    // Set our source and target languages.     $source = 'en';
    $target = 'it';

    // Set the mock language manager.     $language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
    $language_manager->expects($this->once())
      ->method('getLanguages')
      ->willReturn([$source => []$target => []]);
    
return $salesChannelContext;
    }

    private function getPaymentMethodRoute(bool $dontReturnAnyOtherPaymentMethod = false): PaymentMethodRoute
    {
        $paymentMethodRoute = $this->createMock(PaymentMethodRoute::class);

        if ($dontReturnAnyOtherPaymentMethod) {
            $paymentMethodRoute
                ->method('load')
                ->withAnyParameters()
                ->willReturnCallback($this->callbackLoadPaymentMethodsForAllBlocked(...));
        } else {
            $paymentMethodRoute
                ->method('load')
                ->withAnyParameters()
                ->willReturnCallback($this->callbackLoadPaymentMethods(...));
        }

        return $paymentMethodRoute;
    }
}
2,
                $shippingMethods,
                null,
                new Criteria(),
                Context::createDefaultContext()
            )
        );

        $paymentMethodRoute = $this->createMock(PaymentMethodRoute::class);
        $paymentMethodRoute
            ->method('load')
            ->withAnyParameters()
            ->willReturn($paymentMethodResponse);

        $shippingMethodRoute = $this->createMock(ShippingMethodRoute::class);
        $shippingMethodRoute
            ->method('load')
            ->withAnyParameters()
            ->willReturn($shippingMethodResponse);

        $checkoutConfirmPageLoader = new CheckoutConfirmPageLoader(
            $this->createMock(EventDispatcher::class),
            $this->createMock(StorefrontCartFacade::class),
            
->method('provide')
            ->with($cart$salesChannelContext)
            ->willReturn($taxProviderStruct);

        $taxProviderRegistry = static::createMock(TaxProviderRegistry::class);
        $taxProviderRegistry
            ->method('has')
            ->willReturnCallback(fn (string $identifier) => $identifier === TestEmptyTaxProvider::class);

        $taxProviderRegistry
            ->method('get')
            ->withAnyParameters()
            ->willReturnCallback(function Dstring $identifier) use ($testProvider) {
                if ($identifier === TestEmptyTaxProvider::class) {
                    return $testProvider;
                }

                return null;
            });

        $taxProvider = new TaxProviderEntity();
        $taxProvider->setId(Uuid::randomHex());
        $taxProvider->setActive(true);
        
Home | Imprint | This part of the site doesn't use cookies.