method example


        static::expectException(DecorationPatternException::class);
        $this->searchIndexer->getDecorated();
    }

    public function testGlobalData(): void
    {
        $context = Context::createDefaultContext();
        $repository = $this->createMock(EntityRepository::class);
        $media = new MediaEntity();
        $media->setUniqueIdentifier(Uuid::randomHex());
        $repository->method('search')->willReturn(
            new EntitySearchResult(
                'media',
                1,
                new EntityCollection([$media]),
                null,
                new Criteria(),
                $context
            )
        );

        $indexer = new MediaAdminSearchIndexer(
            
$this->eventDispatcher = new CollectingEventDispatcher();
        $this->kernelPluginCollectionMock = $this->createMock(KernelPluginCollection::class);
        $this->containerMock = $this->createMock(Container::class);
        $this->migrationLoaderMock = $this->createMock(MigrationCollectionLoader::class);
        $this->requirementsValidatorMock = $this->createMock(RequirementsValidator::class);
        $this->cacheItemPoolInterfaceMock = $this->createMock(CacheItemPoolInterface::class);
        $this->pluginServiceMock = $this->createMock(PluginService::class);
        $this->commandExecutor = $this->createMock(CommandExecutor::class);

        $this->pluginMock = $this->createMock(Plugin::class);

        $this->pluginMock->method('getNamespace')->willReturn('MockPlugin');
        $this->pluginMock->method('getMigrationNamespace')->willReturn('migration');

        $this->pluginLifecycleService = new PluginLifecycleService(
            $this->pluginRepoMock,
            $this->eventDispatcher,
            $this->kernelPluginCollectionMock,
            $this->containerMock,
            $this->migrationLoaderMock,
            $this->createMock(AssetService::class),
            $this->commandExecutor,
            $this->requirementsValidatorMock,
            

  }

  /** * @covers ::setRouteParameterConverters * * @dataProvider providerTestSetRouteParameterConverters */
  public function testSetRouteParameterConverters($path$parameters = NULL, $expected = NULL) {
    $converter = $this->createMock('Drupal\Core\ParamConverter\ParamConverterInterface');
    $converter->expects($this->any())
      ->method('applies')
      ->with($this->anything(), 'id', $this->anything())
      ->willReturn(TRUE);
    $this->manager->addConverter($converter, 'applied');

    $route = new Route($path);
    if ($parameters) {
      $route->setOption('parameters', $parameters);
    }
    $collection = new RouteCollection();
    $collection->add('test_route', $route);

    


    public function testSetsParametersOnTheQueueAndExchange()
    {
        $factory = new TestAmqpFactory(
            $amqpConnection = $this->createMock(\AMQPConnection::class),
            $amqpChannel = $this->createMock(\AMQPChannel::class),
            $amqpQueue = $this->createMock(\AMQPQueue::class),
            $amqpExchange = $this->createMock(\AMQPExchange::class)
        );

        $amqpQueue->expects($this->once())->method('setArguments')->with([
            'x-dead-letter-exchange' => 'dead-exchange',
            'x-delay' => 100,
            'x-expires' => 150,
            'x-max-length' => 200,
            'x-max-length-bytes' => 300,
            'x-max-priority' => 4,
            'x-message-ttl' => 100,
        ]);

        $amqpExchange->expects($this->once())->method('setArguments')->with([
            'alternate-exchange' => 'alternate',
        ]);


        $stats = $collector->getStatistics();
        $this->assertGreaterThan(0, $stats[self::INSTANCE_NAME]['time']);
        $this->assertEquals($stats[self::INSTANCE_NAME]['hits'], 0, 'hits');
        $this->assertEquals($stats[self::INSTANCE_NAME]['misses'], 1, 'misses');
    }

    private function getCacheDataCollectorStatisticsFromEvents(array $traceableAdapterEvents)
    {
        $traceableAdapterMock = $this->createMock(TraceableAdapter::class);
        $traceableAdapterMock->method('getCalls')->willReturn($traceableAdapterEvents);

        $cacheDataCollector = new CacheDataCollector();
        $cacheDataCollector->addInstance(self::INSTANCE_NAME, $traceableAdapterMock);
        $cacheDataCollector->collect(new Request()new Response());

        return $cacheDataCollector->getStatistics();
    }
}
static::assertEquals([
            FlowEvents::FLOW_WRITTEN_EVENT => 'invalidate',
        ], CachedFlowLoader::getSubscribedEvents());
    }

    public function testClearFlowCache(): void
    {
        /** @var EventDispatcher $dispatcher */
        $dispatcher = $this->getContainer()->get('event_dispatcher');

        $listener = $this->getMockBuilder(CallableClass::class)->getMock();
        $listener->expects(static::once())->method('__invoke');
        $dispatcher->addListener(FlowEvents::FLOW_WRITTEN_EVENT, $listener);

        $flowLoader = $this->getContainer()->get(CachedFlowLoader::class);
        $class = new \ReflectionClass($flowLoader);
        $property = $class->getProperty('flows');
        $property->setAccessible(true);
        $property->setValue(
            $flowLoader,
            ['abc']
        );

        


        $this->service->sync($operations, Context::createDefaultContext()new SyncBehavior());

        $dispatcher = $this->getContainer()->get('event_dispatcher');

        $createListener = $this
            ->getMockBuilder(CallableClass::class)
            ->getMock();

        $createListener->expects(static::once())
            ->method('__invoke');

        $deleteListener = $this
            ->getMockBuilder(CallableClass::class)
            ->getMock();

        $deleteListener->expects(static::exactly(3))
            ->method('__invoke');

        $this->addEventListener($dispatcher, EntityWrittenContainerEvent::class$createListener);
        $this->addEventListener($dispatcher, 'tax.deleted', $deleteListener);
        $this->addEventListener($dispatcher, 'country.deleted', $deleteListener);
        

        $rule = (new CustomerGroupRule())->assign(['customerGroupIds' => ['SWAG-CUSTOMER-GROUP-ID-1']]);

        $cart = new Cart('test');

        $group = new CustomerGroupEntity();
        $group->setId('SWAG-CUSTOMER-GROUP-ID-1');

        $context = $this->createMock(SalesChannelContext::class);

        $context
            ->method('getCurrentCustomerGroup')
            ->willReturn($group);

        static::assertTrue(
            $rule->match(new CartRuleScope($cart$context))
        );
    }

    public function testMultipleGroups(): void
    {
        $rule = (new CustomerGroupRule())->assign(['customerGroupIds' => ['SWAG-CUSTOMER-GROUP-ID-2', 'SWAG-CUSTOMER-GROUP-ID-3', 'SWAG-CUSTOMER-GROUP-ID-1']]);

        
new PercentagePriceCalculator(new CashRounding()$quantityCalculatornew PercentageTaxRuleBuilder()),
        );

        $entity->assign(['calculatedPrice' => new CalculatedPrice(10, 10, new CalculatedTaxCollection()new TaxRuleCollection())]);

        $original = new CalculatedCheapestPrice(10, 10, new CalculatedTaxCollection()new TaxRuleCollection(new TaxRuleCollection([new TaxRule(10)])));

        // mock context to simulate currency and tax states         $context = $this->createMock(SalesChannelContext::class);

        // currency key will be provided, we want to test different currencies are taking into account         $context->expects(static::any())->method('getCurrencyId')->willReturn($ids->get($currencyKey));

        // we also want to test different tax states (gross/net)         $context->expects(static::any())->method('getTaxState')->willReturn($taxState);
        $context->expects(static::any())->method('getItemRounding')->willReturn(new CashRoundingConfig(2, 0.01, true));

        return new CheapestPriceFacade($entity$original$stubs$context);
    }
}
PageNotFoundException::ERROR_CODE,
        ];
    }

    /** * @param list<string> $cmsPageIds */
    private function getBeforeDeleteEvent(array $cmsPageIds = []): EntityDeleteEvent
    {
        $event = $this->createMock(EntityDeleteEvent::class);
        $event
            ->method('getIds')
            ->with(CmsPageDefinition::ENTITY_NAME)
            ->willReturn($cmsPageIds);

        return $event;
    }

    private static function getBeforeSystemConfigChangedEvent(string $key, mixed $value): BeforeSystemConfigChangedEvent
    {
        return new BeforeSystemConfigChangedEvent($key$value, null);
    }

    

