Skip to content

Commit

Permalink
BB-17481: PayPal Express Integration 4.1 LTS (#28067)
Browse files Browse the repository at this point in the history
- moved jsmodules file to a blank theme
- removed old requirejs file
- added changes in composer files
- Moved versioned migration code to the installer.
  • Loading branch information
ikrynychanskyi authored Jun 17, 2020
1 parent 27bc1e7 commit 8c0a50c
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 29 deletions.
98 changes: 95 additions & 3 deletions Migrations/Schema/OroPayPalExpressBundleInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Installation;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
use Oro\Bundle\PayPalExpressBundle\Migrations\Schema\v1_0;

/**
* Installer for {@see OroPayPalExpress} bundle.
Expand All @@ -26,7 +25,100 @@ public function getMigrationVersion()
*/
public function up(Schema $schema, QueryBag $queries)
{
$createPayPalSettings = new v1_0\CreatePayPalExpressSettings();
$createPayPalSettings->up($schema, $queries);
$this->updateOroIntegrationTransportTable($schema);
$this->createPpExpressLabelTable($schema);
$this->createPpExpressShortLabelTable($schema);
$this->addPpExpressLabelForeignKeys($schema);
$this->addPpExpressShortLabelForeignKeys($schema);
}

/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
protected function updateOroIntegrationTransportTable(Schema $schema)
{
$table = $schema->getTable('oro_integration_transport');

$table->addColumn('pp_express_client_id', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('pp_express_client_secret', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('pp_express_sandbox_mode', 'boolean', ['default' => '0', 'notnull' => false]);
$table->addColumn('pp_express_payment_action', 'string', ['notnull' => false, 'length' => 255]);
}

/**
* Create oro_pp_express_label table
*
* @param Schema $schema
*/
protected function createPpExpressLabelTable(Schema $schema)
{
$table = $schema->createTable('oro_pp_express_label');
$table->addColumn('transport_id', 'integer', []);
$table->addColumn('localized_value_id', 'integer', []);
$table->setPrimaryKey(['transport_id', 'localized_value_id']);
$table->addUniqueIndex(['localized_value_id'], 'UNIQ_A5EC4163EB576E89');
$table->addIndex(['transport_id'], 'IDX_A5EC41639909C13F', []);
}

/**
* Create oro_pp_express_short_label table
*
* @param Schema $schema
*/
protected function createPpExpressShortLabelTable(Schema $schema)
{
$table = $schema->createTable('oro_pp_express_short_label');
$table->addColumn('transport_id', 'integer', []);
$table->addColumn('localized_value_id', 'integer', []);
$table->setPrimaryKey(['transport_id', 'localized_value_id']);
$table->addUniqueIndex(['localized_value_id'], 'UNIQ_3E6DC779EB576E89');
$table->addIndex(['transport_id'], 'IDX_3E6DC7799909C13F', []);
}

/**
* Add oro_pp_express_label foreign keys.
*
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
protected function addPpExpressLabelForeignKeys(Schema $schema)
{
$table = $schema->getTable('oro_pp_express_label');
$table->addForeignKeyConstraint(
$schema->getTable('oro_integration_transport'),
['transport_id'],
['id'],
['onDelete' => 'CASCADE', 'onUpdate' => null]
);
$table->addForeignKeyConstraint(
$schema->getTable('oro_fallback_localization_val'),
['localized_value_id'],
['id'],
['onDelete' => 'CASCADE', 'onUpdate' => null]
);
}

/**
* Add oro_pp_express_short_label foreign keys.
*
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
protected function addPpExpressShortLabelForeignKeys(Schema $schema)
{
$table = $schema->getTable('oro_pp_express_short_label');
$table->addForeignKeyConstraint(
$schema->getTable('oro_integration_transport'),
['transport_id'],
['id'],
['onDelete' => 'CASCADE', 'onUpdate' => null]
);
$table->addForeignKeyConstraint(
$schema->getTable('oro_fallback_localization_val'),
['localized_value_id'],
['id'],
['onDelete' => 'CASCADE', 'onUpdate' => null]
);
}
}
3 changes: 0 additions & 3 deletions Resources/views/layouts/blank/config/requirejs.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ Oro\Bundle\ShippingBundle\Entity\ShippingMethodTypeConfig:

Oro\Bundle\ShippingBundle\Entity\ShippingMethodConfig:
shippingMethodConfig:
method: '<("flat_rate_".@flatRateIntegration->id)>'
method: '<("flat_rate_".@flatRateIntegration->getId())>'
typeConfigs: ['@shippingMethodTypeConfig']

Oro\Bundle\ShippingBundle\Entity\ShippingMethodsConfigsRule:
shippingMethodsConfigsRule:
rule: '@shippingRule'
methodConfigs: ['@shippingMethodConfig']
currency: 'USD'
organization: '@organization'

Oro\Bundle\CurrencyBundle\Entity\Price(local):
Oro\Bundle\CurrencyBundle\Entity\Price:
price:
value: '10'
currency: 'USD'
Expand All @@ -51,7 +52,7 @@ Oro\Bundle\CustomerBundle\Entity\CustomerUser:
confirmed: '1'
customer: '@customer'
organization: '@organization'
role: ['@buyer']
roles: ['@buyer']
owner: '@admin'
website: '@website1'

Expand All @@ -71,13 +72,15 @@ Oro\Bundle\ProductBundle\Entity\Product:
product:
sku: 'SKU123'
primaryUnitPrecision: '@precision'
setNames: [['@locValue', '@zuluLocValue']]
inventoryStatus: '@enumInventoryStatuses'
status: 'enabled'
owner: '@business_unit'
organization: '@organization'
attributeFamily: '@defaultProductFamily'
taxCode: '@tax_code_taxable_items'
__calls:
- addName: ['@locValue']
- addName: ['@zuluLocValue']

Oro\Bundle\ShoppingListBundle\Entity\ShoppingList:
shoppinglist:
Expand Down Expand Up @@ -140,7 +143,8 @@ Oro\Bundle\PricingBundle\Entity\PriceList:
pricelistShipping:
name: 'pricelist_shipping'
default: true
setCurrencies: [['USD']]
__calls:
- setCurrencies: [['USD']]
active: true

Oro\Bundle\PricingBundle\Entity\PriceListToCustomer:
Expand Down
10 changes: 0 additions & 10 deletions Tests/Unit/Method/PayPalExpressMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ public function testCanExecuteAction()
$this->assertEquals($expectedResult, $actualResult);
}

public function testIsApplicableReturnTrueWithSupportedCurrency()
{
$supportedCurrency = 'USD';

$context = $this->createPaymentContext($supportedCurrency);
$this->expectCurrencyIsSupported($supportedCurrency, true);

$this->assertTrue($this->payPalExpressMethod->isApplicable($context));
}

public function testIsApplicableReturnFalseWithNotSupportedCurrency()
{
$supportedCurrency = 'UAH';
Expand Down
14 changes: 7 additions & 7 deletions Tests/Unit/Method/Translator/LineItemTranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
use Oro\Bundle\OrderBundle\Entity\Order;
use Oro\Bundle\PaymentBundle\Model\LineItemOptionModel;
use Oro\Bundle\PaymentBundle\Model\Surcharge;
use Oro\Bundle\PaymentBundle\Provider\ExtractOptionsProvider;
use Oro\Bundle\PayPalBundle\OptionsProvider\OptionsProvider;
use Oro\Bundle\PayPalExpressBundle\Method\Translator\LineItemTranslator;
use Oro\Bundle\PayPalExpressBundle\Transport\DTO\ItemInfo;
use Symfony\Component\Translation\TranslatorInterface;

class LineItemTranslatorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\MockObject|ExtractOptionsProvider
* @var \PHPUnit\Framework\MockObject\MockObject|OptionsProvider
*/
protected $extractOptionsProvider;
protected $optionsProvider;

/**
* @var \PHPUnit\Framework\MockObject\MockObject|TranslatorInterface
Expand All @@ -41,7 +41,7 @@ class LineItemTranslatorTest extends \PHPUnit\Framework\TestCase

protected function setUp()
{
$this->extractOptionsProvider = $this->createMock(ExtractOptionsProvider::class);
$this->optionsProvider = $this->createMock(OptionsProvider::class);
$this->translator = $this->createMock(TranslatorInterface::class);
$this->rounder = $this->createMock(RoundingServiceInterface::class);
$this->rounder->expects($this->any())
Expand All @@ -51,7 +51,7 @@ protected function setUp()
});
$this->currencyFormatter = $this->createMock(NumberFormatter::class);

$this->lineItemTranslator = new LineItemTranslator($this->extractOptionsProvider, $this->translator);
$this->lineItemTranslator = new LineItemTranslator($this->optionsProvider, $this->translator);
$this->lineItemTranslator->setRounder($this->rounder);
$this->lineItemTranslator->setCurrencyFormatter($this->currencyFormatter);
}
Expand Down Expand Up @@ -339,8 +339,8 @@ protected function createOrderWithExpectedLineItems(array $lineItemOptionsModels
{
$order = new Order();

$this->extractOptionsProvider->expects($this->once())
->method('getLineItemPaymentOptions')
$this->optionsProvider->expects($this->once())
->method('getLineItemOptions')
->with($order)
->willReturn($lineItemOptionsModels);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Oro\Bundle\PayPalExpressBundle\Tests\Unit\Method\Translator;

use Oro\Bundle\CurrencyBundle\Rounding\RoundingServiceInterface;
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper;
use Oro\Bundle\OrderBundle\Entity\Order;
use Oro\Bundle\PaymentBundle\Entity\PaymentTransaction;
Expand Down

0 comments on commit 8c0a50c

Please sign in to comment.