Skip to content

Commit

Permalink
Merge branch 'e2e-test-cases' into e2e-actions
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
Justas Vaitkus authored and Justas Vaitkus committed Jul 11, 2024
2 parents 3c4d8bd + 1c6ed7e commit df3f420
Show file tree
Hide file tree
Showing 41 changed files with 5,110 additions and 3,679 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile.1786
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ RUN cd /usr/local/etc/php/conf.d/ && \

RUN echo 'max_execution_time = 120' >> /usr/local/etc/php/conf.d/docker-php-maxexectime.ini

RUN pecl install -f xdebug
# RUN pecl install -f xdebug

105 changes: 0 additions & 105 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,111 +4,6 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
fix-lint:
docker-compose run --rm php sh -c "vendor/bin/php-cs-fixer fix --using-cache=no"

############ PS1784 ############################

# All the commands required to build prestashop-1784 version locally
bps1784: build-ps-1784
build-ps-1784:
# configuring your prestashop
docker exec -i prestashop-1784 sh -c "rm -rf /var/www/html/install"
# configuring base database
mysql -h 127.0.0.1 -P 9002 --protocol=tcp -u root -pprestashop prestashop < ${PWD}/tests/seed/database/prestashop_1784_2.sql
# installing module
docker exec -i prestashop-1784 sh -c "cd /var/www/html && php bin/console prestashop:module install saferpayofficial"
# uninstalling module
docker exec -i prestashop-1784 sh -c "cd /var/www/html && php bin/console prestashop:module uninstall saferpayofficial"
# installing the module again
docker exec -i prestashop-1784 sh -c "cd /var/www/html && php bin/console prestashop:module install saferpayofficial"
# chmod all folders
docker exec -i prestashop-1784 sh -c "chmod -R 777 /var/www/html"

# Preparing prestashop-1784 for e2e tests - this actually launched an app in background. You can access it already!
e2e1784p: e2e-1784-prepare
e2e-1784-prepare:
# detaching containers
docker-compose -f docker-compose.1784.yml up -d --force-recreate
# sees what containers are running
docker-compose -f docker-compose.1784.yml ps
# waits for mysql to load
/bin/bash .docker/wait-for-container.sh saferpayofficial-mysql-1784
# preloads initial data
make bps1784

# Run e2e tests in headless way.
e2eh1784: test-e2e-headless-1784
test-e2e-headless-1784:
make e2e1784p

############ PS1764 ############################

# All the commands required to build prestashop-1764 version locally
bps1764: build-ps-1764
build-ps-1764:
# configuring your prestashop
docker exec -i prestashop-1764 sh -c "rm -rf /var/www/html/install"
# configuring base database
mysql -h 127.0.0.1 -P 9002 --protocol=tcp -u root -pprestashop prestashop < ${PWD}/tests/seed/database/prestashop_1764.sql
# installing module
docker exec -i prestashop-1764 sh -c "cd /var/www/html && php bin/console prestashop:module install saferpayofficial"
# uninstalling module
docker exec -i prestashop-1764 sh -c "cd /var/www/html && php bin/console prestashop:module uninstall saferpayofficial"
# installing the module again
docker exec -i prestashop-1764 sh -c "cd /var/www/html && php bin/console prestashop:module install saferpayofficial"
# chmod all folders
docker exec -i prestashop-1764 sh -c "chmod -R 777 /var/www/html"

# Preparing prestashop-1764 for e2e tests - this actually launched an app in background. You can access it already!
e2e1764p: e2e-1764-prepare
e2e-1764-prepare:
# detaching containers
docker-compose -f docker-compose.1764.yml up -d --force-recreate
# sees what containers are running
docker-compose -f docker-compose.1764.yml ps
# waits for mysql to load
/bin/bash .docker/wait-for-container.sh saferpayofficial-mysql-1764
# preloads initial data
make bps1764

# Run e2e tests in headless way.
e2eh1764: test-e2e-headless-1764
test-e2e-headless-1764:
make e2e1764p

############ PS1770 ############################

# All the commands required to build prestashop-1764 version locally
bps1770: build-ps-1770
build-ps-1770:
# configuring your prestashop
docker exec -i prestashop-1770 sh -c "rm -rf /var/www/html/install"
# configuring base database
mysql -h 127.0.0.1 -P 9002 --protocol=tcp -u root -pprestashop prestashop < ${PWD}/tests/seed/database/prestashop_1770.sql
# installing module
docker exec -i prestashop-1770 sh -c "cd /var/www/html && php bin/console prestashop:module install saferpayofficial"
# uninstalling module
docker exec -i prestashop-1770 sh -c "cd /var/www/html && php bin/console prestashop:module uninstall saferpayofficial"
# installing the module again
docker exec -i prestashop-1770 sh -c "cd /var/www/html && php bin/console prestashop:module install saferpayofficial"
# chmod all folders
docker exec -i prestashop-1770 sh -c "chmod -R 777 /var/www/html"

