From 24f118b15346ec6bb5178a569ce62a9bd7121368 Mon Sep 17 00:00:00 2001 From: Alexander Pobereznichenko Date: Tue, 17 Jan 2017 00:01:55 +0200 Subject: [PATCH 01/10] Fix account=>customer migrations --- .../Schema/v1_10/OroAccountBundle.php | 145 +++++++++++------- 1 file changed, 93 insertions(+), 52 deletions(-) diff --git a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php index b243e291e51..5f13a9279c1 100644 --- a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php +++ b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php @@ -177,28 +177,38 @@ private function renameCustomer(Schema $schema, QueryBag $queries) 'oro_rel_c3990ba6b28b6f382b5af2', 'oro_rel_c3990ba6b28b6f383f1392', ]; - foreach ($possibleTableNames as $tableName) { - if ($schema->hasTable($tableName)) { - $table = $schema->getTable($tableName); - $table->removeForeignKey($this->getConstraintName($table, "account_id")); - foreach ($table->getIndexes() as $index) { - if ($index->getColumns() === ['account_id']) { - $table->dropIndex($index->getName()); + if (!$schema->hasTable('oro_rel_c3990ba6784fec5f6e321b')) { + foreach ($possibleTableNames as $tableName) { + $schema->dropTable($tableName); + } + } else { + foreach ($possibleTableNames as $tableName) { + if ($schema->hasTable($tableName)) { + if (!$schema->hasTable('oro_rel_c3990ba6784fec5f6e321b')) { + $schema->dropTable($tableName); + } else { + $table = $schema->getTable($tableName); + $table->removeForeignKey($this->getConstraintName($table, "account_id")); + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['account_id']) { + $table->dropIndex($index->getName()); + } + } + $this->renameExtension->renameColumn( + $schema, + $queries, + $table, + 'account_id', + 'customer_id' + ); + $this->renameExtension->renameTable( + $schema, + $queries, + $tableName, + 'oro_rel_c3990ba6784fec5f6e321b' + ); } } - $this->renameExtension->renameColumn( - $schema, - $queries, - $table, - 'account_id', - 'customer_id' - ); - $this->renameExtension->renameTable( - $schema, - $queries, - $tableName, - 'oro_rel_c3990ba6784fec5f6e321b' - ); } } if ($schema->hasTable('oro_rel_6f8f552ab28b6f38cd148c')) { @@ -323,28 +333,42 @@ private function renameCustomerUserRole(Schema $schema, QueryBag $queries) 'oro_rel_c3990ba69df6f4d8894a76', 'oro_rel_c3990ba69df6f4d84415b1', ]; - foreach ($possibleTableNames as $tableName) { - if ($schema->hasTable($tableName)) { - $table = $schema->getTable($tableName); - $table->removeForeignKey($this->getConstraintName($table, "accountuserrole_id")); - foreach ($table->getIndexes() as $index) { - if ($index->getColumns() === ['accountuserrole_id']) { - $table->dropIndex($index->getName()); + if ($schema->hasTable('oro_rel_c3990ba6d7fa01cd30d950')) { + foreach ($possibleTableNames as $tableName) { + if ($schema->hasTable($tableName)) { + $schema->dropTable($tableName); + } + } + } else { + $renamed = false; + foreach ($possibleTableNames as $tableName) { + if ($schema->hasTable($tableName)) { + if ($renamed) { + $schema->dropTable($tableName); + continue; } + $table = $schema->getTable($tableName); + $table->removeForeignKey($this->getConstraintName($table, "accountuserrole_id")); + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['accountuserrole_id']) { + $table->dropIndex($index->getName()); + } + } + $this->renameExtension->renameColumn( + $schema, + $queries, + $table, + 'accountuserrole_id', + 'customeruserrole_id' + ); + $this->renameExtension->renameTable( + $schema, + $queries, + $tableName, + 'oro_rel_c3990ba6d7fa01cd30d950' + ); + $renamed = true; } - $this->renameExtension->renameColumn( - $schema, - $queries, - $table, - 'accountuserrole_id', - 'customeruserrole_id' - ); - $this->renameExtension->renameTable( - $schema, - $queries, - $tableName, - 'oro_rel_c3990ba6d7fa01cd30d950' - ); } } @@ -537,6 +561,9 @@ private function renameAccountAddressTable(Schema $schema, QueryBag $queries) } /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * * @param Schema $schema * @param QueryBag $queries */ @@ -589,18 +616,32 @@ public function renameCustomerGroup(Schema $schema, QueryBag $queries) 'oro_rel_c3990ba665864788b74044', 'oro_rel_c3990ba6658647885abb70', ]; - foreach ($tables as $tableName) { - if ($schema->hasTable($tableName)) { - $table = $schema->getTable($tableName); - $fk = $this->getConstraintName($table, 'accountgroup_id'); - $table->removeForeignKey($fk); - $extension->renameColumn($schema, $queries, $table, 'accountgroup_id', 'customergroup_id'); - $extension->renameTable( - $schema, - $queries, - $tableName, - 'oro_rel_c3990ba616cbf45899499b' - ); + if ($schema->hasTable('oro_rel_c3990ba616cbf45899499b')) { + foreach ($tables as $tableName) { + if ($schema->hasTable($tableName)) { + $schema->dropTable($tableName); + } + } + } else { + $renamed = false; + foreach ($tables as $tableName) { + if ($schema->hasTable($tableName)) { + if ($renamed) { + $schema->dropTable($tableName); + } else { + $table = $schema->getTable($tableName); + $fk = $this->getConstraintName($table, 'accountgroup_id'); + $table->removeForeignKey($fk); + $extension->renameColumn($schema, $queries, $table, 'accountgroup_id', 'customergroup_id'); + $extension->renameTable( + $schema, + $queries, + $tableName, + 'oro_rel_c3990ba616cbf45899499b' + ); + $renamed = true; + } + } } } if ($schema->hasTable('oro_rel_6f8f552a65864788eebf8a')) { From bb55df462574383ddd007789312f8b99ed24c094 Mon Sep 17 00:00:00 2001 From: Alexander Pobereznichenko Date: Tue, 17 Jan 2017 00:27:01 +0200 Subject: [PATCH 02/10] Fix account=>customer migrations --- .../Migrations/Schema/v1_10/OroAccountBundle.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php index 5f13a9279c1..df80a3cdae4 100644 --- a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php +++ b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php @@ -179,7 +179,9 @@ private function renameCustomer(Schema $schema, QueryBag $queries) ]; if (!$schema->hasTable('oro_rel_c3990ba6784fec5f6e321b')) { foreach ($possibleTableNames as $tableName) { - $schema->dropTable($tableName); + if ($schema->hasTable($tableName)) { + $schema->dropTable($tableName); + } } } else { foreach ($possibleTableNames as $tableName) { From b6affb8cf823435afe1f7c798a7d9e65c244b995 Mon Sep 17 00:00:00 2001 From: Alexander Pobereznichenko Date: Tue, 17 Jan 2017 13:30:29 +0200 Subject: [PATCH 03/10] Fix account=>customer migrations --- .../Schema/v1_10/OroAccountBundle.php | 80 ++++++++++++++++++- .../Schema/v1_10/OroAccountBundleStage2.php | 39 ++++++++- 2 files changed, 115 insertions(+), 4 deletions(-) diff --git a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php index df80a3cdae4..65815478d86 100644 --- a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php +++ b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php @@ -171,18 +171,41 @@ private function renameCustomer(Schema $schema, QueryBag $queries) $query->setFieldName($relation); $queries->addPostQuery($query); } + + $this->migrateConfig( + $configManager, + 'Oro\Bundle\NoteBundle\Entity\Note', + 'Oro\Bundle\CustomerBundle\Entity\Customer', + $relation, + 'customer_71cbb705', + RelationType::MANY_TO_MANY + ); } $possibleTableNames = [ 'oro_rel_c3990ba6b28b6f382b5af2', 'oro_rel_c3990ba6b28b6f383f1392', ]; - if (!$schema->hasTable('oro_rel_c3990ba6784fec5f6e321b')) { + if ($schema->hasTable('oro_rel_c3990ba6784fec5f6e321b')) { foreach ($possibleTableNames as $tableName) { if ($schema->hasTable($tableName)) { $schema->dropTable($tableName); } } + $table = $schema->getTable('oro_rel_c3990ba6784fec5f6e321b'); + $table->removeForeignKey($this->getConstraintName($table, "account_id")); + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['account_id']) { + $table->dropIndex($index->getName()); + } + } + $this->renameExtension->renameColumn( + $schema, + $queries, + $table, + 'account_id', + 'customer_id' + ); } else { foreach ($possibleTableNames as $tableName) { if ($schema->hasTable($tableName)) { @@ -293,6 +316,8 @@ private function renameCustomer(Schema $schema, QueryBag $queries) /** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * * @param Schema $schema * @param QueryBag $queries */ @@ -341,6 +366,20 @@ private function renameCustomerUserRole(Schema $schema, QueryBag $queries) $schema->dropTable($tableName); } } + $table = $schema->getTable('oro_rel_c3990ba6d7fa01cd30d950'); + $table->removeForeignKey($this->getConstraintName($table, "accountuserrole_id")); + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['accountuserrole_id']) { + $table->dropIndex($index->getName()); + } + } + $this->renameExtension->renameColumn( + $schema, + $queries, + $table, + 'accountuserrole_id', + 'customeruserrole_id' + ); } else { $renamed = false; foreach ($possibleTableNames as $tableName) { @@ -373,6 +412,15 @@ private function renameCustomerUserRole(Schema $schema, QueryBag $queries) } } } + if ($schema->hasTable('oro_rel_6f8f552a9df6f4d81e2432') && $schema->getTable('oro_rel_6f8f552a9df6f4d81e2432') + ->hasColumn('accountuserrole_id') + ) { + $table = $schema->getTable('oro_rel_6f8f552a9df6f4d81e2432'); + $fk = $this->getConstraintName($table, 'accountuserrole_id'); + $table->removeForeignKey($fk); + $this->renameExtension + ->renameColumn($schema, $queries, $table, 'accountuserrole_id', 'customeruserrole_id'); + } $possibleActivityRelations = [ 'account_user_role_a5e27440', @@ -604,6 +652,14 @@ public function renameCustomerGroup(Schema $schema, QueryBag $queries) $query->setTargetClass('CustomerGroup'); $queries->addPostQuery($query); } + $this->migrateConfig( + $configManager, + 'Oro\Bundle\NoteBundle\Entity\Note', + 'Oro\Bundle\CustomerBundle\Entity\CustomerGroup', + $relation, + 'customer_group_4f9aa384', + RelationType::MANY_TO_MANY + ); $this->migrateConfig( $configManager, 'Oro\Bundle\ActivityListBundle\Entity\ActivityList', @@ -624,6 +680,10 @@ public function renameCustomerGroup(Schema $schema, QueryBag $queries) $schema->dropTable($tableName); } } + $table = $schema->getTable('oro_rel_c3990ba616cbf45899499b'); + $fk = $this->getConstraintName($table, 'accountgroup_id'); + $table->removeForeignKey($fk); + $extension->renameColumn($schema, $queries, $table, 'accountgroup_id', 'customergroup_id'); } else { $renamed = false; foreach ($tables as $tableName) { @@ -646,6 +706,7 @@ public function renameCustomerGroup(Schema $schema, QueryBag $queries) } } } + if ($schema->hasTable('oro_rel_6f8f552a65864788eebf8a')) { $table = $schema->getTable('oro_rel_6f8f552a65864788eebf8a'); $fk = $this->getConstraintName($table, 'accountgroup_id'); @@ -849,6 +910,23 @@ private function renameCustomerUser(Schema $schema, QueryBag $queries) ); } + if ($schema->hasTable('oro_rel_46a29d19a6adb604aeb863') && $schema->getTable('oro_rel_46a29d19a6adb604aeb863') + ->hasColumn('accountuser_id') + ) { + $table = $schema->getTable('oro_rel_46a29d19a6adb604aeb863'); + $fk = $this->getConstraintName($table, 'accountuser_id'); + $table->removeForeignKey($fk); + $extension->renameColumn($schema, $queries, $table, 'accountuser_id', 'customeruser_id'); + } + if ($schema->hasTable('oro_rel_46a29d19a6adb604aeb863') && $schema->getTable('oro_rel_c3990ba6a6adb604193652') + ->hasColumn('accountuser_id') + ) { + $table = $schema->getTable('oro_rel_c3990ba6a6adb604193652'); + $fk = $this->getConstraintName($table, 'accountuser_id'); + $table->removeForeignKey($fk); + $extension->renameColumn($schema, $queries, $table, 'accountuser_id', 'customeruser_id'); + } + $this->renameRelationTable( $schema, $queries, diff --git a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php index e3aed620152..188a23a996d 100644 --- a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php +++ b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php @@ -61,7 +61,7 @@ public function up(Schema $schema, QueryBag $queries) 'oro_note', 'oro_customer' ); - $this->alterScopes($schema, $queries); + $this->alterScopes($schema); } /** @@ -96,6 +96,16 @@ private function renameAccountUserRole(Schema $schema) ['onDelete' => 'CASCADE', 'onUpdate' => null] ); + if ($schema->hasTable("oro_rel_6f8f552a9df6f4d81e2432")) { + $table = $schema->getTable("oro_rel_6f8f552a9df6f4d81e2432"); + $table->addForeignKeyConstraint( + $schema->getTable('oro_customer_user_role'), + ['customeruserrole_id'], + ['id'], + ['onDelete' => 'CASCADE', 'onUpdate' => null] + ); + } + $table = $schema->getTable("oro_rel_c3990ba6d7fa01cd30d950"); $table->addForeignKeyConstraint( $schema->getTable('oro_customer_user_role'), @@ -285,6 +295,10 @@ public function renameCustomer(Schema $schema) } /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * * @param Schema $schema */ public function renameCustomerUser(Schema $schema) @@ -373,13 +387,32 @@ public function renameCustomerUser(Schema $schema) ['id'], ['onDelete' => 'SET NULL', 'onUpdate' => null] ); + + if ($schema->hasTable('oro_rel_46a29d19a6adb604aeb863')) { + $schema->getTable('oro_rel_46a29d19a6adb604aeb863') + ->addForeignKeyConstraint( + $schema->getTable('oro_customer_user'), + ['customeruser_id'], + ['id'], + ['onDelete' => 'SET NULL', 'onUpdate' => null] + ); + } + + if ($schema->hasTable('oro_rel_c3990ba6a6adb604193652')) { + $schema->getTable('oro_rel_c3990ba6a6adb604193652') + ->addForeignKeyConstraint( + $schema->getTable('oro_customer_user'), + ['customeruser_id'], + ['id'], + ['onDelete' => 'SET NULL', 'onUpdate' => null] + ); + } } /** * @param Schema $schema - * @param QueryBag $queries */ - private function alterScopes(Schema $schema, QueryBag $queries) + private function alterScopes(Schema $schema) { $table = $schema->getTable('oro_scope'); $table->addForeignKeyConstraint( From 283dcbda0c239a750c61bc9221911fe91b3c2253 Mon Sep 17 00:00:00 2001 From: Ilya Antipenko Date: Tue, 17 Jan 2017 14:45:34 +0200 Subject: [PATCH 04/10] BB-7183: PayPal parameters - add BUTTONSOURCE option - set BUTTONSOURCE for PayPal Payflow, PayPal Payments Pro, Payflow Express Checkout - fix sendtion zero tax info to PP - fix typo in app.yml - update tests --- .../Method/PayflowExpressCheckout.php | 47 ++++++++++++++----- .../PayPalBundle/Method/PayflowGateway.php | 14 ++++++ .../Request/AuthorizationRequest.php | 3 +- .../ExpressCheckout/Request/SaleRequest.php | 3 +- .../Gateway/Request/AuthorizationRequest.php | 3 +- .../Payflow/Gateway/Request/SaleRequest.php | 3 +- .../PayPal/Payflow/Option/ButtonSource.php | 16 +++++++ .../Payflow/Request/DelayedCaptureRequest.php | 3 +- .../PayPalBundle/Resources/config/oro/app.yml | 2 +- .../PayPalBundle/Resources/config/payment.yml | 2 + .../Method/PayflowExpressCheckoutTest.php | 28 ++++++++++- .../Tests/Unit/Method/PayflowGatewayTest.php | 2 +- .../Payflow/Option/ButtonSourceTest.php | 32 +++++++++++++ .../ExtractLineItemPaymentOptionsListener.php | 2 +- 14 files changed, 137 insertions(+), 23 deletions(-) create mode 100644 src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Option/ButtonSource.php create mode 100644 src/Oro/Bundle/PayPalBundle/Tests/Unit/PayPal/Payflow/Option/ButtonSourceTest.php diff --git a/src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php b/src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php index 4f58d4989f3..b5fbeb28294 100644 --- a/src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php +++ b/src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php @@ -27,6 +27,9 @@ class PayflowExpressCheckout implements PaymentMethodInterface const COMPLETE = 'complete'; + // PayPal BN code + const BUTTON_SOURCE = 'OroCommerce_SP'; + const PILOT_REDIRECT_URL = 'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=%s'; const PRODUCTION_REDIRECT_URL = 'https://www.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=%s'; @@ -58,6 +61,7 @@ class PayflowExpressCheckout implements PaymentMethodInterface * @param DoctrineHelper $doctrineHelper * @param ExtractOptionsProvider $optionsProvider * @param SurchargeProvider $surchargeProvider + * @param PropertyAccessor $propertyAccessor */ public function __construct( Gateway $gateway, @@ -65,7 +69,8 @@ public function __construct( RouterInterface $router, DoctrineHelper $doctrineHelper, ExtractOptionsProvider $optionsProvider, - SurchargeProvider $surchargeProvider + SurchargeProvider $surchargeProvider, + PropertyAccessor $propertyAccessor ) { $this->gateway = $gateway; $this->config = $config; @@ -73,6 +78,7 @@ public function __construct( $this->doctrineHelper = $doctrineHelper; $this->optionsProvider = $optionsProvider; $this->surchargeProvider = $surchargeProvider; + $this->propertyAccessor = $propertyAccessor; } /** @@ -124,12 +130,14 @@ public function supports($actionName) */ protected function purchase(PaymentTransaction $paymentTransaction) { - $paymentTransaction->setRequest(array_merge( + $options = array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), $this->getSetExpressCheckoutOptions($paymentTransaction), $this->getShippingAddressOptions($paymentTransaction) - )); + ); + $paymentTransaction->setRequest($options); $paymentTransaction->setAction($this->config->getPurchaseAction()); $this->execute($paymentTransaction->getAction(), $paymentTransaction); @@ -148,11 +156,13 @@ protected function purchase(PaymentTransaction $paymentTransaction) */ protected function complete(PaymentTransaction $paymentTransaction) { - $paymentTransaction->setRequest(array_merge( + $options = array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), $this->getDoExpressCheckoutOptions($paymentTransaction) - )); + ); + $paymentTransaction->setRequest($options); $response = $this->actionRequest($paymentTransaction, ECOption\Action::DO_EC); $data = $response->getData(); @@ -182,10 +192,12 @@ protected function complete(PaymentTransaction $paymentTransaction) */ protected function authorize(PaymentTransaction $paymentTransaction) { - $paymentTransaction->setRequest(array_merge( + $options = array_merge( $paymentTransaction->getRequest(), [Option\Transaction::TRXTYPE => Option\Transaction::AUTHORIZATION] - )); + ); + + $paymentTransaction->setRequest($options); $this->setExpressCheckoutRequest($paymentTransaction); } @@ -194,10 +206,12 @@ protected function authorize(PaymentTransaction $paymentTransaction) */ protected function charge(PaymentTransaction $paymentTransaction) { - $paymentTransaction->setRequest(array_merge( + $options = array_merge( $paymentTransaction->getRequest(), [Option\Transaction::TRXTYPE => Option\Transaction::SALE] - )); + ); + + $paymentTransaction->setRequest($options); $this->setExpressCheckoutRequest($paymentTransaction); } @@ -218,6 +232,7 @@ protected function capture(PaymentTransaction $paymentTransaction) $options = array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), $this->getDelayedCaptureOptions($paymentTransaction) ); @@ -477,10 +492,6 @@ protected function getTransactionType(PaymentTransaction $paymentTransaction) */ protected function getPropertyAccessor() { - if (!$this->propertyAccessor) { - $this->propertyAccessor = PropertyAccess::createPropertyAccessor(); - } - return $this->propertyAccessor; } @@ -496,4 +507,14 @@ protected function getCredentials() ] ); } + + /** + * @return array + */ + protected function getAdditionalOptions() + { + return [ + Option\ButtonSource::BUTTONSOURCE => self::BUTTON_SOURCE + ]; + } } diff --git a/src/Oro/Bundle/PayPalBundle/Method/PayflowGateway.php b/src/Oro/Bundle/PayPalBundle/Method/PayflowGateway.php index 9641bcb26ac..14c44e64bad 100644 --- a/src/Oro/Bundle/PayPalBundle/Method/PayflowGateway.php +++ b/src/Oro/Bundle/PayPalBundle/Method/PayflowGateway.php @@ -26,6 +26,9 @@ class PayflowGateway implements PaymentMethodInterface const ZERO_AMOUNT = 0; + // PayPal BN code + const BUTTON_SOURCE = 'OroCommerce_SP'; + /** @var Gateway */ protected $gateway; @@ -374,8 +377,19 @@ protected function combineOptions(array $options = []) { return array_replace( $this->config->getCredentials(), + $this->getAdditionalOptions(), $options, $this->getVerbosityOption() ); } + + /** + * @return array + */ + protected function getAdditionalOptions() + { + return [ + Option\ButtonSource::BUTTONSOURCE => self::BUTTON_SOURCE + ]; + } } diff --git a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/ExpressCheckout/Request/AuthorizationRequest.php b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/ExpressCheckout/Request/AuthorizationRequest.php index 9980ef273d3..f3777e84be2 100644 --- a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/ExpressCheckout/Request/AuthorizationRequest.php +++ b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/ExpressCheckout/Request/AuthorizationRequest.php @@ -31,7 +31,8 @@ public function configureRequestOptions() ->addOption(new ECOption\PaymentType()) ->addOption(new ECOption\ShippingAddress()) ->addOption(new ECOption\ShippingAddressOverride()) - ->addOption(new Option\Verbosity()); + ->addOption(new Option\Verbosity()) + ->addOption(new Option\ButtonSource()); return $this; } diff --git a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/ExpressCheckout/Request/SaleRequest.php b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/ExpressCheckout/Request/SaleRequest.php index d7a1fdc6b6b..b5900d0d0b3 100644 --- a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/ExpressCheckout/Request/SaleRequest.php +++ b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/ExpressCheckout/Request/SaleRequest.php @@ -31,7 +31,8 @@ public function configureRequestOptions() ->addOption(new ECOption\PaymentType()) ->addOption(new ECOption\ShippingAddress()) ->addOption(new ECOption\ShippingAddressOverride()) - ->addOption(new Option\Verbosity()); + ->addOption(new Option\Verbosity()) + ->addOption(new Option\ButtonSource()); return $this; } diff --git a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Gateway/Request/AuthorizationRequest.php b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Gateway/Request/AuthorizationRequest.php index 13a184641ee..2a497cb1d98 100644 --- a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Gateway/Request/AuthorizationRequest.php +++ b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Gateway/Request/AuthorizationRequest.php @@ -35,7 +35,8 @@ public function configureRequestOptions() ->addOption(new GatewayOption\TransparentRedirect()) ->addOption(new GatewayOption\SecureTokenIdentifier()) ->addOption(new GatewayOption\SilentPost()) - ->addOption(new GatewayOption\CreateSecureToken()); + ->addOption(new GatewayOption\CreateSecureToken()) + ->addOption(new Option\ButtonSource()); return $this; } diff --git a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Gateway/Request/SaleRequest.php b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Gateway/Request/SaleRequest.php index 43ed3b792cd..1eaadf63b34 100644 --- a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Gateway/Request/SaleRequest.php +++ b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Gateway/Request/SaleRequest.php @@ -36,7 +36,8 @@ public function configureRequestOptions() ->addOption(new GatewayOption\TransparentRedirect()) ->addOption(new GatewayOption\SecureTokenIdentifier()) ->addOption(new GatewayOption\CreateSecureToken()) - ->addOption(new GatewayOption\SilentPost()); + ->addOption(new GatewayOption\SilentPost()) + ->addOption(new Option\ButtonSource()); return $this; } diff --git a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Option/ButtonSource.php b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Option/ButtonSource.php new file mode 100644 index 00000000000..954f991829f --- /dev/null +++ b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Option/ButtonSource.php @@ -0,0 +1,16 @@ +setDefined(ButtonSource::BUTTONSOURCE) + ->addAllowedTypes(ButtonSource::BUTTONSOURCE, 'string'); + } +} diff --git a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Request/DelayedCaptureRequest.php b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Request/DelayedCaptureRequest.php index 3237731d418..069fbaeaf0a 100644 --- a/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Request/DelayedCaptureRequest.php +++ b/src/Oro/Bundle/PayPalBundle/PayPal/Payflow/Request/DelayedCaptureRequest.php @@ -20,7 +20,8 @@ public function configureRequestOptions() ->addOption(new Option\Amount(false)) ->addOption(new Option\CaptureComplete()) ->addOption(new Option\OriginalTransaction()) - ->addOption(new Option\Verbosity()); + ->addOption(new Option\Verbosity()) + ->addOption(new Option\ButtonSource()); return $this; } diff --git a/src/Oro/Bundle/PayPalBundle/Resources/config/oro/app.yml b/src/Oro/Bundle/PayPalBundle/Resources/config/oro/app.yml index 63937a34893..13cff073537 100644 --- a/src/Oro/Bundle/PayPalBundle/Resources/config/oro/app.yml +++ b/src/Oro/Bundle/PayPalBundle/Resources/config/oro/app.yml @@ -1,4 +1,4 @@ -# Uncomment this setting if you need to be able to recieve payment confirmation notifications from PayPal servers +# Uncomment this setting if you need to be able to receive payment confirmation notifications from PayPal servers # when developing on the local machine # For more info see bundle documentation, section "Testing the PayPal response" diff --git a/src/Oro/Bundle/PayPalBundle/Resources/config/payment.yml b/src/Oro/Bundle/PayPalBundle/Resources/config/payment.yml index 08bd5e9a29c..2f404ade046 100644 --- a/src/Oro/Bundle/PayPalBundle/Resources/config/payment.yml +++ b/src/Oro/Bundle/PayPalBundle/Resources/config/payment.yml @@ -53,6 +53,7 @@ services: - '@oro_entity.doctrine_helper' - '@oro_payment.provider.extract_options' - '@oro_payment.provider.surcharge' + - '@property_accessor' tags: - { name: oro_payment.payment_method } @@ -66,6 +67,7 @@ services: - '@oro_entity.doctrine_helper' - '@oro_payment.provider.extract_options' - '@oro_payment.provider.surcharge' + - '@property_accessor' tags: - { name: oro_payment.payment_method } diff --git a/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowExpressCheckoutTest.php b/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowExpressCheckoutTest.php index 8e40471a477..56ac461d875 100644 --- a/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowExpressCheckoutTest.php +++ b/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowExpressCheckoutTest.php @@ -17,6 +17,8 @@ use Oro\Bundle\PayPalBundle\Method\PayflowExpressCheckout; use Oro\Bundle\PayPalBundle\PayPal\Payflow\Gateway; use Oro\Bundle\PayPalBundle\PayPal\Payflow\Response\Response; +use Symfony\Component\PropertyAccess\PropertyAccess; +use Symfony\Component\PropertyAccess\PropertyAccessor; use Symfony\Component\Routing\RouterInterface; /** @@ -54,6 +56,9 @@ class PayflowExpressCheckoutTest extends \PHPUnit_Framework_TestCase /** @var SurchargeProvider|\PHPUnit_Framework_MockObject_MockObject */ protected $surchargeProvider; + /** @var PropertyAccessor */ + protected $propertyAccessor; + protected function setUp() { $this->gateway = $this->getMockBuilder(Gateway::class)->disableOriginalConstructor()->getMock(); @@ -69,13 +74,16 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); + $this->propertyAccessor = PropertyAccess::createPropertyAccessor(); + $this->expressCheckout = new PayflowExpressCheckout( $this->gateway, $this->paymentConfig, $this->router, $this->doctrineHelper, $this->optionsProvider, - $this->surchargeProvider + $this->surchargeProvider, + $this->propertyAccessor ); } @@ -214,6 +222,7 @@ public function testPurchaseCheckRequest() $requestData = array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), $this->getExpressCheckoutOptions(), $this->getShippingAddressOptions(), $this->getLineItemOptions(), @@ -302,6 +311,7 @@ public function testPurchaseWithoutShippingAddress() $requestData = array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), $this->getExpressCheckoutOptions(), $this->getLineItemOptions(), $this->getSurchargeOptions() @@ -480,6 +490,7 @@ public function getLineItemOptionsProvider() 'entity' => new \stdClass(), 'requestData' => array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), $this->getExpressCheckoutOptions(), $this->getShippingAddressOptions(), $this->getSurchargeOptions() @@ -491,6 +502,7 @@ public function getLineItemOptionsProvider() 'entity' => $this->getEntity(), 'requestData' => array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), $this->getExpressCheckoutOptions(), $this->getShippingAddressOptions(), $this->getSurchargeOptions(), @@ -512,7 +524,7 @@ public function testCompleteSuccess() 'PAYERID' => 'payerIdTest', ]; - $transactionRequest = array_merge($transactionRequest, $this->getCredentials()); + $transactionRequest = array_merge($transactionRequest, $this->getCredentials(), $this->getAdditionalOptions()); $transaction = $this->createTransaction(PaymentMethodInterface::AUTHORIZE); @@ -603,6 +615,7 @@ public function testComplete() $requestOptions = array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), [ 'AMT' => 10, 'TOKEN' => self::TOKEN, @@ -650,6 +663,7 @@ public function testCaptureSuccess() $requestOptions = array_merge( $this->getCredentials(), + $this->getAdditionalOptions(), $this->getDelayedCaptureOptions() ); @@ -827,4 +841,14 @@ protected function configCredentials() ->method('getCredentials') ->willReturn($this->getCredentials()); } + + /** + * @return array + */ + protected function getAdditionalOptions() + { + return [ + 'BUTTONSOURCE' => 'OroCommerce_SP' + ]; + } } diff --git a/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowGatewayTest.php b/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowGatewayTest.php index 4189b03ece9..a1975a939a0 100644 --- a/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowGatewayTest.php +++ b/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowGatewayTest.php @@ -11,7 +11,7 @@ class PayflowGatewayTest extends AbstractPayflowGatewayTest */ protected function getMethod() { - return new PayflowGateway($this->gateway, $this->paymentConfig, $this->router); + return new PayflowGateway($this->gateway, $this->paymentConfig, $this->router); } public function testGetType() diff --git a/src/Oro/Bundle/PayPalBundle/Tests/Unit/PayPal/Payflow/Option/ButtonSourceTest.php b/src/Oro/Bundle/PayPalBundle/Tests/Unit/PayPal/Payflow/Option/ButtonSourceTest.php new file mode 100644 index 00000000000..feb08667963 --- /dev/null +++ b/src/Oro/Bundle/PayPalBundle/Tests/Unit/PayPal/Payflow/Option/ButtonSourceTest.php @@ -0,0 +1,32 @@ + [], + 'invalid type' => [ + ['BUTTONSOURCE' => 100001], + [], + [ + 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', + 'The option "BUTTONSOURCE" with value 100001 is expected to be of type "string", but is of ' . + 'type "integer".', + ], + ], + 'valid' => [['BUTTONSOURCE' => 'OroCommerce_SP'], ['BUTTONSOURCE' => 'OroCommerce_SP']], + ]; + } +} diff --git a/src/Oro/Bundle/TaxBundle/EventListener/ExtractLineItemPaymentOptionsListener.php b/src/Oro/Bundle/TaxBundle/EventListener/ExtractLineItemPaymentOptionsListener.php index e6c7e9a4e13..efaf37b4c05 100644 --- a/src/Oro/Bundle/TaxBundle/EventListener/ExtractLineItemPaymentOptionsListener.php +++ b/src/Oro/Bundle/TaxBundle/EventListener/ExtractLineItemPaymentOptionsListener.php @@ -42,7 +42,7 @@ public function onExtractLineItemPaymentOptions(ExtractLineItemPaymentOptionsEve return; } - if ($taxAmount === 0) { + if ((float)$taxAmount === 0.) { return; } From ce346f91453a98e34530097d3d485e88dcd3a8dc Mon Sep 17 00:00:00 2001 From: Oleg Popadko Date: Tue, 17 Jan 2017 15:13:45 +0200 Subject: [PATCH 05/10] BB-7167: Upgrade beta3 -> rc1 -> 1.0.0 fails - sequences of new tables were not renamed on renaming tables in next migrations, so new migration for renaming was added --- .../Schema/OroShippingBundleInstaller.php | 2 +- .../Schema/v1_4/RenameTablesSequences.php | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/Oro/Bundle/ShippingBundle/Migrations/Schema/v1_4/RenameTablesSequences.php diff --git a/src/Oro/Bundle/ShippingBundle/Migrations/Schema/OroShippingBundleInstaller.php b/src/Oro/Bundle/ShippingBundle/Migrations/Schema/OroShippingBundleInstaller.php index 80e45eaf43e..423c2187239 100644 --- a/src/Oro/Bundle/ShippingBundle/Migrations/Schema/OroShippingBundleInstaller.php +++ b/src/Oro/Bundle/ShippingBundle/Migrations/Schema/OroShippingBundleInstaller.php @@ -24,7 +24,7 @@ class OroShippingBundleInstaller implements Installation, ActivityExtensionAware */ public function getMigrationVersion() { - return 'v1_3'; + return 'v1_4'; } /** diff --git a/src/Oro/Bundle/ShippingBundle/Migrations/Schema/v1_4/RenameTablesSequences.php b/src/Oro/Bundle/ShippingBundle/Migrations/Schema/v1_4/RenameTablesSequences.php new file mode 100644 index 00000000000..07d1355480b --- /dev/null +++ b/src/Oro/Bundle/ShippingBundle/Migrations/Schema/v1_4/RenameTablesSequences.php @@ -0,0 +1,62 @@ +platform = $platform; + } + + /** + * {@inheritdoc} + */ + public function up(Schema $schema, QueryBag $queries) + { + $this->renameSequence($schema, $queries, 'oro_shipping_rule_mthd_config', 'oro_ship_method_config'); + $this->renameSequence($schema, $queries, 'oro_shipping_rule_mthd_tp_cnfg', 'oro_ship_method_type_config'); + } + + /** + * @param Schema $schema + * @param QueryBag $queries + * @param string $newTableName + * @param string $oldTableName + */ + private function renameSequence(Schema $schema, QueryBag $queries, $oldTableName, $newTableName) + { + if ($this->platform->supportsSequences()) { + $primaryKey = $schema->getTable($newTableName)->getPrimaryKeyColumns(); + if (count($primaryKey) === 1) { + $primaryKey = reset($primaryKey); + $oldSequenceName = $this->platform->getIdentitySequenceName($oldTableName, $primaryKey); + if ($schema->hasSequence($oldSequenceName)) { + $newSequenceName = $this->platform->getIdentitySequenceName($newTableName, $primaryKey); + if ($this->platform instanceof PostgreSqlPlatform) { + $renameSequenceQuery = new SqlSchemaUpdateMigrationQuery( + "ALTER SEQUENCE $oldSequenceName RENAME TO $newSequenceName" + ); + $queries->addQuery($renameSequenceQuery); + } + } + } + } + } +} From fdf069447eb8116939fca01c475a7b64ed20a105 Mon Sep 17 00:00:00 2001 From: Vitalii Yeromenko Date: Tue, 17 Jan 2017 16:09:46 +0200 Subject: [PATCH 06/10] BB-7183: PayPal parameters - review fixes --- src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php | 3 ++- .../EventListener/ExtractLineItemPaymentOptionsListener.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php b/src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php index b5fbeb28294..006fc9654f5 100644 --- a/src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php +++ b/src/Oro/Bundle/PayPalBundle/Method/PayflowExpressCheckout.php @@ -132,7 +132,6 @@ protected function purchase(PaymentTransaction $paymentTransaction) { $options = array_merge( $this->getCredentials(), - $this->getAdditionalOptions(), $this->getSetExpressCheckoutOptions($paymentTransaction), $this->getShippingAddressOptions($paymentTransaction) ); @@ -194,6 +193,7 @@ protected function authorize(PaymentTransaction $paymentTransaction) { $options = array_merge( $paymentTransaction->getRequest(), + $this->getAdditionalOptions(), [Option\Transaction::TRXTYPE => Option\Transaction::AUTHORIZATION] ); @@ -208,6 +208,7 @@ protected function charge(PaymentTransaction $paymentTransaction) { $options = array_merge( $paymentTransaction->getRequest(), + $this->getAdditionalOptions(), [Option\Transaction::TRXTYPE => Option\Transaction::SALE] ); diff --git a/src/Oro/Bundle/TaxBundle/EventListener/ExtractLineItemPaymentOptionsListener.php b/src/Oro/Bundle/TaxBundle/EventListener/ExtractLineItemPaymentOptionsListener.php index efaf37b4c05..bf1edf1e763 100644 --- a/src/Oro/Bundle/TaxBundle/EventListener/ExtractLineItemPaymentOptionsListener.php +++ b/src/Oro/Bundle/TaxBundle/EventListener/ExtractLineItemPaymentOptionsListener.php @@ -42,7 +42,7 @@ public function onExtractLineItemPaymentOptions(ExtractLineItemPaymentOptionsEve return; } - if ((float)$taxAmount === 0.) { + if (abs((float)$taxAmount) <= 1e-6) { return; } From 405e69d8799775c908131e6156aa2f2a09926196 Mon Sep 17 00:00:00 2001 From: Vitalii Yeromenko Date: Tue, 17 Jan 2017 16:33:09 +0200 Subject: [PATCH 07/10] BB-7183: PayPal parameters - fixed unit test --- .../Tests/Unit/Method/PayflowExpressCheckoutTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowExpressCheckoutTest.php b/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowExpressCheckoutTest.php index 56ac461d875..a3f3317be8e 100644 --- a/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowExpressCheckoutTest.php +++ b/src/Oro/Bundle/PayPalBundle/Tests/Unit/Method/PayflowExpressCheckoutTest.php @@ -98,7 +98,13 @@ public function testExecute() $this->gateway->expects($this->any()) ->method('request') - ->with('S', ['ACTION' => 'S']) + ->with( + 'S', + array_merge( + ['ACTION' => 'S'], + $this->getAdditionalOptions() + ) + ) ->willReturn(new Response(['RESPMSG' => 'Approved', 'RESULT' => '0'])); $this->gateway->expects($this->exactly(1)) @@ -786,7 +792,7 @@ protected function getSurchargeOptions() protected function getLineItemOptionModel() { $lineItemModel = new LineItemOptionModel(); - + return $lineItemModel ->setName('Product Name') ->setDescription('Product Description') From f5d449451a2415c7d5ea9f7b9b08ab230f3f2796 Mon Sep 17 00:00:00 2001 From: Alexander Pobereznichenko Date: Tue, 17 Jan 2017 17:25:19 +0200 Subject: [PATCH 08/10] Fix account=>customer migrations --- .../Schema/v1_10/OroAccountBundle.php | 2 +- .../Schema/v1_10/OroAccountBundleStage2.php | 31 +++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php index 65815478d86..46eaefa3b0c 100644 --- a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php +++ b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundle.php @@ -918,7 +918,7 @@ private function renameCustomerUser(Schema $schema, QueryBag $queries) $table->removeForeignKey($fk); $extension->renameColumn($schema, $queries, $table, 'accountuser_id', 'customeruser_id'); } - if ($schema->hasTable('oro_rel_46a29d19a6adb604aeb863') && $schema->getTable('oro_rel_c3990ba6a6adb604193652') + if ($schema->hasTable('oro_rel_c3990ba6a6adb604193652') && $schema->getTable('oro_rel_c3990ba6a6adb604193652') ->hasColumn('accountuser_id') ) { $table = $schema->getTable('oro_rel_c3990ba6a6adb604193652'); diff --git a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php index 188a23a996d..097ce740dac 100644 --- a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php +++ b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php @@ -3,6 +3,7 @@ namespace Oro\Bundle\CustomerBundle\Migrations\Schema\v1_10; use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\Table; use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtension; use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtensionAwareInterface; use Oro\Bundle\MigrationBundle\Migration\Extension\RenameExtension; @@ -96,7 +97,9 @@ private function renameAccountUserRole(Schema $schema) ['onDelete' => 'CASCADE', 'onUpdate' => null] ); - if ($schema->hasTable("oro_rel_6f8f552a9df6f4d81e2432")) { + if ($schema->hasTable("oro_rel_6f8f552a9df6f4d81e2432") && + !$this->fkExists($schema->getTable("oro_rel_6f8f552a9df6f4d81e2432"), 'customeruserrole_id') + ) { $table = $schema->getTable("oro_rel_6f8f552a9df6f4d81e2432"); $table->addForeignKeyConstraint( $schema->getTable('oro_customer_user_role'), @@ -388,7 +391,9 @@ public function renameCustomerUser(Schema $schema) ['onDelete' => 'SET NULL', 'onUpdate' => null] ); - if ($schema->hasTable('oro_rel_46a29d19a6adb604aeb863')) { + if ($schema->hasTable('oro_rel_46a29d19a6adb604aeb863') && + !$this->fkExists($schema->getTable("oro_rel_46a29d19a6adb604aeb863"), 'customeruser_id') + ) { $schema->getTable('oro_rel_46a29d19a6adb604aeb863') ->addForeignKeyConstraint( $schema->getTable('oro_customer_user'), @@ -398,7 +403,9 @@ public function renameCustomerUser(Schema $schema) ); } - if ($schema->hasTable('oro_rel_c3990ba6a6adb604193652')) { + if ($schema->hasTable('oro_rel_c3990ba6a6adb604193652') && + !$this->fkExists($schema->getTable("oro_rel_c3990ba6a6adb604193652"), 'customeruser_id') + ) { $schema->getTable('oro_rel_c3990ba6a6adb604193652') ->addForeignKeyConstraint( $schema->getTable('oro_customer_user'), @@ -458,4 +465,22 @@ public function getOrder() { return 2; } + + /** + * @param Table $table + * @param $columnName + * + * @return bool + */ + protected function fkExists(Table $table, $columnName) + { + $foreignKeys = $table->getForeignKeys(); + foreach ($foreignKeys as $key) { + if ($key->getLocalColumns() === [$columnName]) { + return true; + } + } + + return false; + } } From de456cc761c5932e2259ce37dcbd1456e54093b4 Mon Sep 17 00:00:00 2001 From: Ilya Antipenko Date: Tue, 17 Jan 2017 17:55:22 +0200 Subject: [PATCH 09/10] BB-7189: Incorrect value of order statuses in orders datagrid for PP orders - add missed flush for PaymentStatus entity - update tests --- src/Oro/Bundle/PaymentBundle/Manager/PaymentStatusManager.php | 1 + .../Tests/Unit/Manager/PaymentStatusManagerTest.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Oro/Bundle/PaymentBundle/Manager/PaymentStatusManager.php b/src/Oro/Bundle/PaymentBundle/Manager/PaymentStatusManager.php index 707e54c84bd..03014baf755 100644 --- a/src/Oro/Bundle/PaymentBundle/Manager/PaymentStatusManager.php +++ b/src/Oro/Bundle/PaymentBundle/Manager/PaymentStatusManager.php @@ -66,5 +66,6 @@ public function updateStatus(PaymentTransaction $transaction) $paymentStatusEntity->setPaymentStatus($status); $em = $this->doctrineHelper->getEntityManager(PaymentStatus::class); $em->persist($paymentStatusEntity); + $em->flush($paymentStatusEntity); } } diff --git a/src/Oro/Bundle/PaymentBundle/Tests/Unit/Manager/PaymentStatusManagerTest.php b/src/Oro/Bundle/PaymentBundle/Tests/Unit/Manager/PaymentStatusManagerTest.php index 937991ea566..9093f83b776 100644 --- a/src/Oro/Bundle/PaymentBundle/Tests/Unit/Manager/PaymentStatusManagerTest.php +++ b/src/Oro/Bundle/PaymentBundle/Tests/Unit/Manager/PaymentStatusManagerTest.php @@ -136,7 +136,8 @@ protected function commonExpectations($entity) ->with(PaymentStatus::class) ->willReturn($emMock); - $emMock->expects($this->once())->method('persist'); + $emMock->expects($this->once())->method('persist')->with($this->isInstanceOf(PaymentStatus::class)); + $emMock->expects($this->once())->method('flush')->with($this->isInstanceOf(PaymentStatus::class)); return $repositoryMock; } From cbb5967996c66aa9501b3d78c28accc6305cc5f1 Mon Sep 17 00:00:00 2001 From: Alexander Pobereznichenko Date: Tue, 17 Jan 2017 18:33:45 +0200 Subject: [PATCH 10/10] Fix account=>customer migrations --- .../Migrations/Schema/v1_10/OroAccountBundleStage2.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php index 097ce740dac..3d99f682642 100644 --- a/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php +++ b/src/Oro/Bundle/CustomerBundle/Migrations/Schema/v1_10/OroAccountBundleStage2.php @@ -399,7 +399,7 @@ public function renameCustomerUser(Schema $schema) $schema->getTable('oro_customer_user'), ['customeruser_id'], ['id'], - ['onDelete' => 'SET NULL', 'onUpdate' => null] + ['onDelete' => 'CASCADE', 'onUpdate' => null] ); } @@ -411,7 +411,7 @@ public function renameCustomerUser(Schema $schema) $schema->getTable('oro_customer_user'), ['customeruser_id'], ['id'], - ['onDelete' => 'SET NULL', 'onUpdate' => null] + ['onDelete' => 'CASCADE', 'onUpdate' => null] ); } } @@ -476,7 +476,7 @@ protected function fkExists(Table $table, $columnName) { $foreignKeys = $table->getForeignKeys(); foreach ($foreignKeys as $key) { - if ($key->getLocalColumns() === [$columnName]) { + if ($key->getLocalColumns() == [$columnName]) { return true; } }