| 
 | 1 | +<?php  | 
 | 2 | + | 
 | 3 | +declare(strict_types=1);  | 
 | 4 | +/**  | 
 | 5 | + * Shopware 5  | 
 | 6 | + * Copyright (c) shopware AG  | 
 | 7 | + *  | 
 | 8 | + * According to our dual licensing model, this program can be used either  | 
 | 9 | + * under the terms of the GNU Affero General Public License, version 3,  | 
 | 10 | + * or under a proprietary license.  | 
 | 11 | + *  | 
 | 12 | + * The texts of the GNU Affero General Public License with an additional  | 
 | 13 | + * permission and of our proprietary license can be found at and  | 
 | 14 | + * in the LICENSE file you have received along with this program.  | 
 | 15 | + *  | 
 | 16 | + * This program is distributed in the hope that it will be useful,  | 
 | 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
 | 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  | 
 | 19 | + * GNU Affero General Public License for more details.  | 
 | 20 | + *  | 
 | 21 | + * "Shopware" is a registered trademark of shopware AG.  | 
 | 22 | + * The licensing of the program under the AGPLv3 does not imply a  | 
 | 23 | + * trademark license. Therefore any rights, title and interest in  | 
 | 24 | + * our trademarks remain entirely with us.  | 
 | 25 | + */  | 
 | 26 | + | 
 | 27 | +namespace Shopware\Tests\Functional\Components\Cart;  | 
 | 28 | + | 
 | 29 | +use Doctrine\DBAL\Connection;  | 
 | 30 | +use Shopware\Tests\Functional\Components\CheckoutTest;  | 
 | 31 | +use Shopware\Tests\Functional\Traits\ContainerTrait;  | 
 | 32 | +use Shopware\Tests\Functional\Traits\DatabaseTransactionBehaviour;  | 
 | 33 | + | 
 | 34 | +class CartDatabaseViewTest extends CheckoutTest  | 
 | 35 | +{  | 
 | 36 | +    use ContainerTrait;  | 
 | 37 | +    use DatabaseTransactionBehaviour;  | 
 | 38 | + | 
 | 39 | +    public bool $clearBasketOnReset = false;  | 
 | 40 | + | 
 | 41 | +    public function testEnsureCartInViewHasSameIDsAsTheDatabase(): void  | 
 | 42 | +    {  | 
 | 43 | +        $productNumber = $this->createProduct(5, 19.00);  | 
 | 44 | + | 
 | 45 | +        $this->loginFrontendCustomer();  | 
 | 46 | + | 
 | 47 | +        $this->addProduct($productNumber);  | 
 | 48 | +        $this->visitConfirm();  | 
 | 49 | + | 
 | 50 | +        $cartItems = $this->View()->getAssign('sBasket')['content'];  | 
 | 51 | +        $cartPositionIds = array_map('\intval', array_column($cartItems, 'id'));  | 
 | 52 | + | 
 | 53 | +        $connection = $this->getContainer()->get(Connection::class);  | 
 | 54 | +        $preparedStatement = $connection->prepare('SELECT id FROM s_order_basket WHERE id = :id');  | 
 | 55 | +        foreach ($cartPositionIds as $cartPositionId) {  | 
 | 56 | +            $preparedStatement->bindValue('id', $cartPositionId);  | 
 | 57 | +            $cartPositionDatabaseId = (int) $preparedStatement->executeQuery()->fetchOne();  | 
 | 58 | +            static::assertSame($cartPositionId, $cartPositionDatabaseId, 'Cart position in view is not the same as in the database.');  | 
 | 59 | +        }  | 
 | 60 | +    }  | 
 | 61 | +}  | 
0 commit comments