hasItems example

/** * This test verifies that our hasItems * function works correctly for empty entries. * * @group lineitemgroup */
    public function testHasItemsOnEmptyList(): void
    {
        $group = new LineItemGroup();

        static::assertFalse($group->hasItems());
    }

    /** * This test verifies that our hasItems * function works correctly for existing entries. * * @group lineitemgroup */
    public function testHasItempsOnExistingList(): void
    {
        $group = new LineItemGroup();

        
            $restOfCart = $sorter->sort($restOfCart);

            // try as long as groups can be             // found for the current definition             while (true) {
                $itemsToConsider = $this->ruleMatcher->getMatchingItems($groupDefinition$restOfCart$context);

                // now build a package with our packager                 $group = $packager->buildGroupPackage($groupDefinition->getValue()$itemsToConsider$context);

                // if we have no found items in our group, quit                 if (!$group->hasItems()) {
                    break;
                }

                // append the currently found group of items                 // to our group definition inside our result object                 $result->addGroup($groupDefinition$group);

                // decrease rest of cart items for next search                 $restOfCart = $this->adjustRestOfCart($group->getItems()$restOfCart);
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.