diff --git a/CHANGELOG.md b/CHANGELOG.md index 637dbe932e8..a47abd1d1fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG for 1.10.0 =================== This changelog references the relevant changes (new features, changes and bugs) done in 1.10.0 versions. - * The application has been upgraded to Symfony 2.8 + * The application has been upgraded to Symfony 2.8 (Symfony 2.8.10 doesn't supported because of [Symfony issue](https://github.com/symfony/symfony/issues/19840)) * Added support php 7 * Changed minimum required php version to 5.5.9 diff --git a/src/OroCRM/Bundle/AccountBundle/composer.json b/src/OroCRM/Bundle/AccountBundle/composer.json index b2601998d38..6c4c74da022 100644 --- a/src/OroCRM/Bundle/AccountBundle/composer.json +++ b/src/OroCRM/Bundle/AccountBundle/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "friendsofsymfony/rest-bundle": "1.5.0-RC2", "nelmio/api-doc-bundle": "dev-master", diff --git a/src/OroCRM/Bundle/ActivityContactBundle/composer.json b/src/OroCRM/Bundle/ActivityContactBundle/composer.json index 51c0035359a..2d38f1c6482 100644 --- a/src/OroCRM/Bundle/ActivityContactBundle/composer.json +++ b/src/OroCRM/Bundle/ActivityContactBundle/composer.json @@ -6,7 +6,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "oro/entity-extend-bundle": "dev-master", "oro/activity-bundle": "dev-master", "oro/activity-list-bundle": "dev-master" diff --git a/src/OroCRM/Bundle/AnalyticsBundle/composer.json b/src/OroCRM/Bundle/AnalyticsBundle/composer.json index f2825c44b4b..fba59264fa1 100644 --- a/src/OroCRM/Bundle/AnalyticsBundle/composer.json +++ b/src/OroCRM/Bundle/AnalyticsBundle/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "doctrine/orm": ">=2.3,<2.4-dev", "oro/entity-config-bundle": "dev-master", diff --git a/src/OroCRM/Bundle/CampaignBundle/EventListener/CampaignStatisticDatagridListener.php b/src/OroCRM/Bundle/CampaignBundle/EventListener/CampaignStatisticDatagridListener.php index 2a8fc1c3303..2fb4b47eb84 100644 --- a/src/OroCRM/Bundle/CampaignBundle/EventListener/CampaignStatisticDatagridListener.php +++ b/src/OroCRM/Bundle/CampaignBundle/EventListener/CampaignStatisticDatagridListener.php @@ -11,6 +11,7 @@ class CampaignStatisticDatagridListener { + /** @deprecated since 1.10. Use config->getName() instead */ const PATH_NAME = '[name]'; const PATH_DATAGRID_WHERE = '[source][query][where]'; @@ -44,9 +45,8 @@ public function onPreBuild(PreBuild $event) { $config = $event->getConfig(); $parameters = $event->getParameters(); - $gridName = $config->offsetGetByPath(self::PATH_NAME); - if (!$this->isApplicable($gridName, $parameters)) { + if (!$this->isApplicable($config->getName(), $parameters)) { return; } diff --git a/src/OroCRM/Bundle/CampaignBundle/EventListener/CampaignStatisticGroupingListener.php b/src/OroCRM/Bundle/CampaignBundle/EventListener/CampaignStatisticGroupingListener.php index 135a23e7b8c..1a662bd63fa 100644 --- a/src/OroCRM/Bundle/CampaignBundle/EventListener/CampaignStatisticGroupingListener.php +++ b/src/OroCRM/Bundle/CampaignBundle/EventListener/CampaignStatisticGroupingListener.php @@ -10,6 +10,7 @@ class CampaignStatisticGroupingListener { const PATH_GROUPBY = '[source][query][groupBy]'; + /** @deprecated since 1.10. Use config->getName() instead */ const PATH_NAME = '[name]'; const PATH_SELECT = '[source][query][select]'; @@ -45,9 +46,8 @@ public function onPreBuild(PreBuild $event) { $config = $event->getConfig(); $parameters = $event->getParameters(); - $gridName = $config->offsetGetByPath(self::PATH_NAME); - if (!$this->isApplicable($gridName, $parameters)) { + if (!$this->isApplicable($config->getName(), $parameters)) { return; } diff --git a/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/EventListener/CampaignStatisticDatagridListenerTest.php b/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/EventListener/CampaignStatisticDatagridListenerTest.php index cb3f204bffe..e4408c97d1c 100644 --- a/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/EventListener/CampaignStatisticDatagridListenerTest.php +++ b/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/EventListener/CampaignStatisticDatagridListenerTest.php @@ -157,7 +157,7 @@ protected function assertEntityFind($id, $entity) public function testOnPreBuildNotApplicable() { $gridName = ConfigurationProvider::GRID_PREFIX; - $config = DatagridConfiguration::create([]); + $config = DatagridConfiguration::createNamed('test_grid', []); $event = new PreBuild($config, new ParameterBag([])); diff --git a/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/EventListener/CampaignStatisticGroupingListenerTest.php b/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/EventListener/CampaignStatisticGroupingListenerTest.php index 8db1cdb41e8..cb218abf570 100644 --- a/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/EventListener/CampaignStatisticGroupingListenerTest.php +++ b/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/EventListener/CampaignStatisticGroupingListenerTest.php @@ -121,7 +121,7 @@ public function testOnPreBuild(array $select, $groupBy, $expected) public function testOnPreBuildNotApplicable() { $gridName = ConfigurationProvider::GRID_PREFIX; - $config = DatagridConfiguration::create([]); + $config = DatagridConfiguration::createNamed('test_grid', []); $event = new PreBuild($config, new ParameterBag([])); diff --git a/src/OroCRM/Bundle/CampaignBundle/composer.json b/src/OroCRM/Bundle/CampaignBundle/composer.json index 7edcb2b6f7a..7320c3ca813 100644 --- a/src/OroCRM/Bundle/CampaignBundle/composer.json +++ b/src/OroCRM/Bundle/CampaignBundle/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "oro/user-bundle": "dev-master", "oro/ui-bundle": "dev-master", "oro/dashboard-bundle": "dev-master", diff --git a/src/OroCRM/Bundle/CaseBundle/Entity/CaseMailboxProcessSettings.php b/src/OroCRM/Bundle/CaseBundle/Entity/CaseMailboxProcessSettings.php index 6716cb8d10c..ff341581b9b 100644 --- a/src/OroCRM/Bundle/CaseBundle/Entity/CaseMailboxProcessSettings.php +++ b/src/OroCRM/Bundle/CaseBundle/Entity/CaseMailboxProcessSettings.php @@ -6,16 +6,14 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; +use Oro\Bundle\EmailBundle\Entity\MailboxProcessSettings; use Oro\Bundle\UserBundle\Entity\User; use Oro\Bundle\TagBundle\Entity\Taggable; -use OroCRM\Bundle\CaseBundle\Model\ExtendCaseMailboxProcessSettings; /** * @ORM\Entity - * @Config */ -class CaseMailboxProcessSettings extends ExtendCaseMailboxProcessSettings implements Taggable +class CaseMailboxProcessSettings extends MailboxProcessSettings implements Taggable { /** * @var User diff --git a/src/OroCRM/Bundle/CaseBundle/Migrations/Schema/OroCRMCaseBundleInstaller.php b/src/OroCRM/Bundle/CaseBundle/Migrations/Schema/OroCRMCaseBundleInstaller.php index 026c610e339..b4d7b3668c5 100644 --- a/src/OroCRM/Bundle/CaseBundle/Migrations/Schema/OroCRMCaseBundleInstaller.php +++ b/src/OroCRM/Bundle/CaseBundle/Migrations/Schema/OroCRMCaseBundleInstaller.php @@ -42,7 +42,7 @@ class OroCRMCaseBundleInstaller implements */ public function getMigrationVersion() { - return 'v1_8'; + return 'v1_9'; } /** diff --git a/src/OroCRM/Bundle/CaseBundle/Migrations/Schema/v1_9/OroCRMCaseBundle.php b/src/OroCRM/Bundle/CaseBundle/Migrations/Schema/v1_9/OroCRMCaseBundle.php new file mode 100644 index 00000000000..7e9a3873f37 --- /dev/null +++ b/src/OroCRM/Bundle/CaseBundle/Migrations/Schema/v1_9/OroCRMCaseBundle.php @@ -0,0 +1,27 @@ +addPreQuery( + new ParametrizedSqlMigrationQuery( + 'DELETE FROM oro_entity_config WHERE class_name = :class_name', + [ + 'class_name' => 'OroCRM\Bundle\CaseBundle\Entity\CaseMailboxProcessSettings', + ] + ) + ); + } +} diff --git a/src/OroCRM/Bundle/CaseBundle/Model/ExtendCaseMailboxProcessSettings.php b/src/OroCRM/Bundle/CaseBundle/Model/ExtendCaseMailboxProcessSettings.php deleted file mode 100644 index 5d8bdc254c9..00000000000 --- a/src/OroCRM/Bundle/CaseBundle/Model/ExtendCaseMailboxProcessSettings.php +++ /dev/null @@ -1,19 +0,0 @@ -=5.5.9", - "symfony/symfony": "2.8.*" + "symfony/symfony": "2.8.*, !=2.8.10" }, "autoload": { "psr-0": { "OroCRM\\Bundle\\CaseBundle": "" } diff --git a/src/OroCRM/Bundle/ChannelBundle/Datagrid/ChannelLimitationExtension.php b/src/OroCRM/Bundle/ChannelBundle/Datagrid/ChannelLimitationExtension.php index b022f0d1d8d..a1c1059d28b 100644 --- a/src/OroCRM/Bundle/ChannelBundle/Datagrid/ChannelLimitationExtension.php +++ b/src/OroCRM/Bundle/ChannelBundle/Datagrid/ChannelLimitationExtension.php @@ -20,7 +20,8 @@ class ChannelLimitationExtension extends AbstractExtension */ public function isApplicable(DatagridConfiguration $config) { - return $config->getDatasourceType() == OrmDatasource::TYPE + return + $config->getDatasourceType() === OrmDatasource::TYPE && $this->getParameters()->get('channelIds', false); } diff --git a/src/OroCRM/Bundle/ChannelBundle/Resources/config/oro/api.yml b/src/OroCRM/Bundle/ChannelBundle/Resources/config/oro/api.yml new file mode 100644 index 00000000000..e23ba229f2c --- /dev/null +++ b/src/OroCRM/Bundle/ChannelBundle/Resources/config/oro/api.yml @@ -0,0 +1,19 @@ +oro_api: + entities: + OroCRM\Bundle\ChannelBundle\Entity\Channel: + actions: + create: false + update: false + delete: false + delete_list: false + fields: + id: ~ + name: ~ + active: + property_path: status + owner: + exclude: true + customerIdentity: + exclude: true + data: + exclude: true diff --git a/src/OroCRM/Bundle/ChannelBundle/composer.json b/src/OroCRM/Bundle/ChannelBundle/composer.json index 66724173259..e4080f2327a 100644 --- a/src/OroCRM/Bundle/ChannelBundle/composer.json +++ b/src/OroCRM/Bundle/ChannelBundle/composer.json @@ -6,7 +6,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "doctrine/orm": ">=2.3,<2.4-dev", "oro/ui-bundle": "dev-master" }, diff --git a/src/OroCRM/Bundle/ContactBundle/composer.json b/src/OroCRM/Bundle/ContactBundle/composer.json index 573d12649eb..1d3b5ae0588 100644 --- a/src/OroCRM/Bundle/ContactBundle/composer.json +++ b/src/OroCRM/Bundle/ContactBundle/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "friendsofsymfony/rest-bundle": "1.5.0-RC2", "nelmio/api-doc-bundle": "dev-master", diff --git a/src/OroCRM/Bundle/MagentoBundle/Controller/OrderController.php b/src/OroCRM/Bundle/MagentoBundle/Controller/OrderController.php index 3561b985441..723594e81bd 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Controller/OrderController.php +++ b/src/OroCRM/Bundle/MagentoBundle/Controller/OrderController.php @@ -128,8 +128,12 @@ public function actualizeAction(Order $order) ProcessorRegistry::TYPE_IMPORT => [ 'filters' => [ 'increment_id' => $order->getIncrementId() - ] + ], + 'complex_filters' => [ + 'updated_at-gt' => null, + 'updated_at-lte' => null ] + ] ] ); } catch (\LogicException $e) { diff --git a/src/OroCRM/Bundle/MagentoBundle/Provider/BatchFilterBag.php b/src/OroCRM/Bundle/MagentoBundle/Provider/BatchFilterBag.php index 6e6a21be694..afe9f8acc87 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Provider/BatchFilterBag.php +++ b/src/OroCRM/Bundle/MagentoBundle/Provider/BatchFilterBag.php @@ -232,4 +232,23 @@ public function merge(BatchFilterBag $bag) } } } + + /** + * Clear filters which have empty values + */ + public function resetFilterWithEmptyValue() + { + $filterTypes = [ + self::FILTER_TYPE_SIMPLE, + self::FILTER_TYPE_COMPLEX + ]; + + foreach ($filterTypes as $filterType) { + foreach ($this->filters[$filterType] as $filterName => $filterData) { + if (empty($filterData['value'])) { + $this->reset($filterType, $filterName); + } + } + } + } } diff --git a/src/OroCRM/Bundle/MagentoBundle/Provider/Iterator/AbstractBridgeIterator.php b/src/OroCRM/Bundle/MagentoBundle/Provider/Iterator/AbstractBridgeIterator.php index d4f4ab4f838..24ee4163283 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Provider/Iterator/AbstractBridgeIterator.php +++ b/src/OroCRM/Bundle/MagentoBundle/Provider/Iterator/AbstractBridgeIterator.php @@ -62,6 +62,8 @@ protected function applyFilter() $this->filter->merge($this->predefinedFilters); } + $this->filter->resetFilterWithEmptyValue(); + $this->logAppliedFilters($this->filter); } diff --git a/src/OroCRM/Bundle/MagentoBundle/Provider/Transport/SoapTransport.php b/src/OroCRM/Bundle/MagentoBundle/Provider/Transport/SoapTransport.php index 702ec3306b9..c45b5f4d553 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Provider/Transport/SoapTransport.php +++ b/src/OroCRM/Bundle/MagentoBundle/Provider/Transport/SoapTransport.php @@ -253,6 +253,23 @@ public function call($action, $params = []) return $result; } + /** + * {@inheritdoc} + */ + protected function makeNewAttempt($action, $params) + { + $this->logAttempt(); + sleep($this->getSleepBetweenAttempt()); + ++$this->attempted; + + // in case if we have WsiMode enabled we should convert object parameters to array to avoid + // not correct parameters during the next attempt call + return $this->call( + $action, + $this->isWsiMode ? (array)array_shift($params) : $params + ); + } + /** * {@inheritdoc} */ diff --git a/src/OroCRM/Bundle/MagentoBundle/Tests/Unit/Provider/BatchFilterBagTest.php b/src/OroCRM/Bundle/MagentoBundle/Tests/Unit/Provider/BatchFilterBagTest.php index baef8898425..321b5fa83ec 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Tests/Unit/Provider/BatchFilterBagTest.php +++ b/src/OroCRM/Bundle/MagentoBundle/Tests/Unit/Provider/BatchFilterBagTest.php @@ -151,6 +151,120 @@ public function testMerge() $this->assertSame($expected, $result); } + /** + * @param array $filters + * @param array $complexFilters + * @param array $expectedBeforeReset + * @param array $expectedAfterReset + * + * @dataProvider providerResetFilterWithEmptyValue + */ + public function testResetFilterWithEmptyValue($filters, $complexFilters, $expectedBeforeReset, $expectedAfterReset) + { + $bag = new BatchFilterBag($filters, $complexFilters); + $filters = $bag->getAppliedFilters(); + self::assertEquals($expectedBeforeReset, $filters); + + $bag->resetFilterWithEmptyValue(); + $filters = $bag->getAppliedFilters(); + self::assertEquals($expectedAfterReset, $filters); + } + + /** + * Data provider for testResetFilterWithEmptyValue + * + * @return array + */ + public function providerResetFilterWithEmptyValue() + { + return [ + 'all filters have empty value' => [ + 'filters' => [ + 'testField1' => null + ], + 'complexFilters' => [ + 'testFieldComplex' => null + ], + 'expectedBeforeReset' => [ + 'filters' => [ + 'filter' => [ + ['key' => 'testField1', 'value' => null] + ], + 'complex_filter' => [ + ['key' => 'testFieldComplex', 'value' => null] + ], + ] + ], + 'expectedAfterReset' => [ + 'filters' => [] + ] + ], + 'one filter with empty value' => [ + 'filters' => [ + 'testField1' => 'testValue1', + 'testField2' => null, + ], + 'complexFilters' => [ + 'testFieldComplex' => 'testValue1' + ], + 'expectedBeforeReset' => [ + 'filters' => [ + 'filter' => [ + ['key' => 'testField1', 'value' => 'testValue1'], + ['key' => 'testField2', 'value' => null] + ], + 'complex_filter' => [ + ['key' => 'testFieldComplex', 'value' => 'testValue1'] + ], + ] + ], + 'expectedAfterReset' => [ + 'filters' => [ + 'filter' => [ + ['key' => 'testField1', 'value' => 'testValue1'] + ], + 'complex_filter' => [ + ['key' => 'testFieldComplex', 'value' => 'testValue1'] + ], + ] + ] + ], + 'one complex_filter with empty value' => [ + 'filters' => [ + 'testField1' => 'testValue1', + 'testField2' => 'testValue2' + ], + 'complexFilters' => [ + 'testFieldComplex' => 'testValue1', + 'testFieldComplex2' => null + ], + 'expectedBeforeReset' => [ + 'filters' => [ + 'filter' => [ + ['key' => 'testField1', 'value' => 'testValue1'], + ['key' => 'testField2', 'value' => 'testValue2'] + ], + 'complex_filter' => [ + ['key' => 'testFieldComplex', 'value' => 'testValue1'], + ['key' => 'testFieldComplex2', 'value' => null] + ] + ], + ], + 'expectedAfterReset' => [ + 'filters' => [ + 'filter' => [ + ['key' => 'testField1', 'value' => 'testValue1'], + ['key' => 'testField2', 'value' => 'testValue2'] + ], + 'complex_filter' => [ + ['key' => 'testFieldComplex', 'value' => 'testValue1'] + ] + ] + ] + ] + ]; + } + /** * @param BatchFilterBag $bag * diff --git a/src/OroCRM/Bundle/MagentoBundle/composer.json b/src/OroCRM/Bundle/MagentoBundle/composer.json index 8471f4191fc..213a309b569 100644 --- a/src/OroCRM/Bundle/MagentoBundle/composer.json +++ b/src/OroCRM/Bundle/MagentoBundle/composer.json @@ -6,7 +6,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "doctrine/orm": ">=2.3,<2.4-dev", "oro/log": "dev-master", "oro/ui-bundle": "dev-master", diff --git a/src/OroCRM/Bundle/MarketingListBundle/Datagrid/ConfigurationProvider.php b/src/OroCRM/Bundle/MarketingListBundle/Datagrid/ConfigurationProvider.php index 20383d53018..cd40a111ee3 100644 --- a/src/OroCRM/Bundle/MarketingListBundle/Datagrid/ConfigurationProvider.php +++ b/src/OroCRM/Bundle/MarketingListBundle/Datagrid/ConfigurationProvider.php @@ -11,6 +11,7 @@ class ConfigurationProvider implements ConfigurationProviderInterface { const GRID_PREFIX = 'orocrm_marketing_list_items_grid_'; + /** @deprecated since 1.10. Use config->getName() instead */ const GRID_NAME_OFFSET = '[name]'; /** @@ -86,7 +87,7 @@ public function getConfiguration($gridName) $concreteGridConfiguration = $this->chainConfigurationProvider->getConfiguration($concreteGridName); // Reset configured name to current gridName for further usage in Listener and Extension - $concreteGridConfiguration->offsetSetByPath(self::GRID_NAME_OFFSET, $gridName); + $concreteGridConfiguration->setName($gridName); $this->configuration[$gridName] = $concreteGridConfiguration; } diff --git a/src/OroCRM/Bundle/MarketingListBundle/Datagrid/Extension/MarketingListExtension.php b/src/OroCRM/Bundle/MarketingListBundle/Datagrid/Extension/MarketingListExtension.php index dda36da5898..b6e02605215 100644 --- a/src/OroCRM/Bundle/MarketingListBundle/Datagrid/Extension/MarketingListExtension.php +++ b/src/OroCRM/Bundle/MarketingListBundle/Datagrid/Extension/MarketingListExtension.php @@ -18,6 +18,7 @@ */ class MarketingListExtension extends AbstractExtension { + /** @deprecated since 1.10. Use config->getName() instead */ const NAME_PATH = '[name]'; /** @@ -43,7 +44,7 @@ public function __construct(MarketingListHelper $marketingListHelper) */ public function isApplicable(DatagridConfiguration $config) { - $gridName = $config->offsetGetByPath(self::NAME_PATH); + $gridName = $config->getName(); if (!empty($this->appliedFor[$gridName])) { return false; @@ -105,7 +106,7 @@ public function visitDatasource(DatagridConfiguration $config, DatasourceInterfa $qb->andWhere($part); } - $gridName = $config->offsetGetByPath(self::NAME_PATH); + $gridName = $config->getName(); if ($addParameter) { $qb->setParameter( diff --git a/src/OroCRM/Bundle/MarketingListBundle/Tests/Unit/Datagrid/ConfigurationProviderTest.php b/src/OroCRM/Bundle/MarketingListBundle/Tests/Unit/Datagrid/ConfigurationProviderTest.php index e9473c191bd..8b7ba285874 100644 --- a/src/OroCRM/Bundle/MarketingListBundle/Tests/Unit/Datagrid/ConfigurationProviderTest.php +++ b/src/OroCRM/Bundle/MarketingListBundle/Tests/Unit/Datagrid/ConfigurationProviderTest.php @@ -246,8 +246,8 @@ protected function assertConfigurationGet($gridName, $actualGridName) ->disableOriginalConstructor() ->getMock(); $configuration->expects($this->once()) - ->method('offsetSetByPath') - ->with(ConfigurationProvider::GRID_NAME_OFFSET, $gridName); + ->method('setName') + ->with($gridName); $this->chainConfigurationProvider->expects($this->once()) ->method('getConfiguration') ->with($actualGridName) diff --git a/src/OroCRM/Bundle/MarketingListBundle/Tests/Unit/Datagrid/Extension/MarketingListExtensionTest.php b/src/OroCRM/Bundle/MarketingListBundle/Tests/Unit/Datagrid/Extension/MarketingListExtensionTest.php index f03b8ce77e8..b43eae37e79 100644 --- a/src/OroCRM/Bundle/MarketingListBundle/Tests/Unit/Datagrid/Extension/MarketingListExtensionTest.php +++ b/src/OroCRM/Bundle/MarketingListBundle/Tests/Unit/Datagrid/Extension/MarketingListExtensionTest.php @@ -46,8 +46,7 @@ public function testIsApplicableIncorrectDataSource() $config ->expects($this->once()) - ->method('offsetGetByPath') - ->with('[name]', null) + ->method('getName') ->will($this->returnValue('grid')); $this->assertFalse($this->extension->isApplicable($config)); @@ -68,8 +67,7 @@ public function testIsApplicableVisitTwice() $config ->expects($this->atLeastOnce()) - ->method('offsetGetByPath') - ->with('[name]', null) + ->method('getName') ->will($this->returnValue(ConfigurationProvider::GRID_PREFIX . '1')); $this->marketingListHelper->expects($this->any()) @@ -244,8 +242,7 @@ protected function assertIsApplicable($marketingListId, $marketingList, $gridNam $config ->expects($this->atLeastOnce()) - ->method('offsetGetByPath') - ->with('[name]', null) + ->method('getName') ->will($this->returnValue($gridName)); $this->marketingListHelper->expects($this->any()) diff --git a/src/OroCRM/Bundle/MarketingListBundle/composer.json b/src/OroCRM/Bundle/MarketingListBundle/composer.json index 90e53528328..efb0ae03e00 100644 --- a/src/OroCRM/Bundle/MarketingListBundle/composer.json +++ b/src/OroCRM/Bundle/MarketingListBundle/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "oro/user-bundle": "dev-master", "oro/segment-bundle": "dev-master", "oro/ui-bundle": "dev-master" diff --git a/src/OroCRM/Bundle/ReportBundle/composer.json b/src/OroCRM/Bundle/ReportBundle/composer.json index c2d053889d1..9e8030bf7d3 100644 --- a/src/OroCRM/Bundle/ReportBundle/composer.json +++ b/src/OroCRM/Bundle/ReportBundle/composer.json @@ -6,7 +6,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "oro/ui-bundle": "dev-master", "orocrm/account-bundle": "dev-master", diff --git a/src/OroCRM/Bundle/SalesBundle/Entity/Opportunity.php b/src/OroCRM/Bundle/SalesBundle/Entity/Opportunity.php index 8286e51e75d..60b4cf0e85e 100644 --- a/src/OroCRM/Bundle/SalesBundle/Entity/Opportunity.php +++ b/src/OroCRM/Bundle/SalesBundle/Entity/Opportunity.php @@ -822,4 +822,12 @@ public function setClosedAt(\DateTime $closedAt = null) { $this->closedAt = $closedAt; } + + /** + * @return \DateTime + */ + public function getClosedAt() + { + return $this->closedAt; + } } diff --git a/src/OroCRM/Bundle/SalesBundle/ImportExport/Strategy/B2bConfigurableAddOrReplaceStrategy.php b/src/OroCRM/Bundle/SalesBundle/ImportExport/Strategy/B2bConfigurableAddOrReplaceStrategy.php new file mode 100644 index 00000000000..3de5cd21448 --- /dev/null +++ b/src/OroCRM/Bundle/SalesBundle/ImportExport/Strategy/B2bConfigurableAddOrReplaceStrategy.php @@ -0,0 +1,108 @@ +checkEmptyAddresses($entity); + + return $entity; + } + + /** + * {@inheritdoc} + */ + protected function afterProcessEntity($entity) + { + /** @var B2bCustomer $entity */ + $entity = parent::afterProcessEntity($entity); + $this->clearEmptyAddresses($entity); + + $this->guessRegion($entity->getBillingAddress()); + $this->guessRegion($entity->getShippingAddress()); + + return $entity; + } + + /** + * @param B2bCustomer $entity + */ + protected function checkEmptyAddresses(B2bCustomer $entity) + { + if (!$entity->getBillingAddress()) { + $this->isBillingAddress = false; + } + + if (!$entity->getShippingAddress()) { + $this->isShippingAddress = false; + } + } + + /** + * @param B2bCustomer $entity + */ + protected function clearEmptyAddresses(B2bCustomer $entity) + { + if (!$this->isBillingAddress) { + $entity->setBillingAddress(null); + } + + if (!$this->isShippingAddress) { + $entity->setShippingAddress(null); + } + } + + /** + * @param Address $address + */ + protected function guessRegion($address) + { + if ($address + && $address->getCountry() && $address->getRegionText() + && !$address->getRegion() + ) { + $region = $this->doctrineHelper + ->getEntityRepository('OroAddressBundle:Region') + ->findOneBy( + [ + 'country' => $address->getCountry(), + 'name' => $address->getRegionText() + ] + ); + if ($region) { + $address->setRegion($region); + $address->setRegionText(null); + } + } + } +} diff --git a/src/OroCRM/Bundle/SalesBundle/Migrations/Schema/v1_24/ConvertPhoneNumberInPhone.php b/src/OroCRM/Bundle/SalesBundle/Migrations/Schema/v1_24/ConvertPhoneNumberInPhone.php index 448b0820e40..33fe90953d3 100644 --- a/src/OroCRM/Bundle/SalesBundle/Migrations/Schema/v1_24/ConvertPhoneNumberInPhone.php +++ b/src/OroCRM/Bundle/SalesBundle/Migrations/Schema/v1_24/ConvertPhoneNumberInPhone.php @@ -31,7 +31,8 @@ public function getOrder() public function up(Schema $schema, QueryBag $queries) { $query = 'INSERT INTO orocrm_sales_lead_phone (owner_id, phone, is_primary) - SELECT orocrm_sales_lead.id, orocrm_sales_lead.phone_number, \'1\' FROM orocrm_sales_lead'; + SELECT orocrm_sales_lead.id, orocrm_sales_lead.phone_number, \'1\' FROM orocrm_sales_lead + WHERE orocrm_sales_lead.phone_number IS NOT NULL'; $queries->addPostQuery($query); } diff --git a/src/OroCRM/Bundle/SalesBundle/Resources/config/importexport.yml b/src/OroCRM/Bundle/SalesBundle/Resources/config/importexport.yml index bb69f31339d..070614199a0 100644 --- a/src/OroCRM/Bundle/SalesBundle/Resources/config/importexport.yml +++ b/src/OroCRM/Bundle/SalesBundle/Resources/config/importexport.yml @@ -89,6 +89,7 @@ services: parent: oro_importexport.strategy.configurable_add_or_replace orocrm_sales.importexport.strategy.b2bcustomer.add_or_replace: + class: OroCRM\Bundle\SalesBundle\ImportExport\Strategy\B2bConfigurableAddOrReplaceStrategy parent: oro_importexport.strategy.configurable_add_or_replace # Import processor diff --git a/src/OroCRM/Bundle/SalesBundle/Tests/Functional/Controller/LeadControllersTest.php b/src/OroCRM/Bundle/SalesBundle/Tests/Functional/Controller/LeadControllersTest.php index aed72cf261d..be14923c442 100644 --- a/src/OroCRM/Bundle/SalesBundle/Tests/Functional/Controller/LeadControllersTest.php +++ b/src/OroCRM/Bundle/SalesBundle/Tests/Functional/Controller/LeadControllersTest.php @@ -205,7 +205,9 @@ public function gridProvider() 'gridParameters' => [ 'gridName' => 'sales-lead-grid' ], - 'gridFilters' => [], + 'gridFilters' => [ + 'sales-lead-grid[_sort_by][name][value]' => 'ASC', + ], 'assert' => [ 'name' => 'Lead name', 'channelName' => LoadSalesBundleFixtures::CHANNEL_NAME, diff --git a/src/OroCRM/Bundle/SalesBundle/Tests/Functional/Fixture/LoadSalesBundleFixtures.php b/src/OroCRM/Bundle/SalesBundle/Tests/Functional/Fixture/LoadSalesBundleFixtures.php index 611b31eecc4..02cf43dbe5b 100644 --- a/src/OroCRM/Bundle/SalesBundle/Tests/Functional/Fixture/LoadSalesBundleFixtures.php +++ b/src/OroCRM/Bundle/SalesBundle/Tests/Functional/Fixture/LoadSalesBundleFixtures.php @@ -5,6 +5,8 @@ use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\Persistence\ObjectManager; +use Oro\Bundle\AddressBundle\Entity\Address; +use Oro\Bundle\AddressBundle\Entity\Country; use Oro\Bundle\UserBundle\Entity\User; use Oro\Bundle\OrganizationBundle\Entity\Organization; @@ -105,6 +107,8 @@ protected function createB2bCustomer() $customer->setName(self::CUSTOMER_NAME); $customer->setDataChannel($this->getReference('default_channel')); $customer->setOrganization($this->organization); + $customer->setBillingAddress($this->getBillingAddress()); + $customer->setShippingAddress($this->getShippingAddress()); $this->em->persist($customer); $this->em->flush(); @@ -244,4 +248,46 @@ protected function getUser() return $this->user; } + + /** + * @return Address + */ + protected function getBillingAddress() + { + $address = new Address(); + $address->setCountry($this->getCounty()); + $address->setStreet('1215 Caldwell Road'); + $address->setCity('Rochester'); + $address->setPostalCode('14608'); + $address->setRegionText('Arizona1'); + + return $address; + } + + /** + * @return Address + */ + protected function getShippingAddress() + { + $address = new Address(); + $address->setCountry($this->getCounty()); + $address->setStreet('1215 Caldwell Road'); + $address->setCity('Rochester'); + $address->setPostalCode('14608'); + $address->setRegionText('Arizona1'); + + return $address; + } + + /** + * @return Country + */ + protected function getCounty() + { + $country = $this->em->getRepository('OroAddressBundle:Country')->findOneBy([ + 'iso2Code'=>'US' + ]); + + return $country; + } } diff --git a/src/OroCRM/Bundle/SalesBundle/Tests/Functional/ImportExport/Strategy/B2bConfigurableAddOrReplaceStrategyTest.php b/src/OroCRM/Bundle/SalesBundle/Tests/Functional/ImportExport/Strategy/B2bConfigurableAddOrReplaceStrategyTest.php new file mode 100644 index 00000000000..8c8507cc4c5 --- /dev/null +++ b/src/OroCRM/Bundle/SalesBundle/Tests/Functional/ImportExport/Strategy/B2bConfigurableAddOrReplaceStrategyTest.php @@ -0,0 +1,255 @@ +initClient( + ['debug' => false], + array_merge($this->generateBasicAuthHeader(), array('HTTP_X-CSRF-Header' => 1)) + ); + $this->client->useHashNavigation(true); + + $this->loadFixtures( + [ + 'OroCRM\Bundle\SalesBundle\Tests\Functional\Fixture\LoadSalesBundleFixtures' + ] + ); + + $container = $this->getContainer(); + + $this->strategy = new B2bConfigurableAddOrReplaceStrategy( + $container->get('event_dispatcher'), + $container->get('oro_importexport.strategy.import.helper'), + $container->get('oro_importexport.field.field_helper'), + $container->get('oro_importexport.field.database_helper'), + $container->get('oro_entity.entity_class_name_provider'), + $container->get('translator'), + $container->get('oro_importexport.strategy.new_entities_helper'), + $container->get('oro_entity.doctrine_helper') + ); + + $this->stepExecution = new StepExecution('step', new JobExecution()); + $this->context = new StepExecutionProxyContext($this->stepExecution); + $this->strategy->setImportExportContext($this->context); + $this->strategy->setEntityName( + $container->getParameter('orocrm_sales.b2bcustomer.entity.class') + ); + } + + protected function tearDown() + { + unset($this->strategy, $this->context, $this->stepExecution); + } + + public function testUpdateAddress() + { + $address = new Address(); + $address->setStreet('Test1'); + $address->setCity('test_city'); + $country = new Country('US'); + $address->setCountry($country); + + $account = new Account(); + $account->setName('some account name'); + + $channel = new Channel(); + $channel->setName('b2b Channel'); + + $newB2bCustomer = new B2bCustomer(); + $newB2bCustomer->setName('b2bCustomer name'); + $newB2bCustomer->setShippingAddress($address); + $newB2bCustomer->setBillingAddress($address); + $newB2bCustomer->setAccount($account); + $newB2bCustomer->setDataChannel($channel); + + /** @var B2bCustomer $existedCustomer */ + $existedCustomer = $this->getReference('default_b2bcustomer'); + self::assertEquals('1215 Caldwell Road', $existedCustomer->getShippingAddress()->getStreet()); + $this->strategy->process($newB2bCustomer); + self::assertEquals('Test1', $existedCustomer->getShippingAddress()->getStreet()); + } + + public function testUpdateCustomerByEmptyAddress() + { + $account = new Account(); + $account->setName('some account name'); + + $channel = new Channel(); + $channel->setName('b2b Channel'); + + $newB2bCustomer = new B2bCustomer(); + $newB2bCustomer->setName('b2bCustomer name'); + $newB2bCustomer->setAccount($account); + $newB2bCustomer->setDataChannel($channel); + + /** @var B2bCustomer $existedCustomer */ + $existedCustomer = $this->getReference('default_b2bcustomer'); + self::assertEquals('1215 Caldwell Road', $existedCustomer->getShippingAddress()->getStreet()); + $this->strategy->process($newB2bCustomer); + self::assertNull($existedCustomer->getShippingAddress()); + } + + public function testUpdateRegionText() + { + $address = new Address(); + $address->setStreet('1215 Caldwell Road'); + $address->setCity('Rochester'); + $address->setPostalCode('14608'); + $country = new Country('US'); + $address->setCountry($country); + $address->setRegionText('test'); + + $account = new Account(); + $account->setName('some account name'); + + $channel = new Channel(); + $channel->setName('b2b Channel'); + + $newB2bCustomer = new B2bCustomer(); + $newB2bCustomer->setName('b2bCustomer name'); + $newB2bCustomer->setAccount($account); + $newB2bCustomer->setDataChannel($channel); + $newB2bCustomer->setBillingAddress($address); + $newB2bCustomer->setShippingAddress($address); + + $this->context->setValue('itemData', [ + 'shippingAddress' => ['regionText' => 'test'], + 'billingAddress' => ['regionText' => 'test'] + ]); + + /** @var B2bCustomer $existedCustomer */ + $existedCustomer = $this->getReference('default_b2bcustomer'); + self::assertEquals('Arizona1', $existedCustomer->getShippingAddress()->getRegionText()); + $this->strategy->process($newB2bCustomer); + self::assertEquals('test', $existedCustomer->getShippingAddress()->getRegionText()); + self::assertEquals('test', $existedCustomer->getBillingAddress()->getRegionText()); + } + + public function testConvertRegionTextToRegion() + { + $country = new Country('US'); + + $address = new Address(); + $address->setStreet('1215 Caldwell Road'); + $address->setCity('Rochester'); + $address->setPostalCode('14608'); + $address->setCountry($country); + $address->setRegionText('Arizona'); + + $account = new Account(); + $account->setName('some account name'); + + $channel = new Channel(); + $channel->setName('b2b Channel'); + + $newB2bCustomer = new B2bCustomer(); + $newB2bCustomer->setName('b2bCustomer name'); + $newB2bCustomer->setAccount($account); + $newB2bCustomer->setDataChannel($channel); + $newB2bCustomer->setBillingAddress($address); + $newB2bCustomer->setShippingAddress($address); + + $this->context->setValue('itemData', [ + 'shippingAddress' => ['regionText' => 'Arizona'], + 'billingAddress' => ['regionText' => 'Arizona'] + ]); + + /** @var B2bCustomer $existedCustomer */ + $existedCustomer = $this->getReference('default_b2bcustomer'); + self::assertEquals('Arizona1', $existedCustomer->getShippingAddress()->getRegionText()); + self::assertNull($existedCustomer->getShippingAddress()->getRegion()); + $this->strategy->process($newB2bCustomer); + self::assertNull($existedCustomer->getShippingAddress()->getRegionText()); + self::assertNull($existedCustomer->getBillingAddress()->getRegionText()); + + $exceptedRegion = $this->getContainer()->get('doctrine')->getRepository('OroAddressBundle:Region') + ->findOneBy( + [ + 'country' => $country, + 'name' => 'Arizona' + ] + ); + + self::assertEquals($exceptedRegion, $existedCustomer->getShippingAddress()->getRegion()); + } + + public function testNewB2bCustomerWithRegionText() + { + $country = new Country('US'); + + $address = new Address(); + $address->setStreet('1215 Caldwell Road'); + $address->setCity('Rochester'); + $address->setPostalCode('14608'); + $address->setCountry($country); + $address->setRegionText('Arizona'); + + $account = new Account(); + $account->setName('some account name 1'); + + $channel = new Channel(); + $channel->setName('b2b Channel'); + + $newB2bCustomer = new B2bCustomer(); + $newB2bCustomer->setName('b2bCustomer name1'); + $newB2bCustomer->setAccount($account); + $newB2bCustomer->setDataChannel($channel); + $newB2bCustomer->setBillingAddress($address); + $newB2bCustomer->setShippingAddress($address); + + $this->context->setValue('itemData', [ + 'shippingAddress' => ['regionText' => 'Arizona'], + 'billingAddress' => ['regionText' => 'Arizona'] + ]); + + /** @var B2bCustomer $existedCustomer */ + $entity = $this->strategy->process($newB2bCustomer); + self::assertNull($entity->getShippingAddress()->getRegionText()); + self::assertNull($entity->getBillingAddress()->getRegionText()); + + $exceptedRegion = $this->getContainer()->get('doctrine')->getRepository('OroAddressBundle:Region') + ->findOneBy( + [ + 'country' => $country, + 'name' => 'Arizona' + ] + ); + + self::assertEquals($exceptedRegion, $entity->getShippingAddress()->getRegion()); + self::assertNull($entity->getId()); + } +} diff --git a/src/OroCRM/Bundle/SalesBundle/composer.json b/src/OroCRM/Bundle/SalesBundle/composer.json index da591f77f1c..a9e7a86c6b5 100644 --- a/src/OroCRM/Bundle/SalesBundle/composer.json +++ b/src/OroCRM/Bundle/SalesBundle/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "oro/ui-bundle": "dev-master", "oro/dashboard-bundle": "dev-master" diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/composer.json b/src/OroCRM/Bundle/TestFrameworkBundle/composer.json index 744ecc57ea8..7fff0126672 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/composer.json +++ b/src/OroCRM/Bundle/TestFrameworkBundle/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/symfony": "2.8.*", + "symfony/symfony": "2.8.*, !=2.8.10", "oro/testframework-bundle" : "dev-master" }, "autoload": {