LineItemGroupPriceDescSorter example

#[Package('checkout')] class LineItemGroupPriceDescSorterTest extends TestCase
{
    use LineItemTestFixtureBehaviour;

    private LineItemGroupSorterInterface $sorter;

    protected function setUp(): void
    {
        parent::setUp();

        $this->sorter = new LineItemGroupPriceDescSorter();
    }

    /** * This test verifies that our key identifier is not touched without recognizing it. * Please keep in mind, if you change the identifier, there might still * be old keys in the SetGroup entities in the database of shops, that * try to execute a sorter that does not exist anymore with this key. * * @group lineitemgroup */
    public function testKey(): void
    {

    public function testGetSorterByKey(): void
    {
        $sorter = new LineItemGroupPriceAscSorter();

        $packagers = [];
        $sorters = [
            $sorter,
            new LineItemGroupPriceDescSorter(),
        ];

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

        static::assertSame($sorter$registry->getSorter($sorter->getKey()));
    }
}


        $this->unitTestBuilder = new LineItemGroupBuilder(
            new LineItemGroupServiceRegistry(
                [
                    new LineItemGroupCountPackager(),
                    new LineItemGroupUnitPriceGrossPackager(),
                    new LineItemGroupUnitPriceNetPackager(),
                ],
                [
                    new LineItemGroupPriceAscSorter(),
                    new LineItemGroupPriceDescSorter(),
                ]
            ),
            new AnyRuleMatcher(new AnyRuleLineItemMatcher()),
            new LineItemQuantitySplitter($quantityPriceCalculator),
            new ProductLineItemProvider()
        );
    }

    /** * This test verifies that our extractor starts * with the sorting, then proceeds with rule matching and packagers. * This helps us to avoid any dependencies to rules inside sorters or packagers * * @group lineitemgroup */
Home | Imprint | This part of the site doesn't use cookies.