# Preparing prestashop-1770 for e2e tests - this actually launched an app in background. You can access it already!
e2e1770p: e2e-1770-prepare
e2e-1770-prepare:
# detaching containers
docker-compose -f docker-compose.1770.yml up -d --force-recreate
# sees what containers are running
docker-compose -f docker-compose.1770.yml ps
# waits for mysql to load
/bin/bash .docker/wait-for-container.sh saferpayofficial-mysql-1770
# preloads initial data
make bps1770

# Run e2e tests in headless way.
e2eh1770: test-e2e-headless-1770
test-e2e-headless-1770:
make e2e1770p

############ PS1786 ############################

# All the commands required to build prestashop-1786 version locally
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,10 @@
- FO : Confirmation email after order authorization fix
- BO : Order confirmation email setting removed
- BO : Security improvements

- ## [1.2.3] - *
- FO : Increased API version to 1.40
- FO : WeChat Pay payment method added
- FO : AccountToAccount Pay payment method added
- BO : Security improvements
- BO : Bug fixes and improvements
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
},
"author": "PrestaShop",
"license": "AFL-3.0"
}
}
75 changes: 75 additions & 0 deletions controllers/front/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Invertus\SaferPay\Controller\Front\CheckoutController;
use Invertus\SaferPay\Core\Payment\DTO\CheckoutData;
use Invertus\SaferPay\Enum\ControllerName;
use Invertus\SaferPay\Repository\SaferPayOrderRepository;

if (!defined('_PS_VERSION_')) {
exit;
Expand All @@ -43,7 +44,81 @@ public function postProcess()
case 'submitHostedFields':
$this->submitHostedFields();
break;
case 'getStatus':
$this->processGetStatus();
break;
}
}

/**
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
protected function processGetStatus()
{
header('Content-Type: application/json;charset=UTF-8');
/** @var SaferPayOrderRepository $saferPayOrderRepository */
$saferPayOrderRepository = $this->module->getService(SaferPayOrderRepository::class);
$cartId = Tools::getValue('cartId');
$secureKey = Tools::getValue('secureKey');
$isBusinessLicence = (int) Tools::getValue(SaferPayConfig::IS_BUSINESS_LICENCE);
$fieldToken = Tools::getValue('fieldToken');
$moduleId = $this->module->id;
$selectedCard = Tools::getValue('selectedCard');
$saferPayOrderId = $saferPayOrderRepository->getIdByCartId($cartId);
$saferPayOrder = new SaferPayOrder($saferPayOrderId);

if (!$saferPayOrder->id || $saferPayOrder->canceled) {
$this->ajaxDie(json_encode([
'isFinished' => true,
'href' => $this->getFailControllerLink($cartId, $secureKey, $moduleId)
]));
}

$this->ajaxDie(json_encode([
'saferpayOrder' => json_encode($saferPayOrder),
'isFinished' => $saferPayOrder->authorized || $saferPayOrder->captured || $saferPayOrder->pending,
'href' => $this->context->link->getModuleLink(
$this->module->name,
$this->getSuccessControllerName($isBusinessLicence, $fieldToken),
[
'cartId' => $cartId,
'orderId' => $saferPayOrder->id_order,
'moduleId' => $moduleId,
'secureKey' => $secureKey,
'selectedCard' => $selectedCard,
]
)
]));
}

private function getFailControllerLink($cartId, $secureKey, $moduleId)
{
return $this->context->link->getModuleLink(
$this->module->name,
ControllerName::FAIL,
[
'cartId' => $cartId,
'secureKey' => $secureKey,
'moduleId' => $moduleId,
],
true
);
}

private function getSuccessControllerName($isBusinessLicence, $fieldToken)
{
$successController = ControllerName::SUCCESS;

if ($isBusinessLicence) {
$successController = ControllerName::SUCCESS_IFRAME;
}

if ($fieldToken) {
$successController = ControllerName::SUCCESS_HOSTED;
}

return $successController;
}

private function submitHostedFields()
Expand Down
Loading

0 comments on commit df3f420

Please sign in to comment.