Skip to content

Commit

Permalink
NTR: fix some tests for 6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Mar 13, 2024
1 parent 2f1a483 commit f5d7725
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/Compatibility/DependencyLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public function loadServices(): void
$loader->load('compatibility/flowbuilder/6.4.6.0.xml');
}

if ($versionCompare->gte('6.6.0.0')){
$loader->load('compatibility/service_6.6.0.0.xml');
}


$composerDevReqsInstalled = file_exists(__DIR__ . '/../../vendor/bin/phpunit');

if ($composerDevReqsInstalled) {
Expand Down
16 changes: 16 additions & 0 deletions src/Resources/config/compatibility/service_6.6.0.0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="Shopware\Core\Content\Product\Cart\ProductLineItemFactory">
<argument type="service" id="Shopware\Core\Checkout\Cart\PriceDefinitionFactory"/>
<tag name="shopware.cart.line_item.factory"/>
</service>



</services>
</container>
2 changes: 1 addition & 1 deletion src/Resources/config/services/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<service id="Kiener\MolliePayments\Service\CartService" class="Kiener\MolliePayments\Service\CartService" public="true">
<argument type="service" id="Shopware\Core\Checkout\Cart\SalesChannel\CartService"/>
<argument type="service" id="Shopware\Core\System\SalesChannel\SalesChannel\SalesChannelContextSwitcher"/>
<argument type="service" id="Shopware\Core\Content\Product\Cart\ProductLineItemFactory"/>
<argument type="service" id="Shopware\Core\Checkout\Cart\LineItemFactoryHandler\ProductLineItemFactory"/>
<argument type="service" id="Kiener\MolliePayments\Compatibility\Gateway\CompatibilityGateway"/>
</service>

Expand Down
4 changes: 2 additions & 2 deletions src/Service/CartService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Kiener\MolliePayments\Compatibility\Gateway\CompatibilityGateway;
use Kiener\MolliePayments\Compatibility\Gateway\CompatibilityGatewayInterface;
use Shopware\Core\Checkout\Cart\Cart;
use Shopware\Core\Checkout\Cart\LineItemFactoryHandler\ProductLineItemFactory;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService as SalesChannelCartService;
use Shopware\Core\Content\Product\Cart\ProductLineItemFactory;
use Shopware\Core\Framework\Validation\DataBag\DataBag;
use Shopware\Core\System\SalesChannel\Context\SalesChannelContextService;
use Shopware\Core\System\SalesChannel\SalesChannel\SalesChannelContextSwitcher;
Expand Down Expand Up @@ -60,7 +60,7 @@ public function addProduct(string $productId, int $quantity, SalesChannelContext
{
$cart = $this->getCalculatedMainCart($context);

$productItem = $this->productItemFactory->create($productId, ['quantity' => $quantity]);
$productItem = $this->productItemFactory->create(['id'=>$productId, 'quantity' => $quantity],$context);

return $this->swCartService->add($cart, $productItem, $context);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Cypress/cypress/e2e/admin/plugin-config.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ context("Plugin Config", () => {
cy.contains('Request support from Mollie');

// the modal should show the Shopware version number
cy.contains("v" + shopware.getVersion());
cy.contains("v" + shopware.getDisplayedVersion());

// the send button is disabled until data is filled in
cy.get('.sw-button-process').should('be.disabled');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class AdminLoginAction {
cy.get('#sw-field--password').type('shopware');

cy.get('.sw-button').click();
cy.wait(2000);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ export default class StoreApiLoginAction {
);

cy.wrap(loginPromise).then((response) => {
const loginToken = response.data.contextToken;
let loginToken = response.data.contextToken;
if(loginToken === undefined){
loginToken = response.headers["sw-context-token"];
}
this.client.setContextToken(loginToken);
cy.log('Context-Token: ' + loginToken);
});
Expand Down
8 changes: 8 additions & 0 deletions tests/Cypress/cypress/support/services/shopware/Shopware.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export default class Shopware {
return Cypress.env().SHOPWARE;
}

/**
* sometimes we test RC versions, and shopware display the version differently in the admin
* @returns {string}
*/
getDisplayedVersion(){
return Cypress.env().SHOPWARE.replace('-rc',' RC ');
}

/**
*
* @returns {string}
Expand Down

0 comments on commit f5d7725

Please sign in to comment.