class CrossSellingTypeDataResolverTest extends TestCase
{
    use IntegrationTestBehaviour;

    private CrossSellingCmsElementResolver $crossSellingResolver;

    protected function setUp(): void
    {
        $mock = $this->createMock(AbstractProductCrossSellingRoute::class);
        $mock->method('load')->willReturn(
            new ProductCrossSellingRouteResponse(
                new CrossSellingElementCollection()
            )
        );

        $this->crossSellingResolver = new CrossSellingCmsElementResolver($mock);
    }

    public function testType(): void
    {
        static::assertSame('cross-selling', $this->crossSellingResolver->getType());
    }

class AdminConfigurationServiceTest extends TestCase
{
    public function testCreateAdmin(): void
    {
        $localeId = Uuid::randomBytes();
        $connection = $this->createMock(Connection::class);
        $connection->expects(static::once())
            ->method('insert')
            ->with(
                'user',
                static::callback(static function Darray $data) use ($localeId): bool {
                    static::assertEquals('admin', $data['username']);
                    static::assertEquals('first', $data['first_name']);
                    static::assertEquals('last', $data['last_name']);
                    static::assertEquals('test@test.com', $data['email']);
                    static::assertEquals($localeId$data['locale_id']);
                    static::assertTrue($data['admin']);
                    static::assertTrue($data['active']);

                    

        $transport = $this->createTransport();
        $transport->setHost($customHost = self::CUSTOM_HOST);
        $transport->setPort($customPort = self::CUSTOM_PORT);
        $this->assertSame(sprintf('ntfy://%s:%s/test', $customHost$customPort)(string) $transport);
    }

    public function testSend()
    {
        $response = $this->createMock(ResponseInterface::class);
        $response->expects($this->exactly(2))
            ->method('getStatusCode')
            ->willReturn(200);
        $response->expects($this->once())
            ->method('getContent')
            ->willReturn(json_encode(['id' => '2BYIwRmvBKcv', 'event' => 'message']));

        $client = new MockHttpClient(function Dstring $method, string $url, array $options = []) use ($response): ResponseInterface {
            $expectedBody = json_encode(['topic' => 'test', 'title' => 'Hello', 'message' => 'World']);
            $this->assertJsonStringEqualsJsonString($expectedBody$options['body']);

            return $response;
        });

        
$this->insertDefaultPropertyGroup();

        $groupRepository = $this->getContainer()->get('property_group.repository');
        $event = $groupRepository->update([
            [
                'id' => $this->ids->get('group1'),
                'sortingType' => PropertyGroupDefinition::SORTING_TYPE_POSITION,
            ],
        ], Context::createDefaultContext());

        $this->cacheInvalidatorMock->expects(static::once())
            ->method('invalidate')
            ->with(static::countOf(1));

        $this->cacheInvalidationSubscriber->invalidatePropertyFilters($event);
    }

    public function testItInvalidatesCacheIfPropertyGroupTranslationIsChanged(): void
    {
        $this->insertDefaultPropertyGroup();

        $groupRepository = $this->getContainer()->get('property_group.repository');
        $event = $groupRepository->update([
            [

#[Package('buyers-experience')] class PromotionActionControllerTest extends TestCase
{
    private PromotionActionController $promotionActionController;

    protected function setUp(): void
    {
        $packager = $this->createMock(LineItemGroupCountPackager::class);
        $packager->method('getKey')->willReturn('test-packager');

        $sorter = $this->createMock(LineItemGroupPriceAscSorter::class);
        $sorter->method('getKey')->willReturn('test-sorter');

        $serviceRegistry = new LineItemGroupServiceRegistry(
            [$packager],
            [$sorter],
        );

        $this->promotionActionController = new PromotionActionController(
            $serviceRegistry
        );
Home | Imprint | This part of the site doesn't use cookies.