getGroupTotalResult example


    public function testGroupTotalResultUsesKeys(): void
    {
        $groupDefinition = new LineItemGroupDefinition('ID1', 'COUNT', 2, 'PRICE_ASC', new RuleCollection());

        $group = new LineItemGroup();
        $group->addItem('ID1', 2);

        $result = new LineItemGroupBuilderResult();
        $result->addGroup($groupDefinition$group);

        static::assertArrayHasKey('ID1', $result->getGroupTotalResult($groupDefinition));
    }

    /** * This test verifies that we can add * a single line item for a definition and retrieve * all the aggregated data with our total result function * * @group lineitemgroup */
    public function testGroupTotalContainsItem(): void
    {
        

    public function testCanOnlyFind1Group(): void
    {
        $cart = $this->buildCart(3);

        $groupDefinition = $this->buildGroup(self::KEY_PACKAGER_COUNT, 2, self::KEY_SORTER_PRICE_ASC, new RuleCollection());

        $result = $this->unitTestBuilder->findGroupPackages([$groupDefinition]$cart$this->context);

        /** @var LineItemQuantity[] $items */
        $items = array_values($result->getGroupTotalResult($groupDefinition));

        static::assertCount(2, $items);
    }

    /** * This test verifies that we build as many group results as possible. * We make groups for every 2 items. Our cart has 7 items, so we * have a total of 6 (3 x 2) resulting items. * * @group lineitemgroup */
    
Home | Imprint | This part of the site doesn't use cookies.