diff --git a/.phpstan-baseline.neon b/.phpstan-baseline.neon index 727f06967c8..ac8229bc449 100644 --- a/.phpstan-baseline.neon +++ b/.phpstan-baseline.neon @@ -11855,36 +11855,6 @@ parameters: count: 1 path: engine/Shopware/Commands/DatabaseSetupCommand.php - - - message: "#^Method Shopware\\\\Commands\\\\FirstRunWizardDisableCommand\\:\\:configure\\(\\) has no return type specified\\.$#" - count: 1 - path: engine/Shopware/Commands/FirstRunWizardDisableCommand.php - - - - message: "#^Query error\\: Column \"s_core_config_values\\.element_id\" expects value type int, got type mixed$#" - count: 2 - path: engine/Shopware/Commands/FirstRunWizardDisableCommand.php - - - - message: "#^Query error\\: Column \"s_core_config_values\\.id\" expects value type int, got type mixed~0\\|0\\.0\\|''\\|'0'\\|array\\{\\}\\|false\\|null$#" - count: 1 - path: engine/Shopware/Commands/FirstRunWizardDisableCommand.php - - - - message: "#^Method Shopware\\\\Commands\\\\FirstRunWizardEnableCommand\\:\\:configure\\(\\) has no return type specified\\.$#" - count: 1 - path: engine/Shopware/Commands/FirstRunWizardEnableCommand.php - - - - message: "#^Query error\\: Column \"s_core_config_values\\.element_id\" expects value type int, got type mixed$#" - count: 2 - path: engine/Shopware/Commands/FirstRunWizardEnableCommand.php - - - - message: "#^Query error\\: Column \"s_core_config_values\\.id\" expects value type int, got type mixed~0\\|0\\.0\\|''\\|'0'\\|array\\{\\}\\|false\\|null$#" - count: 1 - path: engine/Shopware/Commands/FirstRunWizardEnableCommand.php - - message: "#^Method Shopware\\\\Commands\\\\GenerateAttributesCommand\\:\\:configure\\(\\) has no return type specified\\.$#" count: 1 @@ -14125,11 +14095,6 @@ parameters: count: 1 path: engine/Shopware/Components/Cart/CartPersistService.php - - - message: "#^Query error\\: Column \"s_order_basket\\.currencyFactor\" expects value type float\\|int, got type mixed~0\\|0\\.0\\|''\\|'0'\\|array\\{\\}\\|false\\|null$#" - count: 1 - path: engine/Shopware/Components/Cart/ConditionalLineItemService.php - - message: "#^Query error\\: Column \"s_order_basket\\.sessionID\" expects value type string\\|null, got type mixed$#" count: 1 @@ -17955,51 +17920,16 @@ parameters: count: 1 path: engine/Shopware/Components/Plugin/Configuration/ReaderInterface.php - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\CronjobSynchronizer\\:\\:addCronjob\\(\\) has no return type specified\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\CronjobSynchronizer\\:\\:addCronjob\\(\\) has parameter \\$cronjob with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\CronjobSynchronizer\\:\\:removeNotExistingEntries\\(\\) has no return type specified\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\CronjobSynchronizer\\:\\:removeNotExistingEntries\\(\\) has parameter \\$cronjobActions with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\CronjobSynchronizer\\:\\:synchronize\\(\\) has no return type specified\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\CronjobSynchronizer\\:\\:synchronize\\(\\) has parameter \\$cronjobs with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - - - message: "#^Query error\\: Argument \\#1 is not a constant array, got array\\&hasOffsetValue\\('pluginID', int\\)$#" - count: 1 - path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - message: "#^Query error\\: Argument \\#1 is not a constant array, got hasOffsetValue\\('end', DateTime\\)&hasOffsetValue\\('next', DateTime\\)&hasOffsetValue\\('pluginID', int\\)&non\\-empty\\-array$#" + message: "#^Query error\\: Argument \\#1 is not a constant array, got array\\&hasOffsetValue\\('pluginID', int\\)$#" count: 1 path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - message: "#^Query error\\: Column \"s_crontab\\.id\" expects value type int, got type mixed~0\\|0\\.0\\|''\\|'0'\\|array\\{\\}\\|false\\|null$#" + message: "#^Query error\\: Argument \\#1 is not a constant array, got non-empty-array\\&hasOffsetValue\\('end', DateTime\\)&hasOffsetValue\\('next', DateTime\\)&hasOffsetValue\\('pluginID', int\\)$#" count: 1 path: engine/Shopware/Components/Plugin/CronjobSynchronizer.php - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\DBALConfigReader\\:\\:getByPluginName\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -23875,56 +23805,6 @@ parameters: count: 1 path: engine/Shopware/Controllers/Frontend/Compare.php - - - message: "#^Method Shopware_Controllers_Frontend_Forms\\:\\:_createInputElement\\(\\) has parameter \\$element with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Method Shopware_Controllers_Frontend_Forms\\:\\:_createLabelElement\\(\\) has parameter \\$element with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Method Shopware_Controllers_Frontend_Forms\\:\\:_validateInput\\(\\) has parameter \\$elements with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Method Shopware_Controllers_Frontend_Forms\\:\\:_validateInput\\(\\) has parameter \\$inputs with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Method Shopware_Controllers_Frontend_Forms\\:\\:_validateInput\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Method Shopware_Controllers_Frontend_Forms\\:\\:getContent\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Method Shopware_Controllers_Frontend_Forms\\:\\:translateForm\\(\\) has parameter \\$fields with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Property Shopware_Controllers_Frontend_Forms\\:\\:\\$_elements type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Property Shopware_Controllers_Frontend_Forms\\:\\:\\$_errors type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - - - message: "#^Property Shopware_Controllers_Frontend_Forms\\:\\:\\$_postData type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Controllers/Frontend/Forms.php - - message: "#^Method Shopware_Controllers_Frontend_Index\\:\\:indexAction\\(\\) has no return type specified\\.$#" count: 1 diff --git a/composer.json b/composer.json index 96be9f8b5b1..20f2b94529a 100644 --- a/composer.json +++ b/composer.json @@ -112,7 +112,7 @@ "friends-of-behat/mink-extension": "2.7.5", "php-parallel-lint/php-var-dump-check": "^0.5", "phpstan/extension-installer": "1.4.2", - "phpstan/phpstan": "1.12.0", + "phpstan/phpstan": "1.12.5", "phpstan/phpstan-doctrine": "1.5.3", "phpstan/phpstan-phpunit": "1.4.0", "phpstan/phpstan-symfony": "1.4.9", diff --git a/composer.lock b/composer.lock index b883254fa02..7de76e20f2f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "593ef8ea27d418aa2832a1335f87e898", + "content-hash": "e223844098537bc2902bda9882b36106", "packages": [ { "name": "aws/aws-crt-php", @@ -8681,16 +8681,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.0", + "version": "1.12.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "384af967d35b2162f69526c7276acadce534d0e1" + "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/384af967d35b2162f69526c7276acadce534d0e1", - "reference": "384af967d35b2162f69526c7276acadce534d0e1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17", + "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17", "shasum": "" }, "require": { @@ -8735,7 +8735,7 @@ "type": "github" } ], - "time": "2024-08-27T09:18:05+00:00" + "time": "2024-09-26T12:45:22+00:00" }, { "name": "phpstan/phpstan-doctrine", diff --git a/engine/Shopware/Bundle/MailBundle/AutocompleteResolver/ShortForeachResolver.php b/engine/Shopware/Bundle/MailBundle/AutocompleteResolver/ShortForeachResolver.php index 0c909bf1621..87d855b44c8 100644 --- a/engine/Shopware/Bundle/MailBundle/AutocompleteResolver/ShortForeachResolver.php +++ b/engine/Shopware/Bundle/MailBundle/AutocompleteResolver/ShortForeachResolver.php @@ -33,12 +33,7 @@ public function completer(array $context, string $smartyCode): array if (!empty($matches)) { foreach ($matches as $match) { - if (!isset($match['arrayName'], $match['value'])) { - continue; - } - $value = $this->getValueFromPath($context, $match['arrayName']); - if ($value === null) { continue; } @@ -46,14 +41,10 @@ public function completer(array $context, string $smartyCode): array if (\count($value)) { $key = array_keys($value)[0]; $context[$match['value']] = $value[$key]; - if (isset($match['key'])) { - $context[$match['key']] = $key; - } + $context[$match['key']] = $key; } else { $context[$match['value']] = []; - if (isset($match['key'])) { - $context[$match['key']] = 0; - } + $context[$match['key']] = 0; } } } diff --git a/engine/Shopware/Commands/FirstRunWizardDisableCommand.php b/engine/Shopware/Commands/FirstRunWizardDisableCommand.php index e2342ec711e..b4e45e505e4 100644 --- a/engine/Shopware/Commands/FirstRunWizardDisableCommand.php +++ b/engine/Shopware/Commands/FirstRunWizardDisableCommand.php @@ -23,15 +23,13 @@ namespace Shopware\Commands; +use RuntimeException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class FirstRunWizardDisableCommand extends ShopwareCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this ->setName('sw:firstrunwizard:disable') @@ -46,7 +44,13 @@ protected function execute(InputInterface $input, OutputInterface $output) { $conn = $this->container->get(\Doctrine\DBAL\Connection::class); $elementId = $conn->fetchColumn('SELECT id FROM s_core_config_elements WHERE name LIKE "firstRunWizardEnabled"'); + $elementId = is_numeric($elementId) ? (int) $elementId : 0; + if ($elementId <= 0) { + throw new RuntimeException('Cannot find config element `firstRunWizardEnabled`'); + } + $valueid = $conn->fetchColumn('SELECT id FROM s_core_config_values WHERE element_id = :elementId', ['elementId' => $elementId]); + $valueid = is_numeric($valueid) ? (int) $valueid : 0; $data = [ 'element_id' => $elementId, @@ -54,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 'value' => serialize(false), ]; - if ($valueid) { + if ($valueid > 0) { $conn->update( 's_core_config_values', $data, diff --git a/engine/Shopware/Commands/FirstRunWizardEnableCommand.php b/engine/Shopware/Commands/FirstRunWizardEnableCommand.php index 4a35ce47ebc..4ac0729d40a 100644 --- a/engine/Shopware/Commands/FirstRunWizardEnableCommand.php +++ b/engine/Shopware/Commands/FirstRunWizardEnableCommand.php @@ -23,15 +23,13 @@ namespace Shopware\Commands; +use RuntimeException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class FirstRunWizardEnableCommand extends ShopwareCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this ->setName('sw:firstrunwizard:enable') @@ -46,7 +44,13 @@ protected function execute(InputInterface $input, OutputInterface $output) { $conn = $this->container->get(\Doctrine\DBAL\Connection::class); $elementId = $conn->fetchColumn('SELECT id FROM s_core_config_elements WHERE name LIKE "firstRunWizardEnabled"'); + $elementId = is_numeric($elementId) ? (int) $elementId : 0; + if ($elementId <= 0) { + throw new RuntimeException('Cannot find config element `firstRunWizardEnabled`'); + } + $valueid = $conn->fetchColumn('SELECT id FROM s_core_config_values WHERE element_id = :elementId', ['elementId' => $elementId]); + $valueid = is_numeric($valueid) ? (int) $valueid : 0; $data = [ 'element_id' => $elementId, @@ -54,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 'value' => serialize(true), ]; - if ($valueid) { + if ($valueid > 0) { $conn->update( 's_core_config_values', $data, diff --git a/engine/Shopware/Components/AddLinkHeaderSubscriber.php b/engine/Shopware/Components/AddLinkHeaderSubscriber.php index 41d4c7c4085..857c44b2520 100644 --- a/engine/Shopware/Components/AddLinkHeaderSubscriber.php +++ b/engine/Shopware/Components/AddLinkHeaderSubscriber.php @@ -29,7 +29,6 @@ use Enlight_Event_EventArgs; use Psr\Link\LinkProviderInterface; use Symfony\Component\WebLink\HttpHeaderSerializer; -use Traversable; class AddLinkHeaderSubscriber implements SubscriberInterface { @@ -88,11 +87,7 @@ public function onDispatchLoopShutdown(Enlight_Event_EventArgs $args): void } $links = $linkProvider->getLinks(); - if (is_countable($links) && \count($links) === 0) { - return; - } - - if ($links instanceof Traversable && iterator_count($links) === 0) { + if (is_countable($links) && \count($links) === 0 || iterator_count($links) === 0) { return; } diff --git a/engine/Shopware/Components/Cart/ConditionalLineItemService.php b/engine/Shopware/Components/Cart/ConditionalLineItemService.php index 8d9212415a3..9e00926799b 100644 --- a/engine/Shopware/Components/Cart/ConditionalLineItemService.php +++ b/engine/Shopware/Components/Cart/ConditionalLineItemService.php @@ -68,7 +68,7 @@ public function __construct( public function addConditionalLineItem(string $name, string $orderNumber, float $price, float $tax, int $mode): void { - $currencyFactor = empty($this->system->sCurrency['factor']) ? 1 : $this->system->sCurrency['factor']; + $currencyFactor = empty($this->system->sCurrency['factor']) ? 1 : (float) $this->system->sCurrency['factor']; $taxFree = empty($this->system->sUSERGROUPDATA['tax']) && !empty($this->system->sUSERGROUPDATA['id']); $sessionId = $this->session->get('sessionId'); diff --git a/engine/Shopware/Components/Plugin/CronjobSynchronizer.php b/engine/Shopware/Components/Plugin/CronjobSynchronizer.php index f5fff249b95..cf35a605004 100644 --- a/engine/Shopware/Components/Plugin/CronjobSynchronizer.php +++ b/engine/Shopware/Components/Plugin/CronjobSynchronizer.php @@ -41,7 +41,11 @@ public function __construct(Connection $connection) } /** + * @param array> $cronjobs + * * @throws InvalidArgumentException + * + * @return void */ public function synchronize(Plugin $plugin, array $cronjobs) { @@ -53,9 +57,9 @@ public function synchronize(Plugin $plugin, array $cronjobs) } /** - * @param array $cronjob + * @param array $cronjob */ - private function addCronjob(Plugin $plugin, $cronjob) + private function addCronjob(Plugin $plugin, $cronjob): void { $cronjob['pluginID'] = $plugin->getId(); @@ -84,7 +88,8 @@ private function addCronjob(Plugin $plugin, $cronjob) $id = $this->connection->fetchColumn($selectStatement, $params); } - if ($id) { + $id = is_numeric($id) ? (int) $id : 0; + if ($id !== 0) { // Don't overwrite user cronjob state unset($cronjob['active']); @@ -97,9 +102,9 @@ private function addCronjob(Plugin $plugin, $cronjob) } /** - * @param int $pluginId + * @param array $cronjobActions */ - private function removeNotExistingEntries($pluginId, array $cronjobActions) + private function removeNotExistingEntries(int $pluginId, array $cronjobActions): void { $builder = $this->connection->createQueryBuilder(); $builder->delete('s_crontab'); diff --git a/engine/Shopware/Controllers/Frontend/Forms.php b/engine/Shopware/Controllers/Frontend/Forms.php index de339b9ad1f..24ca44f3ced 100644 --- a/engine/Shopware/Controllers/Frontend/Forms.php +++ b/engine/Shopware/Controllers/Frontend/Forms.php @@ -40,21 +40,21 @@ class Shopware_Controllers_Frontend_Forms extends Enlight_Controller_Action /** * Contains the validated post data * - * @var array + * @var array */ public $_postData; /** * Contains the errors * - * @var array + * @var array{v?: list, e?: array} */ public $_errors; /** * Contains the form elements * - * @var array + * @var array> */ protected $_elements; @@ -148,7 +148,7 @@ public function commitForm() * @throws Enlight_Exception * @throws Exception * - * @return array + * @return array{id: string, active: bool, name: string, text: string, text2: string, email: string, email_template: string, email_subject: string, metaTitle: ?string, metaDescription: ?string, metaKeywords: ?string, attribute: array, sErrors: array{v?: list, e?: array}, sElements: array>, sFields: array, sLabels: array} */ protected function getContent($formId) { @@ -287,7 +287,7 @@ protected function getContent($formId) /** * Create label element * - * @param array $element + * @param array $element * * @return string */ @@ -310,6 +310,7 @@ protected function _createLabelElement($element) /** * Create input element method * + * @param array $element * @param array|string|null $post * * @return string @@ -575,9 +576,12 @@ protected function _filterInput($input) * * Populates $this->_postData * + * @param array $inputs + * @param array> $elements + * * @throws Exception * - * @return array + * @return array{v?: list, e?: array} */ protected function _validateInput(array $inputs, array $elements) { @@ -636,8 +640,16 @@ protected function _validateInput(array $inputs, array $elements) $valid = false; break; } - $host = trim(substr($value, strpos($value, '@') + 1)); - if (empty($host) || !gethostbyname($host)) { + + $host = substr($value, strpos($value, '@') + 1); + if ($host === false) { + unset($value); + $valid = false; + break; + } + + $host = trim($host); + if ($host === '' || !gethostbyname($host)) { unset($value); $valid = false; } @@ -687,6 +699,8 @@ protected function _validateInput(array $inputs, array $elements) } /** + * @param array> $fields + * * @return Form */ protected function translateForm(Form $form, array &$fields) diff --git a/engine/Shopware/Plugins/Default/Backend/SwagUpdate/Controllers/Backend/SwagUpdate.php b/engine/Shopware/Plugins/Default/Backend/SwagUpdate/Controllers/Backend/SwagUpdate.php index 0b8cd0321d3..2187e74ca58 100644 --- a/engine/Shopware/Plugins/Default/Backend/SwagUpdate/Controllers/Backend/SwagUpdate.php +++ b/engine/Shopware/Plugins/Default/Backend/SwagUpdate/Controllers/Backend/SwagUpdate.php @@ -453,10 +453,12 @@ private function mapResult($result): array private function getUserLanguage(stdClass $user): string { - $locale = $user->locale; - $locale = strtolower($locale->getLocale()); + $locale = substr(strtolower($user->locale->getLocale()), 0, 2); + if ($locale === false) { + throw new Exception('Could not get user language'); + } - return substr($locale, 0, 2); + return $locale; } private function checkSecurityPlugin(): bool diff --git a/tests/Functional/Bundle/StoreFrontBundle/ListProductTest.php b/tests/Functional/Bundle/StoreFrontBundle/ListProductTest.php index 1f7930888a8..04585903012 100644 --- a/tests/Functional/Bundle/StoreFrontBundle/ListProductTest.php +++ b/tests/Functional/Bundle/StoreFrontBundle/ListProductTest.php @@ -27,7 +27,6 @@ use Shopware\Bundle\StoreFrontBundle\Service\ListProductServiceInterface; use Shopware\Bundle\StoreFrontBundle\Struct\ListProduct; -use Shopware\Bundle\StoreFrontBundle\Struct\Product\Manufacturer; use Shopware\Bundle\StoreFrontBundle\Struct\Product\Price; use Shopware\Bundle\StoreFrontBundle\Struct\Product\PriceRule; use Shopware\Bundle\StoreFrontBundle\Struct\Product\Unit; @@ -61,21 +60,13 @@ public function testProductRequirements(): void static::assertNotEmpty($product->getTax()); static::assertNotEmpty($product->getUnit()); - static::assertInstanceOf(Unit::class, $product->getUnit()); - static::assertInstanceOf(Manufacturer::class, $product->getManufacturer()); - static::assertNotEmpty($product->getPrices()); static::assertNotEmpty($product->getPriceRules()); foreach ($product->getPrices() as $price) { - static::assertInstanceOf(Price::class, $price); static::assertInstanceOf(Unit::class, $price->getUnit()); static::assertGreaterThanOrEqual(1, $price->getUnit()->getMinPurchase()); } - foreach ($product->getPriceRules() as $price) { - static::assertInstanceOf(PriceRule::class, $price); - } - static::assertInstanceOf(Price::class, $product->getCheapestPrice()); static::assertInstanceOf(PriceRule::class, $product->getCheapestPriceRule()); static::assertInstanceOf(Unit::class, $product->getCheapestPrice()->getUnit()); diff --git a/tests/Functional/Components/Privacy/CookieRemoveSubscriberTest.php b/tests/Functional/Components/Privacy/CookieRemoveSubscriberTest.php index 9615290f9a1..38ec0601421 100644 --- a/tests/Functional/Components/Privacy/CookieRemoveSubscriberTest.php +++ b/tests/Functional/Components/Privacy/CookieRemoveSubscriberTest.php @@ -43,18 +43,15 @@ class CookieRemoveSubscriberTest extends TestCase public function testPostDispatchDoesNothingRemovalInactive(): void { Shopware()->Config()->offsetSet('cookie_note_mode', 0); - $cookieRemoveSubscriber = $this->getCookieRemoveSubscriber(); $controller = $this->getController(); // May not be removed, since further code may not be executed $controller->Response()->setCookie('notRemoved', 'foo'); + $cookieRemoveSubscriber = $this->getCookieRemoveSubscriber(); $cookieRemoveSubscriber->onPostDispatch($this->getEventArgs($controller)); - // More code than allowed got executed if this fails - static::assertNotEmpty($controller->Response()->getCookies()); - Shopware()->Config()->offsetSet('cookie_note_mode', 1); Shopware()->Config()->offsetSet('show_cookie_note', 0); $cookieRemoveSubscriber = $this->getCookieRemoveSubscriber(); diff --git a/tests/Unit/Bundle/SitemapBundle/SitemapListenerTest.php b/tests/Unit/Bundle/SitemapBundle/SitemapListenerTest.php index 88c08155fc8..ff793e8de80 100644 --- a/tests/Unit/Bundle/SitemapBundle/SitemapListenerTest.php +++ b/tests/Unit/Bundle/SitemapBundle/SitemapListenerTest.php @@ -30,7 +30,6 @@ use Shopware\Bundle\MediaBundle\Adapters\LocalAdapterFactory; use Shopware\Bundle\SitemapBundle\Service\SitemapLister; use Shopware\Bundle\SitemapBundle\Service\SitemapNameGenerator; -use Shopware\Bundle\SitemapBundle\Struct\Sitemap; use Shopware\Components\DependencyInjection\Container; use Shopware\Components\Filesystem\PublicUrlGenerator; @@ -78,8 +77,6 @@ public function testListWithSitemap(): void $sitemaps = $this->listener->getSitemaps(1); static::assertNotEmpty($sitemaps); - static::assertInstanceOf(Sitemap::class, $sitemaps[0]); - // Subshop specific sitemaps static::assertEmpty($this->listener->getSitemaps(2)); static::assertNotEmpty($this->listener->getSitemaps(1));