diff --git a/Migrations/Schema/OroPayPalExpressBundleInstaller.php b/Migrations/Schema/OroPayPalExpressBundleInstaller.php index 0b20bb330e3..e4980f1b052 100644 --- a/Migrations/Schema/OroPayPalExpressBundleInstaller.php +++ b/Migrations/Schema/OroPayPalExpressBundleInstaller.php @@ -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. @@ -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] + ); } } diff --git a/Resources/views/layouts/default/config/jsmodules.yml b/Resources/views/layouts/blank/config/jsmodules.yml similarity index 100% rename from Resources/views/layouts/default/config/jsmodules.yml rename to Resources/views/layouts/blank/config/jsmodules.yml diff --git a/Resources/views/layouts/blank/config/requirejs.yml b/Resources/views/layouts/blank/config/requirejs.yml deleted file mode 100644 index 4f391d883b6..00000000000 --- a/Resources/views/layouts/blank/config/requirejs.yml +++ /dev/null @@ -1,3 +0,0 @@ -config: - paths: - 'oropaypalexpress/js/app/components/express-checkout-component': 'bundles/oropaypalexpress/js/app/components/express-checkout-component.js' diff --git a/Tests/Behat/Features/Fixtures/ProductsAndShoppingListsFixture.yml b/Tests/Behat/Features/Fixtures/ProductsAndShoppingListsFixture.yml index ba131d2a056..ce268566b16 100644 --- a/Tests/Behat/Features/Fixtures/ProductsAndShoppingListsFixture.yml +++ b/Tests/Behat/Features/Fixtures/ProductsAndShoppingListsFixture.yml @@ -18,7 +18,7 @@ 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: @@ -26,8 +26,9 @@ Oro\Bundle\ShippingBundle\Entity\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' @@ -51,7 +52,7 @@ Oro\Bundle\CustomerBundle\Entity\CustomerUser: confirmed: '1' customer: '@customer' organization: '@organization' - role: ['@buyer'] + roles: ['@buyer'] owner: '@admin' website: '@website1' @@ -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: @@ -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: diff --git a/Tests/Unit/Method/PayPalExpressMethodTest.php b/Tests/Unit/Method/PayPalExpressMethodTest.php index 36587c2eec2..ebe70ea049b 100644 --- a/Tests/Unit/Method/PayPalExpressMethodTest.php +++ b/Tests/Unit/Method/PayPalExpressMethodTest.php @@ -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'; diff --git a/Tests/Unit/Method/Translator/LineItemTranslatorTest.php b/Tests/Unit/Method/Translator/LineItemTranslatorTest.php index c4a56286a69..6c0d37d2a6a 100644 --- a/Tests/Unit/Method/Translator/LineItemTranslatorTest.php +++ b/Tests/Unit/Method/Translator/LineItemTranslatorTest.php @@ -7,7 +7,7 @@ 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; @@ -15,9 +15,9 @@ 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 @@ -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()) @@ -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); } @@ -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); diff --git a/Tests/Unit/Method/Translator/PaymentTransactionTranslatorTest.php b/Tests/Unit/Method/Translator/PaymentTransactionTranslatorTest.php index fd767972b12..f02d00754c1 100644 --- a/Tests/Unit/Method/Translator/PaymentTransactionTranslatorTest.php +++ b/Tests/Unit/Method/Translator/PaymentTransactionTranslatorTest.php @@ -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;