LineItemGroupServiceRegistry example

$this->context = $this->getMockBuilder(SalesChannelContext::class)->disableOriginalConstructor()->getMock();
        $this->context->method('getItemRounding')->willReturn(new CashRoundingConfig(2, 0.01, true));

        $this->fakeSequenceSupervisor = new FakeSequenceSupervisor();
        $this->fakeTakeAllPackager = new FakeLineItemGroupTakeAllPackager('FAKE-PACKAGER', $this->fakeSequenceSupervisor);
        $this->fakeSorter = new FakeLineItemGroupSorter('FAKE-SORTER', $this->fakeSequenceSupervisor);
        $this->fakeTakeAllRuleMatcher = new FakeTakeAllRuleMatcher($this->fakeSequenceSupervisor);

        $quantityPriceCalculator = $this->createQuantityPriceCalculator();

        $this->integrationTestBuilder = new LineItemGroupBuilder(
            new LineItemGroupServiceRegistry(
                [
                    $this->fakeTakeAllPackager,
                ],
                [
                    $this->fakeSorter,
                ]
            ),
            $this->fakeTakeAllRuleMatcher,
            new LineItemQuantitySplitter($quantityPriceCalculator),
            new ProductLineItemProvider()
        );

        

    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
        );
    }

    public function testSetGroupPackager(): void
    {
        

    public function testPackagersAreRegistered(): void
    {
        $packagers = [
            new LineItemGroupCountPackager(),
            new LineItemGroupUnitPriceNetPackager(),
        ];
        $sorters = [];

        $registry = new LineItemGroupServiceRegistry($packagers$sorters);

        $generator = iterator_to_array($registry->getPackagers());
        static::assertCount(2, $generator);
    }

    /** * This test verifies that our sorters are * correctly registered in our registry. */
    public function testSortersAreRegistered(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.