From 980cfe21c81380574bbdb7e7a6b1564b5226228c Mon Sep 17 00:00:00 2001 From: Ivan Klymenko Date: Fri, 14 Jun 2013 20:55:32 +0300 Subject: [PATCH 01/65] CRM-138: Upgrade Symfony to version 2.3 - removed usage of Symfony\Component\Form\Exception\FormException - refactored usage of Symfony\Component\Form\Util\PropertyPath - renamed FormInterface::bind to FormInterface::submit - removed usage of deprecated Form::getAttribute - removed usage of deprecated Form::getChildren, Form::hasChildren, Form::getClientData --- .../Tests/Unit/Form/Handler/AccountHandlerTest.php | 6 +++--- .../Controller/Api/Rest/ContactGroupController.php | 2 +- .../Tests/Unit/Form/Handler/ContactHandlerTest.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php index 653058b8a62..03b0f97bbca 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php @@ -61,7 +61,7 @@ public function testProcessUnsupportedRequest() ->with($this->entity); $this->form->expects($this->never()) - ->method('bind'); + ->method('submit'); $this->assertFalse($this->handler->process($this->entity)); } @@ -79,7 +79,7 @@ public function testProcessSupportedRequest($method) ->with($this->entity); $this->form->expects($this->once()) - ->method('bind') + ->method('submit') ->with($this->request); $this->assertFalse($this->handler->process($this->entity)); @@ -110,7 +110,7 @@ public function testProcessValidData() ->with($this->entity); $this->form->expects($this->once()) - ->method('bind') + ->method('submit') ->with($this->request); $this->form->expects($this->once()) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactGroupController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactGroupController.php index d2a5c8e9602..9da5b9f19a3 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactGroupController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactGroupController.php @@ -9,7 +9,7 @@ use Oro\Bundle\UserBundle\Annotation\Acl; use Oro\Bundle\UserBundle\Annotation\AclAncestor; -use Symfony\Component\Form\Tests\FormInterface; +use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Response; use FOS\RestBundle\Routing\ClassResourceInterface; use Oro\Bundle\SoapBundle\Form\Handler\ApiFormHandler; diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Handler/ContactHandlerTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Handler/ContactHandlerTest.php index f9941f081e8..b9d76a1b2d2 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Handler/ContactHandlerTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Handler/ContactHandlerTest.php @@ -59,7 +59,7 @@ public function testProcessUnsupportedRequest() ->with($this->entity); $this->form->expects($this->never()) - ->method('bind'); + ->method('submit'); $this->assertFalse($this->handler->process($this->entity)); } @@ -77,7 +77,7 @@ public function testProcessSupportedRequest($method) $this->request->setMethod($method); $this->form->expects($this->once()) - ->method('bind') + ->method('submit') ->with($this->request); $this->assertFalse($this->handler->process($this->entity)); @@ -108,7 +108,7 @@ public function testProcessValidData() ->with($this->entity); $this->form->expects($this->once()) - ->method('bind') + ->method('submit') ->with($this->request); $this->form->expects($this->once()) From 8d48da322ee8c42a0b5eff9642194a6c82355daf Mon Sep 17 00:00:00 2001 From: Ivan Klymenko Date: Tue, 18 Jun 2013 15:17:56 +0300 Subject: [PATCH 02/65] CRM-138: Upgrade Symfony to version 2.3 - renamed FormInterface::bind to FormInterface::submit --- src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php | 2 +- src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php | 2 +- src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php index 1b58dd34f70..20cff9da733 100644 --- a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php +++ b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php @@ -50,7 +50,7 @@ public function process(Account $entity) $this->form->setData($entity); if (in_array($this->request->getMethod(), array('POST', 'PUT'))) { - $this->form->bind($this->request); + $this->form->submit($this->request); if ($this->form->isValid()) { $appendContacts = $this->form->get('appendContacts')->getData(); diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php b/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php index 4c31e3dbc1a..0de4cfd5f2f 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php @@ -50,7 +50,7 @@ public function process(Contact $entity) $this->form->setData($entity); if (in_array($this->request->getMethod(), array('POST', 'PUT'))) { - $this->form->bind($this->request); + $this->form->submit($this->request); if ($this->form->isValid()) { $appendAccounts = $this->form->get('appendAccounts')->getData(); diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php b/src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php index 90102f6ebfa..c312c97cbb7 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php @@ -50,7 +50,7 @@ public function process(Group $entity) $this->form->setData($entity); if (in_array($this->request->getMethod(), array('POST', 'PUT'))) { - $this->form->bind($this->request); + $this->form->submit($this->request); if ($this->form->isValid()) { $appendContacts = $this->form->get('appendContacts')->getData(); From e742713dee3d79a9f26edfbd26eb2dc3365b91c6 Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Tue, 2 Jul 2013 16:52:04 +0300 Subject: [PATCH 03/65] CRM-222: Refactor AddressType entity - refactored address type entity - updated DB schema - updated data fixture - updated unit tests --- .../Controller/Api/Rest/ContactController.php | 2 +- .../ContactBundle/Entity/ContactAddress.php | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php index e8fe6614824..f24e3b27a0a 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php @@ -190,7 +190,7 @@ protected function fixRequestAttributes($entity) ? $this->getAddressTypeTransformer()->reverseTransform($address['type']) : null; if ($addressType) { - $address['type'] = $addressType->getId(); + $address['type'] = $addressType->getName(); } } unset($data['addresses']); diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php index 9f2cc10bc0e..56b68922e54 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php @@ -3,9 +3,11 @@ namespace OroCRM\Bundle\ContactBundle\Entity; use Doctrine\ORM\Mapping as ORM; -use Oro\Bundle\AddressBundle\Entity\TypedAddress; +use Doctrine\Common\Collections\ArrayCollection; use JMS\Serializer\Annotation\Exclude; +use Oro\Bundle\AddressBundle\Entity\TypedAddress; + /** * @ORM\Table("orocrm_contact_address") * @ORM\HasLifecycleCallbacks() @@ -19,10 +21,28 @@ class ContactAddress extends TypedAddress */ protected $owner; + /** + * @var ArrayCollection + * + * @ORM\ManyToMany(targetEntity="Oro\Bundle\AddressBundle\Entity\AddressType") + * @ORM\JoinTable( + * name="orocrm_contact_address_to_address_type", + * joinColumns={@ORM\JoinColumn(name="contact_address_id", referencedColumnName="id")}, + * inverseJoinColumns={@ORM\JoinColumn(name="type_name", referencedColumnName="name")} + * ) + * @Exclude + **/ + protected $types; + /** * @var \Oro\Bundle\FlexibleEntityBundle\Model\AbstractFlexibleValue[] * - * @ORM\OneToMany(targetEntity="Oro\Bundle\AddressBundle\Entity\Value\AddressValue", mappedBy="entity", cascade={"persist", "remove"}, orphanRemoval=true) + * @ORM\OneToMany( + * targetEntity="Oro\Bundle\AddressBundle\Entity\Value\AddressValue", + * mappedBy="entity", + * cascade={"persist", "remove"}, + * orphanRemoval=true + * ) * @Exclude */ protected $values; From cf7be5ee0c0934c13617586d08abbcd350a3702e Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Tue, 2 Jul 2013 18:49:13 +0300 Subject: [PATCH 04/65] CRM-222: Refactor AddressType entity - removed unused AddressTypeManager - updated unit tests - marked tests incomplete to fix in CRM-221 --- .../ContactBundle/Tests/Functional/API/RestContactApiTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php index 5a7dcdab0b2..7333464695b 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php @@ -53,6 +53,8 @@ protected function assertAddresses(array $actualAddresses) */ public function testCreateContact() { + $this->markTestIncomplete('Should be fixed in scope of CRM-221'); + $request = array( "contact" => array ( "attributes" => array( From 048cba8bf7c2096d8b552ffb9ecf74cc5c73316b Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Tue, 2 Jul 2013 19:40:28 +0300 Subject: [PATCH 05/65] CRM-221: Update form type for TypedAddress - updated Api/Rest/ContactController - updated Contact and ContactAddress entities - updated tests --- .../Controller/Api/Rest/ContactController.php | 38 ++++++++----------- .../Bundle/ContactBundle/Entity/Contact.php | 6 +-- .../ContactBundle/Entity/ContactAddress.php | 4 +- .../Functional/API/RestContactApiTest.php | 8 ++-- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php index f24e3b27a0a..6ac451a191d 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php @@ -2,23 +2,27 @@ namespace OroCRM\Bundle\ContactBundle\Controller\Api\Rest; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\HttpFoundation\Response; + use FOS\RestBundle\Controller\Annotations\NamePrefix; use FOS\RestBundle\Controller\Annotations\RouteResource; use FOS\RestBundle\Controller\Annotations\QueryParam; +use FOS\RestBundle\Routing\ClassResourceInterface; + use Nelmio\ApiDocBundle\Annotation\ApiDoc; + use Oro\Bundle\AddressBundle\Entity\AddressType; -use Oro\Bundle\AddressBundle\Form\DataTransformer\AddressTypeToTypeTransformer; +use Oro\Bundle\AddressBundle\Entity\TypedAddress; + use Oro\Bundle\UserBundle\Annotation\Acl; use Oro\Bundle\UserBundle\Annotation\AclAncestor; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\Response; -use FOS\RestBundle\Routing\ClassResourceInterface; use Oro\Bundle\SoapBundle\Form\Handler\ApiFormHandler; use Oro\Bundle\SoapBundle\Controller\Api\Rest\FlexibleRestController; use Oro\Bundle\SoapBundle\Entity\Manager\ApiFlexibleEntityManager; + use OroCRM\Bundle\ContactBundle\Entity\Contact; -use Oro\Bundle\AddressBundle\Entity\TypedAddress; /** * @RouteResource("contact") @@ -142,14 +146,6 @@ public function getFormHandler() return $this->get('orocrm_contact.form.handler.contact.api'); } - /** - * @return AddressTypeToTypeTransformer - */ - protected function getAddressTypeTransformer() - { - return $this->get('oro_address.typed.transformer'); - } - /** * {@inheritDoc} */ @@ -161,7 +157,12 @@ protected function getPreparedItem($entity) /** @var $address TypedAddress */ foreach ($entity->getMultiAddress() as $address) { $addressArray = parent::getPreparedItem($address); - $addressArray['type'] = $this->getAddressTypeTransformer()->transform($address->getType()); + $addressArray['types'] = array_map( + function (AddressType $addressType) { + return $addressType->getName(); + }, + $address->getTypes()->toArray() + ); $addressData[] = $addressArray; } @@ -184,15 +185,6 @@ protected function fixRequestAttributes($entity) $data = $request->get($requestVariable, array()); $data['multiAddress'] = !empty($data['addresses']) ? $data['addresses'] : array(); - foreach ($data['multiAddress'] as &$address) { - /** @var bool|AddressType $addressType */ - $addressType = isset($address['type']) - ? $this->getAddressTypeTransformer()->reverseTransform($address['type']) - : null; - if ($addressType) { - $address['type'] = $addressType->getName(); - } - } unset($data['addresses']); $request->set($requestVariable, $data); diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 8bb6933c927..dae26dca88a 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -32,7 +32,7 @@ class Contact extends AbstractEntityFlexible protected $id; /** - * @var Group[] + * @var Collection * * @ORM\ManyToMany(targetEntity="Group") * @ORM\JoinTable(name="orocrm_contact_to_contact_group", @@ -47,7 +47,7 @@ class Contact extends AbstractEntityFlexible /** * Accounts storage * - * @var ArrayCollection $accounts + * @var Collection * * @ORM\ManyToMany(targetEntity="OroCRM\Bundle\AccountBundle\Entity\Account", mappedBy="contacts") * @ORM\JoinTable(name="orocrm_contact_to_account") @@ -56,7 +56,7 @@ class Contact extends AbstractEntityFlexible protected $accounts; /** - * @var ArrayCollection $multiAddress + * @var Collection * @ORM\OneToMany(targetEntity="ContactAddress", mappedBy="owner", cascade={"all"}) * @ORM\OrderBy({"primary" = "DESC"}) * diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php index 56b68922e54..978b9884c49 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php @@ -3,7 +3,7 @@ namespace OroCRM\Bundle\ContactBundle\Entity; use Doctrine\ORM\Mapping as ORM; -use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use JMS\Serializer\Annotation\Exclude; use Oro\Bundle\AddressBundle\Entity\TypedAddress; @@ -22,7 +22,7 @@ class ContactAddress extends TypedAddress protected $owner; /** - * @var ArrayCollection + * @var Collection * * @ORM\ManyToMany(targetEntity="Oro\Bundle\AddressBundle\Entity\AddressType") * @ORM\JoinTable( diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php index 5a7dcdab0b2..865d558bb97 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php @@ -21,7 +21,7 @@ class RestContactApiTest extends WebTestCase * @var array */ protected $testAddress = array( - 'type' => 'shipping', + 'types' => array('shipping'), 'street' => 'contact_street', 'city' => 'contact_city', 'country' => 'US', @@ -42,7 +42,7 @@ protected function assertAddresses(array $actualAddresses) $this->assertCount(1, $actualAddresses); $address = current($actualAddresses); - foreach (array('type', 'street', 'city') as $key) { + foreach (array('types', 'street', 'city') as $key) { $this->assertArrayHasKey($key, $address); $this->assertEquals($this->testAddress[$key], $address[$key]); } @@ -117,10 +117,10 @@ public function testGetContact($request) */ public function testUpdateContact($contact, $request) { - $this->testAddress['type'] = 'billing'; + $this->testAddress['types'] = array('billing'); $request['contact']['attributes']['first_name'] .= "_Updated"; - $request['contact']['addresses'][0]['type'] = $this->testAddress['type']; + $request['contact']['addresses'][0]['types'] = $this->testAddress['types']; $request['contact']['addresses'][0]['primary'] = true; $this->client->request('PUT', 'http://localhost/api/rest/latest/contacts/' . $contact['id'], $request); From 9eabecd883e495ea51463daeef323847e8adabee Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Tue, 2 Jul 2013 20:42:00 +0300 Subject: [PATCH 06/65] CRM-221: Update form type for TypedAddress - updated Api/Rest/ContactController - added validation of address types of contact --- .../Controller/Api/Rest/ContactController.php | 7 +------ .../Bundle/ContactBundle/Resources/config/validation.yml | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php index 6ac451a191d..5af07a37d74 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php @@ -157,12 +157,7 @@ protected function getPreparedItem($entity) /** @var $address TypedAddress */ foreach ($entity->getMultiAddress() as $address) { $addressArray = parent::getPreparedItem($address); - $addressArray['types'] = array_map( - function (AddressType $addressType) { - return $addressType->getName(); - }, - $address->getTypes()->toArray() - ); + $addressArray['types'] = $address->getTypeNames(); $addressData[] = $addressArray; } diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml index 254b47caaea..000a32d0e56 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml @@ -11,4 +11,5 @@ OroCRM\Bundle\ContactBundle\Entity\Group: OroCRM\Bundle\ContactBundle\Entity\Contact: properties: multiAddress: - - Oro\Bundle\AddressBundle\Validator\Constraints\ContainsPrimary: ~ \ No newline at end of file + - Oro\Bundle\AddressBundle\Validator\Constraints\ContainsPrimary: ~ + - Oro\Bundle\AddressBundle\Validator\Constraints\UniqueAddressTypes: ~ From bd3ec3b387ee6e68419dbd885c88460fab084236 Mon Sep 17 00:00:00 2001 From: Aleksandr Smaga Date: Wed, 3 Jul 2013 14:22:52 +0200 Subject: [PATCH 07/65] BAP-1092: Ability to create tags for entities - Add taggable implementation --- .../Bundle/AccountBundle/Entity/Account.php | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php index 27c0271f6bf..6cd37600b43 100644 --- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php +++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; +use DoctrineExtensions\Taggable\Taggable; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Exclude; @@ -21,7 +22,7 @@ * @ORM\HasLifecycleCallbacks() * @Oro\Loggable */ -class Account extends AbstractEntityFlexible +class Account extends AbstractEntityFlexible implements Taggable { /** * @ORM\Id @@ -62,6 +63,11 @@ class Account extends AbstractEntityFlexible */ protected $values; + /** + * @var ArrayCollection $tags + */ + protected $tags; + public function __construct() { parent::__construct(); @@ -185,4 +191,36 @@ public function doPreUpdate() { $this->updated = new \DateTime('now', new \DateTimeZone('UTC')); } + + /** + * Return related tags + * + * @return ArrayCollection + */ + public function getTags() + { + $this->tags = $this->tags ?: new ArrayCollection(); + + return $this->tags; + } + + /** + * Return unique entity type identifier + * + * @return string + */ + public function getTaggableType() + { + return 'account'; + } + + /** + * Return unique record identifier + * + * @return mixed + */ + public function getTaggableId() + { + return $this->getId(); + } } From 44093d3472e6e1166c457e5971e8db64cb287603 Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Wed, 3 Jul 2013 15:30:31 +0300 Subject: [PATCH 08/65] CRM-221: Update form type for TypedAddress - updated Api/Rest/ContactController - updated Contact entity - updated ContactAddress entity - updated ContactAddressType - updated view.html.twig - updated tests --- .../ContactBundle/Controller/Api/Rest/ContactController.php | 4 ++-- src/OroCRM/Bundle/ContactBundle/Entity/Contact.php | 1 - src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php | 4 ++-- .../Bundle/ContactBundle/Form/Type/ContactAddressType.php | 4 ++-- .../ContactBundle/Resources/views/Contact/view.html.twig | 2 +- .../ContactBundle/Tests/Functional/API/RestContactApiTest.php | 2 -- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php index 5af07a37d74..f54f6489c0d 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php @@ -13,7 +13,6 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Oro\Bundle\AddressBundle\Entity\AddressType; -use Oro\Bundle\AddressBundle\Entity\TypedAddress; use Oro\Bundle\UserBundle\Annotation\Acl; use Oro\Bundle\UserBundle\Annotation\AclAncestor; @@ -23,6 +22,7 @@ use Oro\Bundle\SoapBundle\Entity\Manager\ApiFlexibleEntityManager; use OroCRM\Bundle\ContactBundle\Entity\Contact; +use OroCRM\Bundle\ContactBundle\Entity\ContactAddress; /** * @RouteResource("contact") @@ -154,7 +154,7 @@ protected function getPreparedItem($entity) // convert addresses to plain array $addressData = array(); /** @var $entity Contact */ - /** @var $address TypedAddress */ + /** @var ContactAddress $address */ foreach ($entity->getMultiAddress() as $address) { $addressArray = parent::getPreparedItem($address); $addressArray['types'] = $address->getTypeNames(); diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index dae26dca88a..07a9a61feca 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -13,7 +13,6 @@ use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible; -use Oro\Bundle\AddressBundle\Entity\TypedAddress; /** * @ORM\Entity(repositoryClass="Oro\Bundle\FlexibleEntityBundle\Entity\Repository\FlexibleEntityRepository") diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php index 978b9884c49..95a8c5e443a 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php @@ -6,14 +6,14 @@ use Doctrine\Common\Collections\Collection; use JMS\Serializer\Annotation\Exclude; -use Oro\Bundle\AddressBundle\Entity\TypedAddress; +use Oro\Bundle\AddressBundle\Entity\AbstractTypedAddress; /** * @ORM\Table("orocrm_contact_address") * @ORM\HasLifecycleCallbacks() * @ORM\Entity(repositoryClass="Oro\Bundle\AddressBundle\Entity\Repository\AddressRepository") */ -class ContactAddress extends TypedAddress +class ContactAddress extends AbstractTypedAddress { /** * @ORM\ManyToOne(targetEntity="Contact", inversedBy="multiAddress") diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactAddressType.php b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactAddressType.php index b010cad59a2..267871336ec 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactAddressType.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactAddressType.php @@ -2,9 +2,9 @@ namespace OroCRM\Bundle\ContactBundle\Form\Type; -use Oro\Bundle\AddressBundle\Form\Type\AddressTypedType; +use Oro\Bundle\AddressBundle\Form\Type\AbstractTypedAddressType; -class ContactAddressType extends AddressTypedType +class ContactAddressType extends AbstractTypedAddressType { /** * {@inheritdoc} diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig index bc34b6c8070..71a45bdf85c 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig @@ -48,7 +48,7 @@ {% set primaryData = attribute(addressValue, 'primary') %} {% set primaryData = yesNoChoices[primaryData]|default('No'|trans) %} {% set addresses = addresses|merge([ - addressView.renderAddressView(addressValue, [{'label': 'Type', 'data': 'type'}]), + addressView.renderAddressView(addressValue, [{'label': 'Types', 'value': addressValue.typeLabels|join(', ')}]), addressView.renderAddressView(addressValue, [{'label': 'Primary', 'value': primaryData}]), addressView.renderAddress(addressValue), '
' diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php index 362224c0c61..865d558bb97 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php @@ -53,8 +53,6 @@ protected function assertAddresses(array $actualAddresses) */ public function testCreateContact() { - $this->markTestIncomplete('Should be fixed in scope of CRM-221'); - $request = array( "contact" => array ( "attributes" => array( From 4adca5f1998361cd38a552729015d48a92d90a08 Mon Sep 17 00:00:00 2001 From: Ivan Shakuta Date: Wed, 3 Jul 2013 12:36:50 +0000 Subject: [PATCH 09/65] BAP-1092: Ability to create tags for entities - make contacts and accounts taggable --- .../Bundle/AccountBundle/Entity/Account.php | 8 ++-- .../Bundle/ContactBundle/Entity/Contact.php | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php index 6cd37600b43..4258eda2560 100644 --- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php +++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php @@ -211,15 +211,15 @@ public function getTags() */ public function getTaggableType() { - return 'account'; + return strtolower(__NAMESPACE__ . __CLASS__); } /** - * Return unique record identifier + * Returns the unique taggable resource identifier * - * @return mixed + * @return string */ - public function getTaggableId() + function getTaggableId() { return $this->getId(); } diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 8bb6933c927..85ded2b8ed3 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -80,6 +80,11 @@ class Contact extends AbstractEntityFlexible */ protected $nameFormat; + /** + * @var ArrayCollection + */ + private $tags; + public function __construct() { parent::__construct(); @@ -341,4 +346,36 @@ public function getAttributeData($attributeCode) return $value; } + + /** + * Returns the unique taggable resource type + * + * @return string + */ + function getTaggableType() + { + return strtolower(__NAMESPACE__ . __CLASS__); + } + + /** + * Returns the unique taggable resource identifier + * + * @return string + */ + function getTaggableId() + { + return $this->getId(); + } + + /** + * Returns the collection of tags for this Taggable entity + * + * @return Doctrine\Common\Collections\Collection + */ + function getTags() + { + $this->tags = $this->tags ?: new ArrayCollection(); + + return $this->tags; + } } From ae9c5cdc2c6a084fda2bc66b27c7920cb892ee0c Mon Sep 17 00:00:00 2001 From: Ivan Shakuta Date: Wed, 3 Jul 2013 12:55:09 +0000 Subject: [PATCH 10/65] BAP-1092: Ability to create tags for entities - fix methods --- src/OroCRM/Bundle/AccountBundle/Entity/Account.php | 2 +- src/OroCRM/Bundle/ContactBundle/Entity/Contact.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php index 4258eda2560..fd74d168188 100644 --- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php +++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php @@ -219,7 +219,7 @@ public function getTaggableType() * * @return string */ - function getTaggableId() + public function getTaggableId() { return $this->getId(); } diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 85ded2b8ed3..0d06d4564d4 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -352,7 +352,7 @@ public function getAttributeData($attributeCode) * * @return string */ - function getTaggableType() + public function getTaggableType() { return strtolower(__NAMESPACE__ . __CLASS__); } @@ -362,7 +362,7 @@ function getTaggableType() * * @return string */ - function getTaggableId() + public function getTaggableId() { return $this->getId(); } @@ -370,9 +370,9 @@ function getTaggableId() /** * Returns the collection of tags for this Taggable entity * - * @return Doctrine\Common\Collections\Collection + * @return ArrayCollection */ - function getTags() + public function getTags() { $this->tags = $this->tags ?: new ArrayCollection(); From cff24c7aa75f4628ced096e3ffb102a62ee8385c Mon Sep 17 00:00:00 2001 From: Ivan Shakuta Date: Wed, 3 Jul 2013 13:19:06 +0000 Subject: [PATCH 11/65] BAP-1067\nGlobal and Users Tags Management\n - fix taggable type definition --- src/OroCRM/Bundle/AccountBundle/Entity/Account.php | 2 +- src/OroCRM/Bundle/ContactBundle/Entity/Contact.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php index fd74d168188..d268a3ed27b 100644 --- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php +++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php @@ -211,7 +211,7 @@ public function getTags() */ public function getTaggableType() { - return strtolower(__NAMESPACE__ . __CLASS__); + return 'oro_'.strtolower(__CLASS__); } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 0d06d4564d4..1edfd30a07b 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -354,7 +354,7 @@ public function getAttributeData($attributeCode) */ public function getTaggableType() { - return strtolower(__NAMESPACE__ . __CLASS__); + return 'oro_'.strtolower(__CLASS__); } /** From f71a1c0835484912297b92ce88db82f4a44ba5d8 Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Wed, 3 Jul 2013 17:22:24 +0300 Subject: [PATCH 12/65] BAP-1102 Refactor REST API tests to use routes - removed hardcoded URLs - added generation routers for api --- .../Functional/API/RestAccountApiTest.php | 25 +++++++++-------- .../Functional/API/SoapAccountApiTest.php | 28 +++++++++---------- .../Functional/API/RestContactApiTest.php | 18 ++++++------ .../API/RestContactGroupsApiTest.php | 17 +++++------ .../Functional/API/SoapContactApiTest.php | 24 ++++++++-------- .../API/SoapContactGroupApiTest.php | 20 ++++++------- 6 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php index f79b6c074e3..2cef344bf8a 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php @@ -12,6 +12,7 @@ */ class RestAccountApiTest extends WebTestCase { + /** @var Client */ public $client = null; public function setUp() @@ -32,7 +33,7 @@ public function testCreateAccount() ) ) ); - $this->client->request('POST', 'http://localhost/api/rest/latest/account', $request); + $this->client->request('POST', $this->client->generate('oro_api_post_account'), $request); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 201); @@ -44,9 +45,9 @@ public function testCreateAccount() * @depends testCreateAccount * @return array */ - public function testGetContact($request) + public function testGetAccount($request) { - $this->client->request('GET', 'http://localhost/api/rest/latest/accounts'); + $this->client->request('GET', $this->client->generate('oro_api_get_accounts')); $result = $this->client->getResponse(); $result = json_decode($result->getContent(), true); $flag = 1; @@ -58,7 +59,7 @@ public function testGetContact($request) } $this->assertEquals(0, $flag); - $this->client->request('GET', 'http://localhost/api/rest/latest/accounts' . '/' . $account['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_account', array('id' => $account['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); @@ -68,16 +69,16 @@ public function testGetContact($request) /** * @param $account * @param $request - * @depends testGetContact + * @depends testGetAccount * @depends testCreateAccount */ - public function testUpdateContact($account, $request) + public function testUpdateAccount($account, $request) { $request['account']['attributes']['description'] .= "_Updated"; - $this->client->request('PUT', 'http://localhost/api/rest/latest/accounts' . '/' . $account['id'], $request); + $this->client->request('PUT', $this->client->generate('oro_api_put_account', array('id' => $account['id'])), $request); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); - $this->client->request('GET', 'http://localhost/api/rest/latest/accounts' . '/' . $account['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_account', array('id' => $account['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); $result = json_decode($result->getContent(), true); @@ -86,14 +87,14 @@ public function testUpdateContact($account, $request) /** * @param $contact - * @depends testGetContact + * @depends testGetAccount */ - public function testDeleteContact($contact) + public function testDeleteAccount($contact) { - $this->client->request('DELETE', 'http://localhost/api/rest/latest/accounts' . '/' . $contact['id']); + $this->client->request('DELETE', $this->client->generate('oro_api_delete_account', array('id' => $contact['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); - $this->client->request('GET', 'http://localhost/api/rest/latest/accounts' . '/' . $contact['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_account', array('id' => $contact['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 404); } diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php index 7350f8e2415..8afc4613716 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php @@ -12,15 +12,15 @@ */ class SoapAccountApiTest extends WebTestCase { - /** @var \SoapClient */ - protected $clientSoap = null; + /** @var Client */ + protected $client = null; public function setUp() { $this->markTestSkipped('BAP-717'); - $this->clientSoap = static::createClient(array(), ToolsAPI::generateWsseHeader()); + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); - $this->clientSoap->soap( + $this->client->soap( "http://localhost/api/soap", array( 'location' => 'http://localhost/api/soap', @@ -37,8 +37,8 @@ public function setUp() */ public function testCreateAccount($request, $response) { - $result = $this->clientSoap->soapClient->createAccount($request); - ToolsAPI::assertEqualsResponse($response, $result, $this->clientSoap->soapClient->__getLastResponse()); + $result = $this->client->soapClient->createAccount($request); + ToolsAPI::assertEqualsResponse($response, $result, $this->client->soapClient->__getLastResponse()); return $request; } @@ -51,7 +51,7 @@ public function testCreateAccount($request, $response) */ public function testGetAccounts($request) { - $accounts = $this->clientSoap->soapClient->getAccounts(1, 1000); + $accounts = $this->client->soapClient->getAccounts(1, 1000); $accounts = ToolsAPI::classToArray($accounts); $result = false; foreach ($accounts as $account) { @@ -72,7 +72,7 @@ public function testGetAccounts($request) */ public function testUpdateAccount($request, $response) { - $accounts = $this->clientSoap->soapClient->getAccounts(1, 1000); + $accounts = $this->client->soapClient->getAccounts(1, 1000); $accounts = ToolsAPI::classToArray($accounts); $result = false; foreach ($accounts as $account) { @@ -83,9 +83,9 @@ public function testUpdateAccount($request, $response) } } $request['attributes']['description'] .= '_Updated'; - $result = $this->clientSoap->soapClient->updateAccount($accountId, $request); + $result = $this->client->soapClient->updateAccount($accountId, $request); $this->assertTrue($result); - $account = $this->clientSoap->soapClient->getAccount($accountId); + $account = $this->client->soapClient->getAccount($accountId); $account = ToolsAPI::classToArray($account); $result = false; if ($account['attributes']['description'] == $request['attributes']['description']) { @@ -103,9 +103,9 @@ public function testUpdateAccount($request, $response) * @depends testUpdateAccount * @throws \Exception|\SoapFault */ - public function testDeleteContactGroup($request, $response) + public function testDeleteAccount($request, $response) { - $accounts = $this->clientSoap->soapClient->getAccounts(1, 1000); + $accounts = $this->client->soapClient->getAccounts(1, 1000); $accounts = ToolsAPI::classToArray($accounts); $result = false; foreach ($accounts as $account) { @@ -115,10 +115,10 @@ public function testDeleteContactGroup($request, $response) break; } } - $result = $this->clientSoap->soapClient->deleteAccount($accountId); + $result = $this->client->soapClient->deleteAccount($accountId); $this->assertTrue($result); try { - $this->clientSoap->soapClient->getAccount($accountId); + $this->client->soapClient->getAccount($accountId); } catch (\SoapFault $e) { if ($e->faultcode != 'NOT_FOUND') { throw $e; diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php index 5a7dcdab0b2..679338960d9 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php @@ -12,9 +12,7 @@ */ class RestContactApiTest extends WebTestCase { - /** - * @var Client - */ + /** @var Client */ public $client = null; /** @@ -64,7 +62,7 @@ public function testCreateContact() "addresses" => array($this->testAddress) ) ); - $this->client->request('POST', 'http://localhost/api/rest/latest/contact', $request); + $this->client->request('POST', $this->client->generate('oro_api_post_contact'), $request); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 201); @@ -82,7 +80,7 @@ public function testCreateContact() */ public function testGetContact($request) { - $this->client->request('GET', 'http://localhost/api/rest/latest/contacts'); + $this->client->request('GET', $this->client->generate('oro_api_get_contacts')); $result = $this->client->getResponse(); $entities = json_decode($result->getContent(), true); $this->assertNotEmpty($entities); @@ -96,7 +94,7 @@ public function testGetContact($request) } $this->assertNotNull($requiredContact); - $this->client->request('GET', 'http://localhost/api/rest/latest/contacts/' . $requiredContact['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_contact', array('id' => $requiredContact['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); @@ -123,11 +121,11 @@ public function testUpdateContact($contact, $request) $request['contact']['addresses'][0]['type'] = $this->testAddress['type']; $request['contact']['addresses'][0]['primary'] = true; - $this->client->request('PUT', 'http://localhost/api/rest/latest/contacts/' . $contact['id'], $request); + $this->client->request('PUT', $this->client->generate('oro_api_put_contact', array('id' => $contact['id'])), $request); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); - $this->client->request('GET', 'http://localhost/api/rest/latest/contacts/' . $contact['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_contact', array('id' => $contact['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); @@ -148,11 +146,11 @@ public function testUpdateContact($contact, $request) */ public function testDeleteContact($contact) { - $this->client->request('DELETE', 'http://localhost/api/rest/latest/contacts' . '/' . $contact['id']); + $this->client->request('DELETE', $this->client->generate('oro_api_delete_contact', array('id' => $contact['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); - $this->client->request('GET', 'http://localhost/api/rest/latest/contacts' . '/' . $contact['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_contact', array('id' => $contact['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 404); } diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php index 375a2f52ef7..6a214430de3 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php @@ -12,7 +12,8 @@ */ class RestContactGroupsApiTest extends WebTestCase { - public $client = null; + /** @var Client */ + protected $client = null; public function setUp() { @@ -29,7 +30,7 @@ public function testCreateContactGroup() "name" => 'Contact_Group_Name_' . mt_rand() ) ); - $this->client->request('POST', 'http://localhost/api/rest/latest/contactgroup', $request); + $this->client->request('POST', $this->client->generate('oro_api_post_contactgroup'), $request); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 201); @@ -43,7 +44,7 @@ public function testCreateContactGroup() */ public function testGetContactGroup($request) { - $this->client->request('GET', 'http://localhost/api/rest/latest/contactgroups'); + $this->client->request('GET', $this->client->generate('oro_api_get_contactgroups')); $result = $this->client->getResponse(); $result = json_decode($result->getContent(), true); $flag = 1; @@ -55,7 +56,7 @@ public function testGetContactGroup($request) } $this->assertEquals(0, $flag); - $this->client->request('GET', 'http://localhost/api/rest/latest/contactgroups' . '/' . $group['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_contactgroup', array('id' => $group['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); @@ -71,10 +72,10 @@ public function testGetContactGroup($request) public function testUpdateContactGroup($group, $request) { $group['name'] .= "_Updated"; - $this->client->request('PUT', 'http://localhost/api/rest/latest/contactgroups' . '/' . $group['id'], $request); + $this->client->request('PUT', $this->client->generate('oro_api_put_contactgroup', array('id' => $group['id'])), $request); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); - $this->client->request('GET', 'http://localhost/api/rest/latest/contactgroups' . '/' . $group['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_contactgroup', array('id' => $group['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); $result = json_decode($result->getContent(), true); @@ -87,10 +88,10 @@ public function testUpdateContactGroup($group, $request) */ public function testDeleteContact($group) { - $this->client->request('DELETE', 'http://localhost/api/rest/latest/contactgroups' . '/' . $group['id']); + $this->client->request('DELETE', $this->client->generate('oro_api_delete_contactgroup', array('id' => $group['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); - $this->client->request('GET', 'http://localhost/api/rest/latest/contactgroups' . '/' . $group['id']); + $this->client->request('GET', $this->client->generate('oro_api_get_contactgroup', array('id' => $group['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 404); } diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactApiTest.php index b858149cb59..57727e7e89a 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactApiTest.php @@ -12,15 +12,15 @@ */ class SoapContactApiTest extends WebTestCase { - /** @var \SoapClient */ - protected $clientSoap = null; + /** @var Client */ + protected $client = null; public function setUp() { $this->markTestSkipped('BAP-717'); - $this->clientSoap = static::createClient(array(), ToolsAPI::generateWsseHeader()); + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); - $this->clientSoap->soap( + $this->client->soap( "http://localhost/api/soap", array( 'location' => 'http://localhost/api/soap', @@ -36,9 +36,9 @@ public function setUp() */ public function testCreateContact($request, $response) { - $result = $this->clientSoap->soapClient->createContact($request); + $result = $this->client->soapClient->createContact($request); $result = ToolsAPI::classToArray($result); - ToolsAPI::assertEqualsResponse($response, $result, $this->clientSoap->soapClient->__getLastResponse()); + ToolsAPI::assertEqualsResponse($response, $result, $this->client->soapClient->__getLastResponse()); } /** @@ -49,7 +49,7 @@ public function testCreateContact($request, $response) */ public function testGetContacts($request) { - $contacts = $this->clientSoap->soapClient->getContacts(1, 1000); + $contacts = $this->client->soapClient->getContacts(1, 1000); $contacts = ToolsAPI::classToArray($contacts); $result = false; foreach ($contacts as $contact) { @@ -73,7 +73,7 @@ public function testGetContacts($request) */ public function testUpdateContact($request) { - $contacts = $this->clientSoap->soapClient->getContacts(1, 1000); + $contacts = $this->client->soapClient->getContacts(1, 1000); $contacts = ToolsAPI::classToArray($contacts); $result = false; foreach ($contacts as $contact) { @@ -86,9 +86,9 @@ public function testUpdateContact($request) } } $request['attributes']['description'] .= '_Updated'; - $result = $this->clientSoap->soapClient->updateContact($contactId, $request); + $result = $this->client->soapClient->updateContact($contactId, $request); $this->assertTrue($result); - $contact = $this->clientSoap->soapClient->getContactGroup($contactId); + $contact = $this->client->soapClient->getContactGroup($contactId); $contact = ToolsAPI::classToArray($contact); $result = false; if ($contact['attributes']['description'] == $request['attributes']['description']) { @@ -106,10 +106,10 @@ public function testUpdateContact($request) */ public function testDeleteContact($contactId) { - $result = $this->clientSoap->soapClient->deleteContact($contactId); + $result = $this->client->soapClient->deleteContact($contactId); $this->assertTrue($result); try { - $this->clientSoap->soapClient->getContact($contactId); + $this->client->soapClient->getContact($contactId); } catch (\SoapFault $e) { if ($e->faultcode != 'NOT_FOUND') { throw $e; diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php index 9b250d1e81e..26a20bc9a94 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php @@ -12,14 +12,14 @@ */ class SoapContactGroupApiTest extends WebTestCase { - /** @var \SoapClient */ - protected $clientSoap = null; + /** @var Client */ + protected $client = null; public function setUp() { - $this->clientSoap = static::createClient(array(), ToolsAPI::generateWsseHeader()); + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); - $this->clientSoap->soap( + $this->client->soap( "http://localhost/api/soap", array( 'location' => 'http://localhost/api/soap', @@ -36,7 +36,7 @@ public function testCreateContactGroup() $request = array( "name" => 'Group name_' . mt_rand() ); - $result = $this->clientSoap->soapClient->createContactGroup($request); + $result = $this->client->soapClient->createContactGroup($request); $this->assertTrue($result); return $request; @@ -49,7 +49,7 @@ public function testCreateContactGroup() */ public function testGetContactGroups($request) { - $groups = $this->clientSoap->soapClient->getContactGroups(1, 1000); + $groups = $this->client->soapClient->getContactGroups(1, 1000); $groups = ToolsAPI::classToArray($groups); $result = false; foreach ($groups as $group) { @@ -74,9 +74,9 @@ public function testGetContactGroups($request) public function testUpdateContact($request, $group) { $request['name'] .= '_Updated'; - $result = $this->clientSoap->soapClient->updateContactGroup($group['id'], $request); + $result = $this->client->soapClient->updateContactGroup($group['id'], $request); $this->assertTrue($result); - $group = $this->clientSoap->soapClient->getContactGroup($group['id']); + $group = $this->client->soapClient->getContactGroup($group['id']); $group = ToolsAPI::classToArray($group); $result = false; if ($group['name'] == $request['name']) { @@ -92,10 +92,10 @@ public function testUpdateContact($request, $group) */ public function testDeleteContactGroup($group) { - $result = $this->clientSoap->soapClient->deleteContactGroup($group['id']); + $result = $this->client->soapClient->deleteContactGroup($group['id']); $this->assertTrue($result); try { - $this->clientSoap->soapClient->getContactGroup($group['id']); + $this->client->soapClient->getContactGroup($group['id']); } catch (\SoapFault $e) { if ($e->faultcode != 'NOT_FOUND') { throw $e; From 3031c9687771eaa7e59a739345f4a1c4d7fd439c Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Wed, 3 Jul 2013 20:16:48 +0300 Subject: [PATCH 13/65] CRM-221: Update form type for TypedAddress - rename property multiAddress to addresses in Contact entity --- .../Controller/Api/Rest/ContactController.php | 6 +--- .../Datagrid/ContactDatagridManager.php | 4 +-- .../Bundle/ContactBundle/Entity/Contact.php | 34 +++++++++---------- .../ContactBundle/Entity/ContactAddress.php | 4 +-- .../ContactBundle/Form/Type/ContactType.php | 4 +-- .../Resources/config/validation.yml | 2 +- .../Resources/views/Contact/update.html.twig | 2 +- .../Resources/views/Contact/view.html.twig | 2 +- .../Tests/Unit/Entity/ContactTest.php | 22 ++++++------ .../Tests/Unit/Form/Type/ContactTypeTest.php | 2 +- .../Accounts/LoadCrmAccountsData.php | 2 +- 11 files changed, 40 insertions(+), 44 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php index f54f6489c0d..096233fc274 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php @@ -155,7 +155,7 @@ protected function getPreparedItem($entity) $addressData = array(); /** @var $entity Contact */ /** @var ContactAddress $address */ - foreach ($entity->getMultiAddress() as $address) { + foreach ($entity->getAddresses() as $address) { $addressArray = parent::getPreparedItem($address); $addressArray['types'] = $address->getTypeNames(); $addressData[] = $addressArray; @@ -163,7 +163,6 @@ protected function getPreparedItem($entity) $result = parent::getPreparedItem($entity); $result['addresses'] = $addressData; - unset($result['multiAddress']); return $result; } @@ -179,9 +178,6 @@ protected function fixRequestAttributes($entity) $request = $this->getRequest()->request; $data = $request->get($requestVariable, array()); - $data['multiAddress'] = !empty($data['addresses']) ? $data['addresses'] : array(); - unset($data['addresses']); - $request->set($requestVariable, $data); } } diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php index c38449bd222..f2e10dbe8a8 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php @@ -178,13 +178,13 @@ protected function applyJoinWithAddressAndCountry(ProxyQueryInterface $query) // need to translate countries $query->setQueryHint( Query::HINT_CUSTOM_OUTPUT_WALKER, - 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker' + 'Gedmo\Translatable\Query\TreeWalker\TranslationWalker' ); $entityAlias = $query->getRootAlias(); /** @var $query QueryBuilder */ - $query->leftJoin("$entityAlias.multiAddress", 'address', 'WITH', 'address.primary = 1') + $query->leftJoin("$entityAlias.addresses", 'address', 'WITH', 'address.primary = 1') ->leftJoin('address.country', 'country'); $query->addSelect('country.name as countryName', true); diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 07a9a61feca..4c65a33a2b4 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -56,12 +56,12 @@ class Contact extends AbstractEntityFlexible /** * @var Collection - * @ORM\OneToMany(targetEntity="ContactAddress", mappedBy="owner", cascade={"all"}) + * @ORM\OneToMany(targetEntity="ContactAddress", mappedBy="owner", cascade={"all"}, orphanRemoval=true) * @ORM\OrderBy({"primary" = "DESC"}) * * @Exclude */ - protected $multiAddress; + protected $addresses; /** * @var \Oro\Bundle\FlexibleEntityBundle\Model\AbstractFlexibleValue[] @@ -84,7 +84,7 @@ public function __construct() parent::__construct(); $this->groups = new ArrayCollection(); $this->accounts = new ArrayCollection(); - $this->multiAddress = new ArrayCollection(); + $this->addresses = new ArrayCollection(); } /** @@ -222,15 +222,15 @@ public function removeAccount(Account $account) /** * Set addresses * - * @param ContactAddress[] $addresses + * @param Collection|ContactAddress[] $addresses * @return Contact */ - public function setMultiAddress($addresses) + public function setAddresses($addresses) { - $this->multiAddress->clear(); + $this->addresses->clear(); foreach ($addresses as $address) { - $this->addMultiAddress($address); + $this->addAddress($address); } return $this; @@ -242,10 +242,10 @@ public function setMultiAddress($addresses) * @param ContactAddress $address * @return Contact */ - public function addMultiAddress(ContactAddress $address) + public function addAddress(ContactAddress $address) { - if (!$this->multiAddress->contains($address)) { - $this->multiAddress->add($address); + if (!$this->addresses->contains($address)) { + $this->addresses->add($address); $address->setOwner($this); } @@ -255,13 +255,13 @@ public function addMultiAddress(ContactAddress $address) /** * Remove address * - * @param mixed $address + * @param ContactAddress $address * @return Contact */ - public function removeMultiAddress($address) + public function removeAddress(ContactAddress $address) { - if ($this->multiAddress->contains($address)) { - $this->multiAddress->removeElement($address); + if ($this->addresses->contains($address)) { + $this->addresses->removeElement($address); } return $this; @@ -270,11 +270,11 @@ public function removeMultiAddress($address) /** * Get addresses * - * @return ContactAddress[] + * @return Collection */ - public function getMultiAddress() + public function getAddresses() { - return $this->multiAddress; + return $this->addresses; } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php index 95a8c5e443a..b4196877b1d 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php @@ -16,7 +16,7 @@ class ContactAddress extends AbstractTypedAddress { /** - * @ORM\ManyToOne(targetEntity="Contact", inversedBy="multiAddress") + * @ORM\ManyToOne(targetEntity="Contact", inversedBy="addresses") * @ORM\JoinColumn(name="owner_id", referencedColumnName="id") */ protected $owner; @@ -52,7 +52,7 @@ class ContactAddress extends AbstractTypedAddress * * @param Contact $owner */ - public function setOwner($owner) + public function setOwner(Contact $owner = null) { $this->owner = $owner; } diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php index 3ea65d2502c..191f011f2b7 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php @@ -38,7 +38,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->addEventSubscriber( - new AddressCollectionTypeSubscriber('multiAddress', $this->addressClass) + new AddressCollectionTypeSubscriber('addresses', $this->addressClass) ); } @@ -52,7 +52,7 @@ public function addEntityFields(FormBuilderInterface $builder) // Addresses $builder->add( - 'multiAddress', + 'addresses', 'oro_address_collection', array( 'required' => true, diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml index 000a32d0e56..0dc9f5f09b5 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml @@ -10,6 +10,6 @@ OroCRM\Bundle\ContactBundle\Entity\Group: OroCRM\Bundle\ContactBundle\Entity\Contact: properties: - multiAddress: + addresses: - Oro\Bundle\AddressBundle\Validator\Constraints\ContainsPrimary: ~ - Oro\Bundle\AddressBundle\Validator\Constraints\UniqueAddressTypes: ~ diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig index 3aad0b22f76..70e6153b640 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig @@ -74,7 +74,7 @@ { 'title': 'Addresses', 'data': [ - form_widget(form.multiAddress), + form_widget(form.addresses), ] }, ] diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig index 71a45bdf85c..e68cf21723d 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig @@ -44,7 +44,7 @@ {% set addresses = [] %} {% set yesNoChoices = {0: 'No'|trans, 1: 'Yes'|trans} %} - {% for addressValue in entity.multiAddress %} + {% for addressValue in entity.addresses %} {% set primaryData = attribute(addressValue, 'primary') %} {% set primaryData = yesNoChoices[primaryData]|default('No'|trans) %} {% set addresses = addresses|merge([ diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php index 993c242833d..d901e8a9386 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php @@ -53,7 +53,7 @@ public function testRemoveAccount() $this->assertEmpty($contact->getAccounts()->toArray()); } - public function testMultiAddress() + public function testAddresses() { $addressOne = new ContactAddress(); $addressOne->setCountry('US'); @@ -64,28 +64,28 @@ public function testMultiAddress() $addresses = array($addressOne, $addressTwo); $contact = new Contact(); - $this->assertSame($contact, $contact->setMultiAddress($addresses)); - $actual = $contact->getMultiAddress(); + $this->assertSame($contact, $contact->setAddresses($addresses)); + $actual = $contact->getAddresses(); $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $actual); $this->assertEquals($addresses, $actual->toArray()); - $this->assertSame($contact, $contact->addMultiAddress($addressTwo)); - $actual = $contact->getMultiAddress(); + $this->assertSame($contact, $contact->addAddress($addressTwo)); + $actual = $contact->getAddresses(); $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $actual); $this->assertEquals($addresses, $actual->toArray()); - $this->assertSame($contact, $contact->addMultiAddress($addressThree)); - $actual = $contact->getMultiAddress(); + $this->assertSame($contact, $contact->addAddress($addressThree)); + $actual = $contact->getAddresses(); $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $actual); $this->assertEquals(array($addressOne, $addressTwo, $addressThree), $actual->toArray()); - $this->assertSame($contact, $contact->removeMultiAddress($addressOne)); - $actual = $contact->getMultiAddress(); + $this->assertSame($contact, $contact->removeAddress($addressOne)); + $actual = $contact->getAddresses(); $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $actual); $this->assertEquals(array(1 => $addressTwo, 2 => $addressThree), $actual->toArray()); - $this->assertSame($contact, $contact->removeMultiAddress($addressOne)); - $actual = $contact->getMultiAddress(); + $this->assertSame($contact, $contact->removeAddress($addressOne)); + $actual = $contact->getAddresses(); $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $actual); $this->assertEquals(array(1 => $addressTwo, 2 => $addressThree), $actual->toArray()); } diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Type/ContactTypeTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Type/ContactTypeTest.php index 823e13e0ed9..8405edc6f90 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Type/ContactTypeTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Type/ContactTypeTest.php @@ -45,7 +45,7 @@ public function testAddEntityFields() $builder->expects($this->at(1)) ->method('add') - ->with('multiAddress', 'oro_address_collection') + ->with('addresses', 'oro_address_collection') ->will($this->returnSelf()); $builder->expects($this->at(2)) ->method('add') diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Accounts/LoadCrmAccountsData.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Accounts/LoadCrmAccountsData.php index 7b263aecd65..a0cb280542e 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Accounts/LoadCrmAccountsData.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Accounts/LoadCrmAccountsData.php @@ -279,7 +279,7 @@ function ($a) use ($idRegion) { $address->setState($region->first()); } - $contact->addMultiAddress($address); + $contact->addAddress($address); return $contact; } From d8a249f8d02779de3a836eafae3ad7a2c1a025c0 Mon Sep 17 00:00:00 2001 From: Michael Banin Date: Thu, 4 Jul 2013 13:03:07 +0300 Subject: [PATCH 14/65] CRM-173 Implement Selenium tests for Autocomplete functionality - Added CRUD tests for Contacts and Accounts --- .../Selenium/Accounts/CreateAccountTest.php | 93 ++++++++++++++++++ .../Selenium/Contacts/CreateContactTest.php | 94 +++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php create mode 100644 src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php new file mode 100644 index 00000000000..05b5f97feaa --- /dev/null +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php @@ -0,0 +1,93 @@ +setHost(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_HOST); + $this->setPort(intval(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PORT)); + $this->setBrowser(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM2_BROWSER); + $this->setBrowserUrl(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL); + } + + protected function tearDown() + { + $this->cookie()->clear(); + } + + /** + * @return string + */ + public function testCreateAccount() + { + $accountname = 'Account_'.mt_rand(); + + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openAccounts() + ->add() + ->setAccount_name($accountname) + ->save() + ->assertTitle('Accounts') + ->assertMessage('Account successfully saved'); + + return $accountname; + } + + /** + * @depends testCreateAccount + * @param $accountname + * @return string + */ + public function testUpdateAccount($accountname) + { + $newAccountname = 'Update_' . $accountname; + + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openAccounts() + ->filterBy('Name', $accountname) + ->open(array($accountname)) + ->edit() + ->assertTitle($accountname . ' - Accounts') + ->setAccount_name($newAccountname) + ->save() + ->assertTitle('Accounts') + ->assertMessage('Account successfully saved') + ->close(); + + return $newAccountname; + } + + /** + * @depends testUpdateContact + * @param $accountname + */ + public function testDeleteAccount($accountname) + { + $this->markTestSkipped('BAP-726'); + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openAccounts() + ->filterBy('Name', $accountname) + ->open(array($accountname)) + ->delete() + ->assertTitle('Accounts') + ->assertMessage('Item was deleted'); + + $login->openUsers()->filterBy('Name', $accountname)->assertNoDataMessage('No Accounts were found to match your search'); + } +} \ No newline at end of file diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php new file mode 100644 index 00000000000..f257c29b559 --- /dev/null +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php @@ -0,0 +1,94 @@ +setHost(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_HOST); + $this->setPort(intval(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PORT)); + $this->setBrowser(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM2_BROWSER); + $this->setBrowserUrl(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL); + } + + protected function tearDown() + { + $this->cookie()->clear(); + } + + /** + * @return string + */ + public function testCreateContact() + { + $contactname = 'Contact_'.mt_rand(); + + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openContacts() + ->add() + ->setFirst_name($contactname . '_first') + ->setLast_name($contactname . '_last') + ->setEmail($contactname . '@mail.com') + ->save() + ->assertTitle('Contacts') + ->assertMessage('Contact successfully saved'); + + return $contactname; + } + + /** + * @depends testCreateContact + * @param $contactname + * @return string + */ + public function testUpdateContact($contactname) + { + $newContactname = 'Update_' . $contactname; + + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openContacts() + ->filterBy('Email', $contactname . '@mail.com') + ->open(array($contactname)) + ->edit() + ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts') + ->setFirst_name($newContactname . '_first') + ->save() + ->assertTitle('Contacts') + ->assertMessage('Contact successfully saved') + ->close(); + + return $newContactname; + } + + /** + * @depends testUpdateContact + * @param $contactname + */ + public function testDeleteContact($contactname) + { + $this->markTestSkipped('BAP-726'); + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openContacts() + ->filterBy('Email', $contactname . 'mail.com') + ->open(array($contactname)) + ->delete() + ->assertTitle('Contacts') + ->assertMessage('Item was deleted'); + + $login->openUsers()->filterBy('Email', $contactname . 'mail.com')->assertNoDataMessage('No Contacts were found to match your search'); + } +} From b925cd8477e5661119a2db0322d90ac39e84588b Mon Sep 17 00:00:00 2001 From: Ivan Shakuta Date: Thu, 4 Jul 2013 10:07:14 +0000 Subject: [PATCH 15/65] BAP-1067\nGlobal and Users Tags Management\n - fix taggable type definition --- src/OroCRM/Bundle/AccountBundle/Entity/Account.php | 2 +- src/OroCRM/Bundle/ContactBundle/Entity/Contact.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php index d268a3ed27b..8be8bbeb76b 100644 --- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php +++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php @@ -211,7 +211,7 @@ public function getTags() */ public function getTaggableType() { - return 'oro_'.strtolower(__CLASS__); + return 'oro_account'; } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 1edfd30a07b..f3fab6c37c9 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -354,7 +354,7 @@ public function getAttributeData($attributeCode) */ public function getTaggableType() { - return 'oro_'.strtolower(__CLASS__); + return 'oro_contact'; } /** From 2bc67c697cf217068e21d817cdc6633d8dcbf7ec Mon Sep 17 00:00:00 2001 From: Aleksandr Smaga Date: Thu, 4 Jul 2013 15:51:57 +0200 Subject: [PATCH 16/65] BAP-1092: Ability to create tags for entities - Fix code style --- src/OroCRM/Bundle/AccountBundle/Entity/Account.php | 4 +++- src/OroCRM/Bundle/ContactBundle/Entity/Contact.php | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php index 8be8bbeb76b..2fbf0a129eb 100644 --- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php +++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php @@ -7,13 +7,15 @@ use Doctrine\Common\Collections\ArrayCollection; use DoctrineExtensions\Taggable\Taggable; + use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Exclude; use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; -use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible; use OroCRM\Bundle\ContactBundle\Entity\Contact; + +use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible; use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro; /** diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index f3fab6c37c9..c709865bf17 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -5,22 +5,23 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use OroCRM\Bundle\AccountBundle\Entity\Account; +use DoctrineExtensions\Taggable\Taggable; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Exclude; use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; +use OroCRM\Bundle\AccountBundle\Entity\Account; + use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible; -use Oro\Bundle\AddressBundle\Entity\TypedAddress; /** * @ORM\Entity(repositoryClass="Oro\Bundle\FlexibleEntityBundle\Entity\Repository\FlexibleEntityRepository") * @ORM\Table(name="orocrm_contact") * @ORM\HasLifecycleCallbacks() */ -class Contact extends AbstractEntityFlexible +class Contact extends AbstractEntityFlexible implements Taggable { /** * @ORM\Id From cc9af3eb486973918d1b10b514c38a1ff3ffe6cf Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Thu, 4 Jul 2013 17:10:30 +0300 Subject: [PATCH 17/65] CRM-225: Add API methods for getting contact addresses by type - fixed and added Soap\ComplexType annotation in Contact for groups and addresses - added new methods to Contact to get address by type and type name - added Soap\ComplexType annotation to ContactAddress - added getAddressByTypeNameAction to Api\Soap\ContactController - updated tests --- .../Controller/Api/Soap/ContactController.php | 15 +++++++ .../Bundle/ContactBundle/Entity/Contact.php | 43 ++++++++++++++++--- .../ContactBundle/Entity/ContactAddress.php | 2 + .../Tests/Unit/Entity/ContactTest.php | 28 +++++++++++- 4 files changed, 82 insertions(+), 6 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php index 4c1c0570811..80a6714dac5 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php @@ -9,6 +9,8 @@ use Oro\Bundle\SoapBundle\Entity\Manager\ApiFlexibleEntityManager; use Oro\Bundle\SoapBundle\Form\Handler\ApiFormHandler; +use OroCRM\Bundle\ContactBundle\Entity\Contact; + class ContactController extends FlexibleSoapController { /** @@ -32,6 +34,19 @@ public function getAction($id) return $this->handleGetRequest($id); } + /** + * @Soap\Method("getContactAddressByTypeName") + * @Soap\Param("id", phpType = "int") + * @Soap\Param("typeName", phpType = "string") + * @Soap\Result(phpType = "Oro\Bundle\AddressBundle\Entity\AddressType") + */ + public function getAddressByTypeNameAction($id, $typeName) + { + /** @var Contact $contact */ + $contact = $this->getEntity($id); + return $contact->getAddressByTypeName($typeName); + } + /** * @Soap\Method("createContact") * @Soap\Param("contact", phpType = "OroCRM\Bundle\ContactBundle\Entity\ContactSoap") diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 4c65a33a2b4..fd5a427f71c 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -12,6 +12,7 @@ use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; +use Oro\Bundle\AddressBundle\Entity\AddressType; use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible; /** @@ -38,7 +39,7 @@ class Contact extends AbstractEntityFlexible * joinColumns={@ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="CASCADE")}, * inverseJoinColumns={@ORM\JoinColumn(name="contact_group_id", referencedColumnName="id", onDelete="CASCADE")} * ) - * @Soap\ComplexType("int[]", nillable=true) + * @Soap\ComplexType("OroCRM\Bundle\ContactBundle\Entity\Group[]", nillable=true) * @Exclude */ protected $groups; @@ -58,7 +59,7 @@ class Contact extends AbstractEntityFlexible * @var Collection * @ORM\OneToMany(targetEntity="ContactAddress", mappedBy="owner", cascade={"all"}, orphanRemoval=true) * @ORM\OrderBy({"primary" = "DESC"}) - * + * @Soap\ComplexType("OroCRM\Bundle\ContactBundle\Entity\ContactAddress[]", nillable=true) * @Exclude */ protected $addresses; @@ -220,12 +221,14 @@ public function removeAccount(Account $account) } /** - * Set addresses + * Set addresses. + * + * This method could not be named setAddresses because of bug CRM-253. * * @param Collection|ContactAddress[] $addresses * @return Contact */ - public function setAddresses($addresses) + public function resetAddresses($addresses) { $this->addresses->clear(); @@ -270,13 +273,43 @@ public function removeAddress(ContactAddress $address) /** * Get addresses * - * @return Collection + * @return Collection|ContactAddress[] */ public function getAddresses() { return $this->addresses; } + /** + * Gets one address that has specified type. + * + * @param AddressType $type + * @return ContactAddress|null + */ + public function getAddressByType(AddressType $type) + { + return $this->getAddressByTypeName($type->getName()); + } + + /** + * Gets one address that has specified type name. + * + * @param string $typeName + * @return ContactAddress|null + */ + public function getAddressByTypeName($typeName) + { + $result = null; + + foreach ($this->getAddresses() as $address) { + if ($address->hasTypeWithName($typeName)) { + $result = $address; + break; + } + } + return $result; + } + /** * Get full name format. Defaults to "%first% %last%". * diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php index b4196877b1d..6c43d9d5eab 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php @@ -5,6 +5,7 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\Collection; use JMS\Serializer\Annotation\Exclude; +use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; use Oro\Bundle\AddressBundle\Entity\AbstractTypedAddress; @@ -30,6 +31,7 @@ class ContactAddress extends AbstractTypedAddress * joinColumns={@ORM\JoinColumn(name="contact_address_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="type_name", referencedColumnName="name")} * ) + * @Soap\ComplexType("Oro\Bundle\AddressBundle\Entity\AddressType[]", nillable=true) * @Exclude **/ protected $types; diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php index d901e8a9386..835ed8da7a9 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php @@ -5,6 +5,7 @@ use OroCRM\Bundle\ContactBundle\Entity\Contact; use OroCRM\Bundle\AccountBundle\Entity\Account; use OroCRM\Bundle\ContactBundle\Entity\ContactAddress; +use Oro\Bundle\AddressBundle\Entity\AddressType; class ContactTest extends \PHPUnit_Framework_TestCase { @@ -64,7 +65,7 @@ public function testAddresses() $addresses = array($addressOne, $addressTwo); $contact = new Contact(); - $this->assertSame($contact, $contact->setAddresses($addresses)); + $this->assertSame($contact, $contact->resetAddresses($addresses)); $actual = $contact->getAddresses(); $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $actual); $this->assertEquals($addresses, $actual->toArray()); @@ -90,6 +91,31 @@ public function testAddresses() $this->assertEquals(array(1 => $addressTwo, 2 => $addressThree), $actual->toArray()); } + public function testGetAddressByTypeName() + { + $contact = new Contact(); + $this->assertNull($contact->getAddressByTypeName('billing')); + + $address = new ContactAddress(); + $address->addType(new AddressType('billing')); + $contact->addAddress($address); + + $this->assertSame($address, $contact->getAddressByTypeName('billing')); + } + + public function testGetAddressByType() + { + $address = new ContactAddress(); + $addressType = new AddressType('billing'); + $address->addType($addressType); + + $contact = new Contact(); + $this->assertNull($contact->getAddressByType($addressType)); + + $contact->addAddress($address); + $this->assertSame($address, $contact->getAddressByType($addressType)); + } + public function testGetAttributeDataException() { $contact = new Contact(); From 0b561d104d405d0d320eb0600cf3179c3aaaddad Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Fri, 5 Jul 2013 14:38:14 +0300 Subject: [PATCH 18/65] CRM-225: Add API methods for getting contact addresses by type - added Api/Rest/AddressController to support getting contact address by type - updated Api/Rest/ContactController to get rid of property "owner" in REST API representation of contact - updated Api/Soap/ContactController to rais NOT_FOUND error when contact address with specified type doesn't exist - updated Soap annotatoins in Contact and ContactAddress entities - update routing files --- .../Controller/Api/Rest/AddressController.php | 92 +++++++++++++++++++ .../Controller/Api/Rest/ContactController.php | 3 + .../Controller/Api/Soap/ContactController.php | 10 +- .../Bundle/ContactBundle/Entity/Contact.php | 2 +- .../ContactBundle/Entity/ContactAddress.php | 2 +- .../Resources/config/routing.yml | 15 +-- .../Resources/config/routing_api.yml | 12 +++ 7 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/AddressController.php create mode 100644 src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/AddressController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/AddressController.php new file mode 100644 index 00000000000..b8fbc32b2de --- /dev/null +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/AddressController.php @@ -0,0 +1,92 @@ +getManager()->find($id); + + if ($contact) { + $address = $contact->getAddressByTypeName($typeName); + } else { + $address = null; + } + + $responseData = $address ? json_encode($this->getPreparedItem($address)) : ''; + + return new Response($responseData, $address ? Codes::HTTP_OK : Codes::HTTP_NOT_FOUND); + } + + /** + * {@inheritdoc} + */ + public function getManager() + { + return $this->get('orocrm_contact.contact.manager.api'); + } + + /** + * {@inheritdoc} + */ + public function getForm() + { + throw new \BadMethodCallException('Form is not available.'); + } + + /** + * {@inheritdoc} + */ + public function getFormHandler() + { + throw new \BadMethodCallException('FormHandler is not available.'); + } + + /** + * {@inheritDoc} + */ + protected function getPreparedItem($entity) + { + // convert addresses to plain array + $addressTypesData = array(); + + /** @var $entity ContactAddress */ + foreach ($entity->getTypes() as $addressType) { + $addressTypesData[] = parent::getPreparedItem($addressType); + } + + $result = parent::getPreparedItem($entity); + $result['types'] = $addressTypesData; + + unset($result['owner']); + + return $result; + } +} diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php index 096233fc274..66703317df2 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php @@ -158,6 +158,9 @@ protected function getPreparedItem($entity) foreach ($entity->getAddresses() as $address) { $addressArray = parent::getPreparedItem($address); $addressArray['types'] = $address->getTypeNames(); + + unset($addressArray['owner']); + $addressData[] = $addressArray; } diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php index 80a6714dac5..67ddbb33db4 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php @@ -38,13 +38,19 @@ public function getAction($id) * @Soap\Method("getContactAddressByTypeName") * @Soap\Param("id", phpType = "int") * @Soap\Param("typeName", phpType = "string") - * @Soap\Result(phpType = "Oro\Bundle\AddressBundle\Entity\AddressType") + * @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\ContactAddress") */ public function getAddressByTypeNameAction($id, $typeName) { /** @var Contact $contact */ $contact = $this->getEntity($id); - return $contact->getAddressByTypeName($typeName); + $address = $contact->getAddressByTypeName($typeName); + + if (!$address) { + throw new \SoapFault('NOT_FOUND', sprintf('Contact "%s" address can not be found', $typeName)); + } + + return $address; } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index fd5a427f71c..1079d785cd5 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -39,7 +39,7 @@ class Contact extends AbstractEntityFlexible * joinColumns={@ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="CASCADE")}, * inverseJoinColumns={@ORM\JoinColumn(name="contact_group_id", referencedColumnName="id", onDelete="CASCADE")} * ) - * @Soap\ComplexType("OroCRM\Bundle\ContactBundle\Entity\Group[]", nillable=true) + * @Soap\ComplexType("int[]", nillable=true) * @Exclude */ protected $groups; diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php index 6c43d9d5eab..cadd9941aaa 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php @@ -31,7 +31,7 @@ class ContactAddress extends AbstractTypedAddress * joinColumns={@ORM\JoinColumn(name="contact_address_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="type_name", referencedColumnName="name")} * ) - * @Soap\ComplexType("Oro\Bundle\AddressBundle\Entity\AddressType[]", nillable=true) + * @Soap\ComplexType("string[]", nillable=true) * @Exclude **/ protected $types; diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/routing.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing.yml index 49c9ba659f1..3429b3d8fed 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/routing.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing.yml @@ -3,16 +3,9 @@ orocrm_contact_bundle: type: annotation prefix: /contact -orocrm_contact_api: - resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactController.php" - type: rest - prefix: api/rest/{version}/ - defaults: - version: latest - -orocrm_contact_group_api: - resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactGroupController.php" - type: rest - prefix: api/rest/{version}/ +orocrm_contact_bundle_api: + resource: "@OroCRMContactBundle/Resources/config/routing_api.yml" + type: rest + prefix: api/rest/{version} defaults: version: latest diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml new file mode 100644 index 00000000000..2530b4d1985 --- /dev/null +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml @@ -0,0 +1,12 @@ +orocrm_contact_api: + resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactController.php" + type: rest + +orocrm_contact_group_api: + resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactGroupController.php" + type: rest + +orocrm_contact_address_api: + resource: "@OroCRMContactBundle/Controller/Api/Rest/AddressController.php" + type: rest + parent: orocrm_contact_api From cc54bc73ef71c4188f9cbb71866e52b79422dd37 Mon Sep 17 00:00:00 2001 From: Aleksandr Smaga Date: Fri, 5 Jul 2013 15:40:21 +0200 Subject: [PATCH 19/65] BAP-1103: Search entities by tags - Remove dependency on third party bundle --- src/OroCRM/Bundle/AccountBundle/Entity/Account.php | 13 +------------ src/OroCRM/Bundle/ContactBundle/Entity/Contact.php | 12 +----------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php index 2fbf0a129eb..ca8a8b97080 100644 --- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php +++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php @@ -6,8 +6,6 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; -use DoctrineExtensions\Taggable\Taggable; - use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Exclude; @@ -15,6 +13,7 @@ use OroCRM\Bundle\ContactBundle\Entity\Contact; +use Oro\Bundle\TagBundle\Entity\Taggable; use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible; use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro; @@ -206,16 +205,6 @@ public function getTags() return $this->tags; } - /** - * Return unique entity type identifier - * - * @return string - */ - public function getTaggableType() - { - return 'oro_account'; - } - /** * Returns the unique taggable resource identifier * diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index c709865bf17..c4094e98692 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -5,7 +5,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use DoctrineExtensions\Taggable\Taggable; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Exclude; @@ -14,6 +13,7 @@ use OroCRM\Bundle\AccountBundle\Entity\Account; +use Oro\Bundle\TagBundle\Entity\Taggable; use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible; /** @@ -348,16 +348,6 @@ public function getAttributeData($attributeCode) return $value; } - /** - * Returns the unique taggable resource type - * - * @return string - */ - public function getTaggableType() - { - return 'oro_contact'; - } - /** * Returns the unique taggable resource identifier * From f4b2001d0e18e00860729a5142fd9c0636a4ea4d Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Fri, 5 Jul 2013 19:25:27 +0300 Subject: [PATCH 20/65] CRM-225: Add API methods for getting contact addresses by type - renamed AddressController to ContactAddressController - added SOAP and REST methods to get primary contact address - add method to Contact to get primary address - updated tests --- ...oller.php => ContactAddressController.php} | 36 +++++++++++++++++-- .../Controller/Api/Soap/ContactController.php | 24 +++++++++++++ .../Bundle/ContactBundle/Entity/Contact.php | 20 +++++++++++ .../Resources/config/routing_api.yml | 2 +- .../Tests/Unit/Entity/ContactTest.php | 13 +++++++ 5 files changed, 92 insertions(+), 3 deletions(-) rename src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/{AddressController.php => ContactAddressController.php} (69%) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/AddressController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php similarity index 69% rename from src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/AddressController.php rename to src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php index b8fbc32b2de..b2db17e197d 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/AddressController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php @@ -4,6 +4,7 @@ use Symfony\Component\HttpFoundation\Response; +use FOS\RestBundle\Controller\Annotations\RouteResource; use FOS\RestBundle\Routing\ClassResourceInterface; use FOS\Rest\Util\Codes; @@ -14,10 +15,13 @@ use OroCRM\Bundle\ContactBundle\Entity\Contact; use OroCRM\Bundle\ContactBundle\Entity\ContactAddress; -class AddressController extends FlexibleRestController implements ClassResourceInterface +/** + * @RouteResource("address") + */ +class ContactAddressController extends FlexibleRestController implements ClassResourceInterface { /** - * REST GET item + * REST GET address by type * * @param string $id * @param string $typeName @@ -45,6 +49,34 @@ public function getAction($id, $typeName) return new Response($responseData, $address ? Codes::HTTP_OK : Codes::HTTP_NOT_FOUND); } + /** + * REST GET primary address + * + * @param string $id + * + * @ApiDoc( + * description="Get contact primary address", + * resource=true + * ) + * @AclAncestor("orocrm_contact_view") + * @return Response + */ + public function getPrimaryAction($id) + { + /** @var Contact $contact */ + $contact = $this->getManager()->find($id); + + if ($contact) { + $address = $contact->getPrimaryAddress(); + } else { + $address = null; + } + + $responseData = $address ? json_encode($this->getPreparedItem($address)) : ''; + + return new Response($responseData, $address ? Codes::HTTP_OK : Codes::HTTP_NOT_FOUND); + } + /** * {@inheritdoc} */ diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php index 67ddbb33db4..fb3d4105f64 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php @@ -5,6 +5,8 @@ use Symfony\Component\Form\FormInterface; use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; +use Oro\Bundle\UserBundle\Annotation\AclAncestor; + use Oro\Bundle\SoapBundle\Controller\Api\Soap\FlexibleSoapController; use Oro\Bundle\SoapBundle\Entity\Manager\ApiFlexibleEntityManager; use Oro\Bundle\SoapBundle\Form\Handler\ApiFormHandler; @@ -18,6 +20,7 @@ class ContactController extends FlexibleSoapController * @Soap\Param("page", phpType="int") * @Soap\Param("limit", phpType="int") * @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\Contact[]") + * @AclAncestor("orocrm_contact_list") */ public function cgetAction($page = 1, $limit = 10) { @@ -28,6 +31,7 @@ public function cgetAction($page = 1, $limit = 10) * @Soap\Method("getContact") * @Soap\Param("id", phpType = "int") * @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\Contact") + * @AclAncestor("orocrm_contact_view") */ public function getAction($id) { @@ -39,6 +43,7 @@ public function getAction($id) * @Soap\Param("id", phpType = "int") * @Soap\Param("typeName", phpType = "string") * @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\ContactAddress") + * @AclAncestor("orocrm_contact_view") */ public function getAddressByTypeNameAction($id, $typeName) { @@ -53,6 +58,25 @@ public function getAddressByTypeNameAction($id, $typeName) return $address; } + /** + * @Soap\Method("getContactPrimaryAddress") + * @Soap\Param("id", phpType = "int") + * @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\ContactAddress") + * @AclAncestor("orocrm_contact_view") + */ + public function getPrimaryAddressAction($id) + { + /** @var Contact $contact */ + $contact = $this->getEntity($id); + $address = $contact->getPrimaryAddress(); + + if (!$address) { + throw new \SoapFault('NOT_FOUND', sprintf('Contact has no primary address', $address)); + } + + return $address; + } + /** * @Soap\Method("createContact") * @Soap\Param("contact", phpType = "OroCRM\Bundle\ContactBundle\Entity\ContactSoap") diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 1079d785cd5..f09d7f4e3c2 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -280,6 +280,25 @@ public function getAddresses() return $this->addresses; } + /** + * Gets primary address if it's available. + * + * @return ContactAddress|null + */ + public function getPrimaryAddress() + { + $result = null; + + foreach ($this->getAddresses() as $address) { + if ($address->isPrimary()) { + $result = $address; + break; + } + } + + return $result; + } + /** * Gets one address that has specified type. * @@ -307,6 +326,7 @@ public function getAddressByTypeName($typeName) break; } } + return $result; } diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml index 2530b4d1985..47ac49de585 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml @@ -7,6 +7,6 @@ orocrm_contact_group_api: type: rest orocrm_contact_address_api: - resource: "@OroCRMContactBundle/Controller/Api/Rest/AddressController.php" + resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactAddressController.php" type: rest parent: orocrm_contact_api diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php index 835ed8da7a9..c785020e233 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php @@ -91,6 +91,19 @@ public function testAddresses() $this->assertEquals(array(1 => $addressTwo, 2 => $addressThree), $actual->toArray()); } + public function testGetPrimaryAddress() + { + $contact = new Contact(); + $this->assertNull($contact->getPrimaryAddress()); + + $address = new ContactAddress(); + $contact->addAddress($address); + $this->assertNull($contact->getPrimaryAddress()); + + $address->setPrimary(true); + $this->assertSame($address, $contact->getPrimaryAddress()); + } + public function testGetAddressByTypeName() { $contact = new Contact(); From 9e7e8e35e63526795f157d0387a5a4af698137ce Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Mon, 8 Jul 2013 14:26:48 +0300 Subject: [PATCH 21/65] CRM-219: Address Types Management - CR fixes --- .../Controller/Api/Rest/ContactAddressController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php index b2db17e197d..6e03222b1ca 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php @@ -4,6 +4,7 @@ use Symfony\Component\HttpFoundation\Response; +use FOS\RestBundle\Controller\Annotations\NamePrefix; use FOS\RestBundle\Controller\Annotations\RouteResource; use FOS\RestBundle\Routing\ClassResourceInterface; use FOS\Rest\Util\Codes; @@ -17,6 +18,7 @@ /** * @RouteResource("address") + * @NamePrefix("oro_api_") */ class ContactAddressController extends FlexibleRestController implements ClassResourceInterface { From b8bc35fec52d92c75f927923d8b7ca0ccb00abc9 Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Mon, 8 Jul 2013 15:09:21 +0300 Subject: [PATCH 22/65] CRM-219: Address Types Management - CR fixes --- .../ContactBundle/Controller/Api/Soap/ContactController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php index fb3d4105f64..51ea92fcbc1 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php @@ -52,7 +52,7 @@ public function getAddressByTypeNameAction($id, $typeName) $address = $contact->getAddressByTypeName($typeName); if (!$address) { - throw new \SoapFault('NOT_FOUND', sprintf('Contact "%s" address can not be found', $typeName)); + throw new \SoapFault('NOT_FOUND', sprintf('Contact address with type "%s" can\'t be found', $typeName)); } return $address; From 97ddf8844decd21b4f7230d31cd3bee894df89cc Mon Sep 17 00:00:00 2001 From: Michael Banin Date: Mon, 8 Jul 2013 18:25:11 +0300 Subject: [PATCH 23/65] CRM-173 Implement Selenium tests for Autocomplete functionality - Fixed CR added autocomplete tests --- .../Selenium/Accounts/CreateAccountTest.php | 29 ++++++++++++-- .../Selenium/Contacts/CreateContactTest.php | 39 ++++++++++++++++--- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php index 05b5f97feaa..1219b6536ce 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php @@ -35,7 +35,7 @@ public function testCreateAccount() ->submit() ->openAccounts() ->add() - ->setAccount_name($accountname) + ->setAccountName($accountname) ->save() ->assertTitle('Accounts') ->assertMessage('Account successfully saved'); @@ -43,6 +43,29 @@ public function testCreateAccount() return $accountname; } + /** + * @depends testCreateAccount + * @param $accountname + */ + public function testAccountAutocmplete($accountname) + { + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openAccounts() + ->add() + ->setAccountName($accountname . '_autocomplete_test') + ->setStreet('Street') + ->setCity('City') + ->setCountry('Kazak') + ->setState('Aqm') + ->setZipCode('Zip Code 000') + ->save() + ->assertTitle('Accounts') + ->assertMessage('Account successfully saved'); + } + /** * @depends testCreateAccount * @param $accountname @@ -61,7 +84,7 @@ public function testUpdateAccount($accountname) ->open(array($accountname)) ->edit() ->assertTitle($accountname . ' - Accounts') - ->setAccount_name($newAccountname) + ->setAccountName($newAccountname) ->save() ->assertTitle('Accounts') ->assertMessage('Account successfully saved') @@ -90,4 +113,4 @@ public function testDeleteAccount($accountname) $login->openUsers()->filterBy('Name', $accountname)->assertNoDataMessage('No Accounts were found to match your search'); } -} \ No newline at end of file +} diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php index f257c29b559..d135a17ef9e 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php @@ -34,8 +34,8 @@ public function testCreateContact() ->submit() ->openContacts() ->add() - ->setFirst_name($contactname . '_first') - ->setLast_name($contactname . '_last') + ->setFirstName($contactname . '_first') + ->setLastName($contactname . '_last') ->setEmail($contactname . '@mail.com') ->save() ->assertTitle('Contacts') @@ -44,6 +44,33 @@ public function testCreateContact() return $contactname; } + /** + * @depends testCreateContact + * @param $contactname + */ + public function testContactAutocmplete($contactname) + { + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openContacts() + ->add() + ->setFirstName($contactname . '_first_autocomplete') + ->setLastName($contactname . '_last_autocomplete') + ->setAssignedTo('admin') + ->setReportsTo($contactname) + ->setStreet('Street') + ->setCity('City') + ->setZipCode('Zip Code 000') + ->setCountry('Kazak') + ->setState('Aqm') + ->save() + ->assertTitle('Contacts') + ->assertMessage('Contact successfully saved') + ->close(); + } + /** * @depends testCreateContact * @param $contactname @@ -60,9 +87,9 @@ public function testUpdateContact($contactname) ->openContacts() ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) - ->edit() ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts') - ->setFirst_name($newContactname . '_first') + ->edit() + ->setFirstName($newContactname . '_first') ->save() ->assertTitle('Contacts') ->assertMessage('Contact successfully saved') @@ -83,12 +110,12 @@ public function testDeleteContact($contactname) ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) ->submit() ->openContacts() - ->filterBy('Email', $contactname . 'mail.com') + ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) ->delete() ->assertTitle('Contacts') ->assertMessage('Item was deleted'); - $login->openUsers()->filterBy('Email', $contactname . 'mail.com')->assertNoDataMessage('No Contacts were found to match your search'); + $login->openUsers()->filterBy('Email', $contactname . '@mail.com')->assertNoDataMessage('No Contacts were found to match your search'); } } From 1db24b8c6b2b63d0b26a7b95312bbd3ae4a8c9ba Mon Sep 17 00:00:00 2001 From: yurio Date: Tue, 9 Jul 2013 12:10:14 +0300 Subject: [PATCH 24/65] BAP-1041: OroAsseticBundle - Add OroAsseticBundle to CRM --- .../Bundle/AccountBundle/Resources/config/assets.yml | 7 ++++--- .../Bundle/ContactBundle/Resources/config/assets.yml | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml index 6000d9cb935..5beeadd951c 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml +++ b/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml @@ -1,4 +1,5 @@ js: - - '@OroUIBundle/Resources/public/lib/bootstrap/js/bootstrap-scrollspy.js' - - '@OroUIBundle/Resources/public/lib/backbone.bootstrap-modal.js' - - '@OroUIBundle/Resources/public/lib/jquery/select2.min.js' \ No newline at end of file + 'crm_accounts': + - '@OroUIBundle/Resources/public/lib/bootstrap/js/bootstrap-scrollspy.js' + - '@OroUIBundle/Resources/public/lib/backbone.bootstrap-modal.js' + - '@OroUIBundle/Resources/public/lib/jquery/select2.min.js' \ No newline at end of file diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml deleted file mode 100644 index 6000d9cb935..00000000000 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml +++ /dev/null @@ -1,4 +0,0 @@ -js: - - '@OroUIBundle/Resources/public/lib/bootstrap/js/bootstrap-scrollspy.js' - - '@OroUIBundle/Resources/public/lib/backbone.bootstrap-modal.js' - - '@OroUIBundle/Resources/public/lib/jquery/select2.min.js' \ No newline at end of file From 2c80271c7d9cb18fc3f0400d5aa9b64207ece94b Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Tue, 9 Jul 2013 12:42:44 +0300 Subject: [PATCH 25/65] CRM-233: Add state column and text filter - added region field to contact datagrid manager - updated contact datagrid translations --- .../Datagrid/ContactDatagridManager.php | 45 +++++++++++--- .../Resources/translations/datagrid.en.xliff | 62 ------------------- .../Resources/translations/datagrid.en.yml | 9 +++ 3 files changed, 45 insertions(+), 71 deletions(-) delete mode 100644 src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.xliff create mode 100644 src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php index f2e10dbe8a8..5b6758134f0 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php @@ -17,6 +17,14 @@ class ContactDatagridManager extends FlexibleDatagridManager { + /** + * Expression to get region text or label, CONCAT is used as type cast function + * + * @var string + */ + protected $regionExpression + = "CONCAT(CASE WHEN address.stateText IS NOT NULL THEN address.stateText ELSE region.name END, '')"; + /** * {@inheritDoc} */ @@ -40,7 +48,7 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) $fieldId->setOptions( array( 'type' => FieldDescriptionInterface::TYPE_INTEGER, - 'label' => $this->translate('ID'), + 'label' => $this->translate('orocrm.contact.datagrid.contact_id'), 'field_name' => 'id', 'filter_type' => FilterInterface::TYPE_NUMBER, 'show_column' => false @@ -58,7 +66,7 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) $fieldCountry->setOptions( array( 'type' => FieldDescriptionInterface::TYPE_TEXT, - 'label' => $this->translate('Country'), + 'label' => $this->translate('orocrm.contact.datagrid.country'), 'field_name' => 'countryName', 'expression' => 'address.country', 'filter_type' => FilterInterface::TYPE_ENTITY, @@ -79,12 +87,29 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) ); $fieldsCollection->add($fieldCountry); + $fieldRegion = new FieldDescription(); + $fieldRegion->setName('region'); + $fieldRegion->setOptions( + array( + 'type' => FieldDescriptionInterface::TYPE_TEXT, + 'label' => $this->translate('orocrm.contact.datagrid.region'), + 'field_name' => 'regionLabel', + 'expression' => $this->regionExpression, + 'filter_type' => FilterInterface::TYPE_STRING, + 'sortable' => true, + 'filterable' => true, + 'show_filter' => true, + 'filter_by_where' => true, + ) + ); + $fieldsCollection->add($fieldRegion); + $fieldCreated = new FieldDescription(); $fieldCreated->setName('created'); $fieldCreated->setOptions( array( 'type' => FieldDescriptionInterface::TYPE_DATETIME, - 'label' => $this->translate('Created At'), + 'label' => $this->translate('orocrm.contact.datagrid.created_at'), 'field_name' => 'created', 'filter_type' => FilterInterface::TYPE_DATETIME, 'sortable' => true, @@ -99,7 +124,7 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) $fieldUpdated->setOptions( array( 'type' => FieldDescriptionInterface::TYPE_DATETIME, - 'label' => $this->translate('Updated At'), + 'label' => $this->translate('orocrm.contact.datagrid.updated_at'), 'field_name' => 'updated', 'filter_type' => FilterInterface::TYPE_DATETIME, 'sortable' => true, @@ -120,7 +145,7 @@ protected function getRowActions() 'type' => ActionInterface::TYPE_REDIRECT, 'acl_resource' => 'orocrm_contact_view', 'options' => array( - 'label' => $this->translate('View'), + 'label' => $this->translate('orocrm.contact.datagrid.view'), 'link' => 'view_link', 'runOnRowClick' => true, ) @@ -131,7 +156,7 @@ protected function getRowActions() 'type' => ActionInterface::TYPE_REDIRECT, 'acl_resource' => 'orocrm_contact_view', 'options' => array( - 'label' => $this->translate('View'), + 'label' => $this->translate('orocrm.contact.datagrid.view'), 'icon' => 'user', 'link' => 'view_link', ) @@ -142,7 +167,7 @@ protected function getRowActions() 'type' => ActionInterface::TYPE_REDIRECT, 'acl_resource' => 'orocrm_contact_update', 'options' => array( - 'label' => $this->translate('Update'), + 'label' => $this->translate('orocrm.contact.datagrid.update'), 'icon' => 'edit', 'link' => 'update_link', ) @@ -153,7 +178,7 @@ protected function getRowActions() 'type' => ActionInterface::TYPE_DELETE, 'acl_resource' => 'orocrm_contact_delete', 'options' => array( - 'label' => $this->translate('Delete'), + 'label' => $this->translate('orocrm.contact.datagrid.delete'), 'icon' => 'trash', 'link' => 'delete_link', ) @@ -185,8 +210,10 @@ protected function applyJoinWithAddressAndCountry(ProxyQueryInterface $query) /** @var $query QueryBuilder */ $query->leftJoin("$entityAlias.addresses", 'address', 'WITH', 'address.primary = 1') - ->leftJoin('address.country', 'country'); + ->leftJoin('address.country', 'country') + ->leftJoin('address.state', 'region'); $query->addSelect('country.name as countryName', true); + $query->addSelect($this->regionExpression . ' AS regionLabel', true); } } diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.xliff b/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.xliff deleted file mode 100644 index 91049a64843..00000000000 --- a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.xliff +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - View - View - - - Update - Update - - - Delete - Delete - - - - - ID - ID - - - Created At - Created At - - - Updated At - Updated At - - - - - ID - ID - - - Name - Name - - - - - ID - ID - - - Has group - Has group - - - - - Assigned - Assigned - - - - - - diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml b/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml new file mode 100644 index 00000000000..84453ddc109 --- /dev/null +++ b/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml @@ -0,0 +1,9 @@ +orocrm.contact.datagrid.contact_id: ID +orocrm.contact.datagrid.country: Country +orocrm.contact.datagrid.region: State +orocrm.contact.datagrid.created_at: Created At +orocrm.contact.datagrid.updated_at: Updated At + +orocrm.contact.datagrid.view: View +orocrm.contact.datagrid.update: Update +orocrm.contact.datagrid.delete: Delete From 24779a39b73187e66e8bb0d686b11225c56a08bc Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Tue, 9 Jul 2013 12:59:06 +0300 Subject: [PATCH 26/65] CRM-173 Implement Selenium tests for Autocomplete functionality - CR changes --- .../AccountBundle/Tests/Functional/API/RestAccountApiTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php index 2cef344bf8a..b0c20328372 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php @@ -33,7 +33,7 @@ public function testCreateAccount() ) ) ); - $this->client->request('POST', $this->client->generate('oro_api_post_account'), $request); + $this->client->request('POST', $this->client->generate('oro_api_post_account'), $request); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 201); From 22aaff25c91aaf108e0f0d58411e6a2e414b1a0c Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Tue, 9 Jul 2013 14:22:02 +0300 Subject: [PATCH 27/65] CRM-232: Add columns and filters for contact group, lead source and primary postal code - changed filters show by default in Contacts grid - added groups and lead_source columns to Contacts grid - added method Contact::getGroupLabelsAsString and Contact::getGroupLabels - renamed Group property name to label - updated form types --- .../Datagrid/ContactDatagridManager.php | 49 ++++++++++++++++--- .../Bundle/ContactBundle/Entity/Contact.php | 27 ++++++++++ .../Bundle/ContactBundle/Entity/Group.php | 18 +++---- .../ContactBundle/Form/Type/ContactType.php | 2 +- .../ContactBundle/Form/Type/GroupType.php | 2 +- .../Resources/config/validation.yml | 4 +- .../Resources/translations/datagrid.en.yml | 1 + .../API/RestContactGroupsApiTest.php | 8 +-- .../API/SoapContactGroupApiTest.php | 8 +-- .../Tests/Unit/Entity/ContactTest.php | 25 ++++++++++ .../Tests/Unit/Entity/GroupTest.php | 33 +++++++++++++ 11 files changed, 149 insertions(+), 28 deletions(-) create mode 100644 src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/GroupTest.php diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php index 5b6758134f0..7b3336ea9c8 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php @@ -13,7 +13,9 @@ use Oro\Bundle\GridBundle\Filter\FilterInterface; use Oro\Bundle\GridBundle\Action\ActionInterface; use Oro\Bundle\GridBundle\Property\UrlProperty; +use Oro\Bundle\GridBundle\Property\FixedProperty; use Oro\Bundle\GridBundle\Datagrid\ProxyQueryInterface; +use Oro\Bundle\GridBundle\Sorter\SorterInterface; class ContactDatagridManager extends FlexibleDatagridManager { @@ -56,10 +58,36 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) ); $fieldsCollection->add($fieldId); - $this->configureFlexibleField($fieldsCollection, 'first_name'); - $this->configureFlexibleField($fieldsCollection, 'last_name'); - $this->configureFlexibleField($fieldsCollection, 'phone'); + $this->configureFlexibleField($fieldsCollection, 'first_name', array('show_filter' => true)); + $this->configureFlexibleField($fieldsCollection, 'last_name', array('show_filter' => true)); $this->configureFlexibleField($fieldsCollection, 'email', array('show_filter' => true)); + $this->configureFlexibleField($fieldsCollection, 'phone', array('show_filter' => true)); + + $rolesLabel = new FieldDescription(); + $rolesLabel->setName('groups'); + $rolesLabel->setProperty(new FixedProperty('groups', 'groupLabelsAsString')); + $rolesLabel->setOptions( + array( + 'type' => FieldDescriptionInterface::TYPE_TEXT, + 'label' => $this->translate('orocrm.contact.datagrid.groups'), + 'field_name' => 'groups', + 'expression' => 'contactGroup', + 'filter_type' => FilterInterface::TYPE_ENTITY, + 'sort_field_mapping' => array( + 'entityAlias' => 'contactGroup', + 'fieldName' => 'label', + ), + 'sortable' => true, + 'filterable' => true, + // entity filter options + 'class' => 'OroCRMContactBundle:Group', + 'property' => 'label', + 'filter_by_where' => true + ) + ); + $fieldsCollection->add($rolesLabel); + + $this->configureFlexibleField($fieldsCollection, 'lead_source'); $fieldCountry = new FieldDescription(); $fieldCountry->setName('country'); @@ -72,7 +100,6 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) 'filter_type' => FilterInterface::TYPE_ENTITY, 'sortable' => true, 'filterable' => true, - 'show_filter' => true, // entity filter options 'multiple' => true, 'class' => 'OroAddressBundle:Country', @@ -98,7 +125,6 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) 'filter_type' => FilterInterface::TYPE_STRING, 'sortable' => true, 'filterable' => true, - 'show_filter' => true, 'filter_by_where' => true, ) ); @@ -129,7 +155,6 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) 'filter_type' => FilterInterface::TYPE_DATETIME, 'sortable' => true, 'filterable' => true, - 'show_filter' => true, ) ); $fieldsCollection->add($fieldUpdated); @@ -209,11 +234,21 @@ protected function applyJoinWithAddressAndCountry(ProxyQueryInterface $query) $entityAlias = $query->getRootAlias(); /** @var $query QueryBuilder */ - $query->leftJoin("$entityAlias.addresses", 'address', 'WITH', 'address.primary = 1') + $query + ->leftJoin("$entityAlias.groups", 'contactGroup') + ->leftJoin("$entityAlias.addresses", 'address', 'WITH', 'address.primary = 1') ->leftJoin('address.country', 'country') ->leftJoin('address.state', 'region'); $query->addSelect('country.name as countryName', true); $query->addSelect($this->regionExpression . ' AS regionLabel', true); } + + protected function getDefaultSorters() + { + return array( + 'first_name' => SorterInterface::DIRECTION_ASC, + 'last_name' => SorterInterface::DIRECTION_ASC, + ); + } } diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index f09d7f4e3c2..c03f1fec598 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -138,6 +138,33 @@ public function doPreUpdate() $this->updated = new \DateTime('now', new \DateTimeZone('UTC')); } + /** + * Get group labels separated with comma. + * + * @return string + */ + public function getGroupLabelsAsString() + { + return implode(', ', $this->getGroupLabels()); + } + + /** + * Get list of group labels + * + * @return array + */ + public function getGroupLabels() + { + $result = array(); + + /** @var Group $group */ + foreach ($this->getGroups() as $group) { + $result[] = $group->getLabel(); + } + + return $result; + } + /** * Gets the groups related to contact * diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Group.php b/src/OroCRM/Bundle/ContactBundle/Entity/Group.php index 940692cbdbc..4b30a60f26a 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Group.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Group.php @@ -33,14 +33,14 @@ class Group * @Type("string") * @Oro\Versioned */ - protected $name; + protected $label; /** - * @param string $name [optional] Group name + * @param string|null $label [optional] Group name */ - public function __construct($name = '') + public function __construct($label = null) { - $this->name = $name; + $this->label = $label; } /** @@ -54,24 +54,24 @@ public function getId() /** * @return string */ - public function getName() + public function getLabel() { - return $this->name; + return $this->label; } /** * @param string $name * @return Group */ - public function setName($name) + public function setLabel($name) { - $this->name = $name; + $this->label = $name; return $this; } public function __toString() { - return (string)$this->getName(); + return (string)$this->getLabel(); } } diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php index 191f011f2b7..64a0eacb186 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php @@ -66,7 +66,7 @@ public function addEntityFields(FormBuilderInterface $builder) 'entity', array( 'class' => 'OroCRMContactBundle:Group', - 'property' => 'name', + 'property' => 'label', 'multiple' => true, 'expanded' => true, 'required' => false, diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Type/GroupType.php b/src/OroCRM/Bundle/ContactBundle/Form/Type/GroupType.php index 67391f0a8c7..a2a99be4779 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Type/GroupType.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Type/GroupType.php @@ -15,7 +15,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add( - 'name', + 'label', 'text', array( 'required' => true, diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml index 0dc9f5f09b5..9150c6eb1f5 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml @@ -1,8 +1,8 @@ OroCRM\Bundle\ContactBundle\Entity\Group: constraints: - - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: name + - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: label properties: - name: + label: - NotBlank: ~ - Length: min: 3 diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml b/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml index 84453ddc109..c513c1a04d1 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml @@ -1,3 +1,4 @@ +orocrm.contact.datagrid.groups: Groups orocrm.contact.datagrid.contact_id: ID orocrm.contact.datagrid.country: Country orocrm.contact.datagrid.region: State diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php index 6a214430de3..a1823b46c50 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php @@ -27,7 +27,7 @@ public function testCreateContactGroup() { $request = array( "contact_group" => array( - "name" => 'Contact_Group_Name_' . mt_rand() + "label" => 'Contact_Group_Name_' . mt_rand() ) ); $this->client->request('POST', $this->client->generate('oro_api_post_contactgroup'), $request); @@ -49,7 +49,7 @@ public function testGetContactGroup($request) $result = json_decode($result->getContent(), true); $flag = 1; foreach ($result as $group) { - if ($group['name'] == $request['contact_group']['name']) { + if ($group['label'] == $request['contact_group']['label']) { $flag = 0; break; } @@ -71,7 +71,7 @@ public function testGetContactGroup($request) */ public function testUpdateContactGroup($group, $request) { - $group['name'] .= "_Updated"; + $group['label'] .= "_Updated"; $this->client->request('PUT', $this->client->generate('oro_api_put_contactgroup', array('id' => $group['id'])), $request); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); @@ -79,7 +79,7 @@ public function testUpdateContactGroup($group, $request) $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); $result = json_decode($result->getContent(), true); - $this->assertEquals($request['contact_group']['name'], $result['name'], 'ContactGroup does not updated'); + $this->assertEquals($request['contact_group']['label'], $result['label'], 'ContactGroup does not updated'); } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php index 26a20bc9a94..3b76057c4cd 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php @@ -34,7 +34,7 @@ public function setUp() public function testCreateContactGroup() { $request = array( - "name" => 'Group name_' . mt_rand() + "label" => 'Group name_' . mt_rand() ); $result = $this->client->soapClient->createContactGroup($request); $this->assertTrue($result); @@ -54,7 +54,7 @@ public function testGetContactGroups($request) $result = false; foreach ($groups as $group) { foreach ($group as $groupDetails) { - $result = $groupDetails['name'] == $request['name']; + $result = $groupDetails['label'] == $request['label']; if ($result) { break; } @@ -73,13 +73,13 @@ public function testGetContactGroups($request) */ public function testUpdateContact($request, $group) { - $request['name'] .= '_Updated'; + $request['label'] .= '_Updated'; $result = $this->client->soapClient->updateContactGroup($group['id'], $request); $this->assertTrue($result); $group = $this->client->soapClient->getContactGroup($group['id']); $group = ToolsAPI::classToArray($group); $result = false; - if ($group['name'] == $request['name']) { + if ($group['label'] == $request['label']) { $result = true; } $this->assertTrue($result); diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php index c785020e233..d63e5106765 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/ContactTest.php @@ -3,6 +3,7 @@ namespace OroCRM\Bundle\ContactBundle\Tests\Unit\Entity; use OroCRM\Bundle\ContactBundle\Entity\Contact; +use OroCRM\Bundle\ContactBundle\Entity\Group; use OroCRM\Bundle\AccountBundle\Entity\Account; use OroCRM\Bundle\ContactBundle\Entity\ContactAddress; use Oro\Bundle\AddressBundle\Entity\AddressType; @@ -23,6 +24,30 @@ public function testDoPreUpdate() $this->assertInstanceOf('\DateTime', $entity->getUpdatedAt()); } + public function testGetGroupLabels() + { + $entity = new Contact(); + $this->assertEquals(array(), $entity->getGroupLabels()); + + $entity->addGroup(new Group('Group One')); + $this->assertEquals(array('Group One'), $entity->getGroupLabels()); + + $entity->addGroup(new Group('Group Two')); + $this->assertEquals(array('Group One', 'Group Two'), $entity->getGroupLabels()); + } + + public function testGetGroupLabelsAsString() + { + $entity = new Contact(); + $this->assertEquals('', $entity->getGroupLabelsAsString()); + + $entity->addGroup(new Group('Group One')); + $this->assertEquals('Group One', $entity->getGroupLabelsAsString()); + + $entity->addGroup(new Group('Group Two')); + $this->assertEquals('Group One, Group Two', $entity->getGroupLabelsAsString()); + } + public function testAddAccount() { $account = new Account(); diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/GroupTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/GroupTest.php new file mode 100644 index 00000000000..5053b9f91a7 --- /dev/null +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Entity/GroupTest.php @@ -0,0 +1,33 @@ +group = new Group(); + } + + public function testConstructor() + { + $this->assertNull($this->group->getLabel()); + + $group = new Group('Label'); + $this->assertEquals('Label', $group->getLabel()); + } + + public function testLabel() + { + $this->assertNull($this->group->getLabel()); + $this->group->setLabel('Label'); + $this->assertEquals('Label', $this->group->getLabel()); + } +} From f8f42f3b4daeeac4aff6d33a9e3581f1aed79d67 Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Tue, 9 Jul 2013 14:43:55 +0300 Subject: [PATCH 28/65] CRM-232: Add columns and filters for contact group, lead source and primary postal code - added postal code field --- .../Datagrid/ContactDatagridManager.php | 22 +++++++++++++++++-- .../Resources/translations/datagrid.en.yml | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php index 7b3336ea9c8..e65952408f2 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php @@ -75,7 +75,7 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) 'filter_type' => FilterInterface::TYPE_ENTITY, 'sort_field_mapping' => array( 'entityAlias' => 'contactGroup', - 'fieldName' => 'label', + 'fieldName' => 'label', ), 'sortable' => true, 'filterable' => true, @@ -130,6 +130,23 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) ); $fieldsCollection->add($fieldRegion); + $fieldPostalCode = new FieldDescription(); + $fieldPostalCode->setName('postal_code'); + $fieldPostalCode->setOptions( + array( + 'type' => FieldDescriptionInterface::TYPE_TEXT, + 'label' => $this->translate('orocrm.contact.datagrid.postal_code'), + 'field_name' => 'addressPostalCode', + 'expression' => 'address.postalCode', + 'filter_type' => FilterInterface::TYPE_STRING, + 'sortable' => true, + 'filterable' => true, + 'show_filter' => true, + 'filter_by_where' => true, + ) + ); + $fieldsCollection->add($fieldPostalCode); + $fieldCreated = new FieldDescription(); $fieldCreated->setName('created'); $fieldCreated->setOptions( @@ -235,12 +252,13 @@ protected function applyJoinWithAddressAndCountry(ProxyQueryInterface $query) /** @var $query QueryBuilder */ $query - ->leftJoin("$entityAlias.groups", 'contactGroup') ->leftJoin("$entityAlias.addresses", 'address', 'WITH', 'address.primary = 1') + ->leftJoin("$entityAlias.groups", 'contactGroup') ->leftJoin('address.country', 'country') ->leftJoin('address.state', 'region'); $query->addSelect('country.name as countryName', true); + $query->addSelect('address.postalCode as addressPostalCode', true); $query->addSelect($this->regionExpression . ' AS regionLabel', true); } diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml b/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml index c513c1a04d1..0d1f3affa23 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.yml @@ -1,7 +1,8 @@ -orocrm.contact.datagrid.groups: Groups orocrm.contact.datagrid.contact_id: ID +orocrm.contact.datagrid.groups: Groups orocrm.contact.datagrid.country: Country orocrm.contact.datagrid.region: State +orocrm.contact.datagrid.postal_code: ZIP/Postal Code orocrm.contact.datagrid.created_at: Created At orocrm.contact.datagrid.updated_at: Updated At From 0711f3a25fc20bdd06a516d32e6b70de171a3b52 Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Tue, 9 Jul 2013 17:19:52 +0300 Subject: [PATCH 29/65] CRM-232: Add columns and filters for contact group, lead source and primary postal code - disable showing of filter for postal code by default --- .../Bundle/ContactBundle/Datagrid/ContactDatagridManager.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php index e65952408f2..c3317bec878 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php @@ -141,7 +141,6 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) 'filter_type' => FilterInterface::TYPE_STRING, 'sortable' => true, 'filterable' => true, - 'show_filter' => true, 'filter_by_where' => true, ) ); From 89399092e718441e3a4fcb3ce53144cebe5d9da1 Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Tue, 9 Jul 2013 17:40:21 +0300 Subject: [PATCH 30/65] CRM-232: Add columns and filters for contact group, lead source and primary postal code - CR fixes --- .../ContactBundle/Datagrid/GroupDatagridManager.php | 6 +++--- .../Bundle/ContactBundle/Resources/config/navigation.yml | 2 +- .../ContactBundle/Resources/views/Group/update.html.twig | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/GroupDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/GroupDatagridManager.php index a3971dfd731..55eff2c74d6 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/GroupDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/GroupDatagridManager.php @@ -42,12 +42,12 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) $fieldsCollection->add($fieldId); $fieldName = new FieldDescription(); - $fieldName->setName('name'); + $fieldName->setName('label'); $fieldName->setOptions( array( 'type' => FieldDescriptionInterface::TYPE_TEXT, - 'label' => $this->translate('Name'), - 'field_name' => 'name', + 'label' => $this->translate('Label'), + 'field_name' => 'label', 'filter_type' => FilterInterface::TYPE_STRING, 'sortable' => true, 'filterable' => true, diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml index 9d48e1a9398..c3275662667 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml @@ -48,4 +48,4 @@ oro_titles: orocrm_contact_group_index: Contact Groups orocrm_contact_group_create: Create Contact Group - orocrm_contact_group_update: %%group.name%% - Contact Group + orocrm_contact_group_update: %%group.label%% - Contact Group diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig index 37d46ffc119..41800f8beea 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig @@ -1,8 +1,8 @@ {% extends 'OroUIBundle:actions:update.html.twig' %} {% form_theme form with 'OroUIBundle:Form:fields.html.twig' %} -{% set title = form.vars.value.id ? form.vars.value.name|default('N/A') : 'Add Customer Group'|trans %} +{% set title = form.vars.value.id ? form.vars.value.label|default('N/A') : 'Add Customer Group'|trans %} {% if form.vars.value.id %} - {% oro_title_set({params : {"%group.name%": form.vars.value.name} }) %} + {% oro_title_set({params : {"%group.label%": form.vars.value.label} }) %} {% endif %} {% set gridId = 'contacts-grid' %} {% set formAction = form.vars.value.id ? path('orocrm_contact_group_update', { id: form.vars.value.id }) : path('orocrm_contact_group_create') %} @@ -50,7 +50,7 @@ 'entity': form.vars.value, 'indexPath': path('orocrm_contact_group_index'), 'indexLabel': 'Contact Groups', - 'entityTitle': form.vars.value.name|default('N/A') + 'entityTitle': form.vars.value.label|default('N/A') } %} {{ parent() }} @@ -69,7 +69,7 @@ { 'title': 'Basic Information', 'data': [ - form_row(form.name) + form_row(form.label) ] } ] From 78fd6d82eb1ab024034ad5018ca09bf365fa16b5 Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Tue, 9 Jul 2013 18:31:58 +0300 Subject: [PATCH 31/65] CRM-232: Add columns and filters for contact group, lead source and primary postal code - renamed "lead source" to "source" --- .../ContactBundle/DataFixtures/ORM/LoadContactAttrData.php | 4 ++-- .../ContactBundle/Datagrid/ContactDatagridManager.php | 2 +- .../DataFixtures/Accounts/LoadCrmAccountsData.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/DataFixtures/ORM/LoadContactAttrData.php b/src/OroCRM/Bundle/ContactBundle/DataFixtures/ORM/LoadContactAttrData.php index 341afe52aa5..1dc0923e695 100644 --- a/src/OroCRM/Bundle/ContactBundle/DataFixtures/ORM/LoadContactAttrData.php +++ b/src/OroCRM/Bundle/ContactBundle/DataFixtures/ORM/LoadContactAttrData.php @@ -82,9 +82,9 @@ public function load(ObjectManager $manager) 'searchable' => true ), array( - 'code' => 'lead_source', + 'code' => 'source', 'type' => 'oro_flexibleentity_simpleselect', - 'label' => 'Lead Source', + 'label' => 'Source', 'options' => array( 'other', 'call', 'TV', 'website' ), diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php index c3317bec878..72ae084e486 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php @@ -87,7 +87,7 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) ); $fieldsCollection->add($rolesLabel); - $this->configureFlexibleField($fieldsCollection, 'lead_source'); + $this->configureFlexibleField($fieldsCollection, 'source'); $fieldCountry = new FieldDescription(); $fieldCountry->setName('country'); diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Accounts/LoadCrmAccountsData.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Accounts/LoadCrmAccountsData.php index a0cb280542e..698d03070c6 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Accounts/LoadCrmAccountsData.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Accounts/LoadCrmAccountsData.php @@ -31,7 +31,7 @@ class LoadCrmAccountsData extends AbstractFixture implements ContainerAwareInter const FLUSH_MAX = 20; /** @var array Lead Sources */ - protected $leadSource = array('other', 'call', 'TV', 'website'); + protected $sources = array('other', 'call', 'TV', 'website'); /** * @var Account Manager */ @@ -135,8 +135,8 @@ public function loadAccounts() $user = $this->users[rand(0, count($this->users)-1)]; $this->setFlexibleAttributeValue($this->contactRepository, $contact, 'assigned_to', $user); $this->setFlexibleAttributeValue($this->contactRepository, $contact, 'reports_to', $contact); - $leadSource = $this->leadSource[rand(0, count($this->leadSource)-1)]; - $this->setFlexibleAttributeValueOption($this->contactRepository, $contact, 'lead_source', $leadSource); + $source = $this->sources[rand(0, count($this->sources)-1)]; + $this->setFlexibleAttributeValueOption($this->contactRepository, $contact, 'source', $source); $this->persist($this->accountManager, $account); From e1c01c42729e48f7da412dc48a64c7019ec4b458 Mon Sep 17 00:00:00 2001 From: Michael Banin Date: Wed, 10 Jul 2013 16:16:56 +0300 Subject: [PATCH 32/65] CRM-249 Fix tests that were blocked by bug CRM-147 - Test fixed --- .../TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php index cfbeff0b034..f9e9f113684 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php @@ -157,7 +157,6 @@ public function testEditRole($roleName) */ public function testViewAccountsContacts($username) { - $this->markTestSkipped('Due bug CRM-147'); $login = new Login($this); $login->setUsername($username) ->setPassword('123123q') From 14d84b5dcc8386c3f5fb7f378763aeced005d57f Mon Sep 17 00:00:00 2001 From: Aleksandr Smaga Date: Wed, 10 Jul 2013 16:19:44 +0200 Subject: [PATCH 33/65] BAP-1104: Create/assign tags on entities - Implement taggable entities for contacts and accounts --- .../Bundle/AccountBundle/Entity/Account.php | 22 ++++++++++++------- .../Form/Handler/AccountHandler.php | 20 +++++++++++++++-- .../AccountBundle/Form/Type/AccountType.php | 6 +++++ .../Resources/config/services.yml | 2 ++ .../Resources/views/Account/update.html.twig | 4 +++- .../Resources/views/Account/view.html.twig | 2 ++ .../Bundle/ContactBundle/Entity/Contact.php | 18 ++++++++++----- .../Form/Handler/ContactHandler.php | 21 ++++++++++++++++-- .../ContactBundle/Form/Type/ContactType.php | 6 +++++ .../Resources/config/services.yml | 2 ++ .../Resources/views/Contact/update.html.twig | 4 +++- .../Resources/views/Contact/view.html.twig | 6 +++++ 12 files changed, 93 insertions(+), 20 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php index ca8a8b97080..905244bd262 100644 --- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php +++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php @@ -194,9 +194,15 @@ public function doPreUpdate() } /** - * Return related tags - * - * @return ArrayCollection + * {@inheritdoc} + */ + public function getTaggableId() + { + return $this->getId(); + } + + /** + * {@inheritdoc} */ public function getTags() { @@ -206,12 +212,12 @@ public function getTags() } /** - * Returns the unique taggable resource identifier - * - * @return string + * {@inheritdoc} */ - public function getTaggableId() + public function setTags($tags) { - return $this->getId(); + $this->tags = $tags; + + return $this; } } diff --git a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php index 1b58dd34f70..f9051aa6690 100644 --- a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php +++ b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php @@ -4,12 +4,14 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; - use Doctrine\Common\Persistence\ObjectManager; + +use Oro\Bundle\TagBundle\Entity\TagManager; use OroCRM\Bundle\AccountBundle\Entity\Account; use OroCRM\Bundle\ContactBundle\Entity\Contact; +use Oro\Bundle\TagBundle\Form\Handler\TagHandlerInterface; -class AccountHandler +class AccountHandler implements TagHandlerInterface { /** * @var FormInterface @@ -26,6 +28,11 @@ class AccountHandler */ protected $manager; + /** + * @var TagManager + */ + protected $tagManager; + /** * * @param FormInterface $form @@ -77,6 +84,7 @@ protected function onSuccess(Account $entity, array $appendContacts, array $remo $this->removeContacts($entity, $removeContacts); $this->manager->persist($entity); $this->manager->flush(); + $this->tagManager->saveTagging($entity); } /** @@ -104,4 +112,12 @@ protected function removeContacts(Account $account, array $contacts) $account->removeContact($contact); } } + + /** + * {@inheritdoc} + */ + public function setTagManager(TagManager $tagManager) + { + $this->tagManager = $tagManager; + } } diff --git a/src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php b/src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php index 23e8dc33b02..023a150b7f4 100644 --- a/src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php +++ b/src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php @@ -27,6 +27,12 @@ public function addEntityFields(FormBuilderInterface $builder) ) ); + // tags + $builder->add( + 'tags', + 'oro_tag_select' + ); + // contacts $builder->add( 'appendContacts', diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml index 9febce0e18c..9f72d0fb94e 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml +++ b/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml @@ -62,6 +62,8 @@ services: - @orocrm_account.form.account - @request - @doctrine.orm.entity_manager + tags: + - { name: oro_tag.tag_manager } # Form type orocrm_account.form.type.account_select: diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig index 70c3f3fcf85..bb353f5ad16 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig @@ -1,4 +1,5 @@ {% extends 'OroUIBundle:actions:update.html.twig' %} +{% import 'OroTagBundle::macros.html.twig' as _tag %} {% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig'] %} {% set format = oro_config_value('oro_user.name_format') %} {% set title = form.vars.value.id ? form.vars.value.fullname(format)|default('N/A') ~ ' - ' ~ 'Update Account'|trans : 'New Account'|trans %} @@ -66,7 +67,8 @@ { 'title': 'Basic Information', 'data': [ - form_row(form.name) + form_row(form.name), + _tag.tagInputField('Tags', form) ] } ] diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig index 135cfa0570a..69b52b9324c 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig @@ -1,5 +1,6 @@ {% extends 'OroUIBundle:actions:view.html.twig' %} {% import 'OroUIBundle::macros.html.twig' as macros %} +{% import 'OroTagBundle::macros.html.twig' as _tag %} {% import 'OroAddressBundle:Include:viewMacro.html.twig' as addressView %} {% set format = oro_config_value('oro_user.name_format') %} {% oro_title_set({params : {"%account.name%": entity.name|default('N/A')} }) %} @@ -81,6 +82,7 @@ 'title': 'Basic Information', 'data': [ UI.attibuteRow('Account Name', entity.name), + UI.renderAttribute('Tags', _tag.renderView(entity)) ] } ] diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php index 21ec15ec7ac..128a1a58af2 100644 --- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php +++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php @@ -402,9 +402,7 @@ public function getAttributeData($attributeCode) } /** - * Returns the unique taggable resource identifier - * - * @return string + * {@inheritdoc} */ public function getTaggableId() { @@ -412,9 +410,7 @@ public function getTaggableId() } /** - * Returns the collection of tags for this Taggable entity - * - * @return ArrayCollection + * {@inheritdoc} */ public function getTags() { @@ -422,4 +418,14 @@ public function getTags() return $this->tags; } + + /** + * {@inheritdoc} + */ + public function setTags($tags) + { + $this->tags = $tags; + + return $this; + } } diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php b/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php index 4c31e3dbc1a..25f6f733ef7 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php @@ -4,12 +4,14 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; - use Doctrine\Common\Persistence\ObjectManager; + +use Oro\Bundle\TagBundle\Entity\TagManager; use OroCRM\Bundle\ContactBundle\Entity\Contact; use OroCRM\Bundle\AccountBundle\Entity\Account; +use Oro\Bundle\TagBundle\Form\Handler\TagHandlerInterface; -class ContactHandler +class ContactHandler implements TagHandlerInterface { /** * @var FormInterface @@ -26,6 +28,11 @@ class ContactHandler */ protected $manager; + /** + * @var TagManager + */ + protected $tagManager; + /** * * @param FormInterface $form @@ -75,8 +82,10 @@ protected function onSuccess(Contact $entity, array $appendAccounts, array $remo { $this->appendAccounts($entity, $appendAccounts); $this->removeAccounts($entity, $removeAccounts); + $this->manager->persist($entity); $this->manager->flush(); + $this->tagManager->saveTagging($entity); } /** @@ -104,4 +113,12 @@ protected function removeAccounts(Contact $contact, array $accounts) $contact->removeAccount($account); } } + + /** + * {@inheritdoc} + */ + public function setTagManager(TagManager $tagManager) + { + $this->tagManager = $tagManager; + } } diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php index 191f011f2b7..d747d580449 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php @@ -50,6 +50,12 @@ public function addEntityFields(FormBuilderInterface $builder) // add default flexible fields parent::addEntityFields($builder); + // tags + $builder->add( + 'tags', + 'oro_tag_select' + ); + // Addresses $builder->add( 'addresses', diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml index 4a5f8706d92..30447e4a393 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml @@ -78,6 +78,8 @@ services: - @orocrm_contact.form.contact - @request - @doctrine.orm.entity_manager + tags: + - { name: oro_tag.tag_manager } orocrm_contact.contact.manager: class: %orocrm_contact.contact.manager.api.class% diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig index 70e6153b640..48ce93c0be4 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig @@ -1,4 +1,5 @@ {% extends 'OroUIBundle:actions:update.html.twig' %} +{% import 'OroTagBundle::macros.html.twig' as _tag %} {% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig'] %} {% set format = oro_config_value('oro_user.name_format') %} {% set fullname = entity.fullname(format)|default('N/A') %} @@ -68,7 +69,8 @@ { 'title': 'Basic Information', 'data': [ - form_row(form.values) + form_row(form.values), + _tag.tagInputField('Tags', form) ] }, { diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig index e68cf21723d..476d7b2ebd5 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig @@ -1,4 +1,5 @@ {% extends 'OroUIBundle:actions:view.html.twig' %} +{% import 'OroTagBundle::macros.html.twig' as _tag %} {% import 'OroUIBundle::macros.html.twig' as macros %} {% import 'OroAddressBundle:Include:viewMacro.html.twig' as addressView %} {% set format = oro_config_value('oro_user.name_format') %} @@ -69,6 +70,11 @@ {% set dataSubBlocks = dataSubBlocks|merge([addressSubBlock]) %} {% endif %} + {% set dataSubBlocks = dataSubBlocks|merge([{ + title: '', + data : [UI.renderAttribute('Tags', _tag.renderView(entity))] + }]) %} + {% set dataBlocks = [ { 'title': 'General', From e871b7c02d3a29c92697ca7d4bc4e26ddd570007 Mon Sep 17 00:00:00 2001 From: Aleksandr Smaga Date: Wed, 10 Jul 2013 16:22:54 +0200 Subject: [PATCH 34/65] BAP-1104: Create/assign tags on entities - Fix style typo --- src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php index f9051aa6690..aff7ccf941a 100644 --- a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php +++ b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php @@ -82,6 +82,7 @@ protected function onSuccess(Account $entity, array $appendContacts, array $remo { $this->appendContacts($entity, $appendContacts); $this->removeContacts($entity, $removeContacts); + $this->manager->persist($entity); $this->manager->flush(); $this->tagManager->saveTagging($entity); From 3ea0cb4a4631912c44508655d3ccfe63adb86f4e Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Wed, 10 Jul 2013 19:04:53 +0300 Subject: [PATCH 35/65] BAP-1027: Upgrade Symfony to version 2.3 - removed layouts with form types --- .../AccountBundle/Resources/views/Account/update.html.twig | 1 - .../ContactBundle/Resources/views/Contact/update.html.twig | 1 - .../ContactBundle/Resources/views/Group/update.html.twig | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig index 70c3f3fcf85..3395a707344 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig @@ -1,5 +1,4 @@ {% extends 'OroUIBundle:actions:update.html.twig' %} -{% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig'] %} {% set format = oro_config_value('oro_user.name_format') %} {% set title = form.vars.value.id ? form.vars.value.fullname(format)|default('N/A') ~ ' - ' ~ 'Update Account'|trans : 'New Account'|trans %} {% oro_title_set({params : {"%account.name%": form.vars.value.name|default('N/A')} }) %} diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig index 70e6153b640..fae187f3d24 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig @@ -1,5 +1,4 @@ {% extends 'OroUIBundle:actions:update.html.twig' %} -{% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig'] %} {% set format = oro_config_value('oro_user.name_format') %} {% set fullname = entity.fullname(format)|default('N/A') %} {% oro_title_set({params : {"%contact.name%": fullname} }) %} diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig index 41800f8beea..b5da1f70682 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig @@ -1,6 +1,5 @@ {% extends 'OroUIBundle:actions:update.html.twig' %} -{% form_theme form with 'OroUIBundle:Form:fields.html.twig' %} -{% set title = form.vars.value.id ? form.vars.value.label|default('N/A') : 'Add Customer Group'|trans %} +{% set title = form.vars.value.id ? form.vars.value.name|default('N/A') : 'Add Customer Group'|trans %} {% if form.vars.value.id %} {% oro_title_set({params : {"%group.label%": form.vars.value.label} }) %} {% endif %} From 76fe6acd600705602127ae5ca70cff4d7e0ab0de Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Wed, 10 Jul 2013 19:39:13 +0300 Subject: [PATCH 36/65] BAP-1027: Upgrade Symfony to version 2.3 - removed unused assets.yml files --- src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml | 4 ---- src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml | 4 ---- 2 files changed, 8 deletions(-) delete mode 100644 src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml delete mode 100644 src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml deleted file mode 100644 index 6000d9cb935..00000000000 --- a/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml +++ /dev/null @@ -1,4 +0,0 @@ -js: - - '@OroUIBundle/Resources/public/lib/bootstrap/js/bootstrap-scrollspy.js' - - '@OroUIBundle/Resources/public/lib/backbone.bootstrap-modal.js' - - '@OroUIBundle/Resources/public/lib/jquery/select2.min.js' \ No newline at end of file diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml deleted file mode 100644 index 6000d9cb935..00000000000 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml +++ /dev/null @@ -1,4 +0,0 @@ -js: - - '@OroUIBundle/Resources/public/lib/bootstrap/js/bootstrap-scrollspy.js' - - '@OroUIBundle/Resources/public/lib/backbone.bootstrap-modal.js' - - '@OroUIBundle/Resources/public/lib/jquery/select2.min.js' \ No newline at end of file From 2a1b84a5dbf9701f0af780d36c37ef0300b733ea Mon Sep 17 00:00:00 2001 From: Ignat Shcheglovskyi Date: Thu, 11 Jul 2013 13:31:52 +0300 Subject: [PATCH 37/65] BAP-1027: Upgrade Symfony to version 2.3 - fix code style issues --- .../Performance/DataFixtures/Users/LoadCrmUsersData.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Users/LoadCrmUsersData.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Users/LoadCrmUsersData.php index 9170de3d983..229b84a9fbc 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Users/LoadCrmUsersData.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Performance/DataFixtures/Users/LoadCrmUsersData.php @@ -20,7 +20,9 @@ use Oro\Bundle\UserBundle\Entity\User; /** - * @SuppressWarnings(PHPMD) + * @SuppressWarnings(PHPMD.TooManyMethods) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * TODO: This class should be refactored (BAP-975) */ class LoadCrmUsersData extends AbstractFixture implements ContainerAwareInterface { @@ -171,6 +173,8 @@ public function loadUsers() * @param array $hobbies * @param \DateTime $lastVisit * @return User + * @SuppressWarnings(PHPMD.ExcessiveParameterList) + * TODO: This method should be refactored (BAP-975) */ private function createUser( $username, From bb4c17a9a4bd380fc516524e69d99055c07191b0 Mon Sep 17 00:00:00 2001 From: Aleksandr Smaga Date: Thu, 11 Jul 2013 13:24:28 +0200 Subject: [PATCH 38/65] BAP-1104: Create/assign tags on entities - Added ACL check - Style issues fix --- .../AccountBundle/Form/Handler/AccountHandler.php | 2 +- .../Resources/views/Account/view.html.twig | 12 ++++++++---- .../ContactBundle/Form/Handler/ContactHandler.php | 2 +- .../Resources/views/Contact/view.html.twig | 10 ++++++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php index aff7ccf941a..8ed1d7756e2 100644 --- a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php +++ b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php @@ -82,7 +82,7 @@ protected function onSuccess(Account $entity, array $appendContacts, array $remo { $this->appendContacts($entity, $appendContacts); $this->removeContacts($entity, $removeContacts); - + $this->manager->persist($entity); $this->manager->flush(); $this->tagManager->saveTagging($entity); diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig index 69b52b9324c..447a0b22e6a 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig @@ -72,6 +72,11 @@ {% set additional = additional|merge([{'title' : null, 'data' : attributes}]) %} {% endif %} + {% set dataSubBlocks = [UI.attibuteRow('Account Name', entity.name)] %} + {% if resource_granted('oro_tag_view_tag_cloud') %} + {% set dataSubBlocks = dataSubBlocks|merge([UI.renderAttribute('Tags', _tag.renderView(entity))]) %} + {% endif %} + {% set dataBlocks = [ { @@ -80,16 +85,15 @@ 'subblocks': [ { 'title': 'Basic Information', - 'data': [ - UI.attibuteRow('Account Name', entity.name), - UI.renderAttribute('Tags', _tag.renderView(entity)) - ] + 'data' : dataSubBlocks } ] } ] %} + + {% if (accountAddresses|length) %} {% set dataBlocks = dataBlocks|merge([{'title' : 'Addresses', 'subblocks': accountAddresses}])%} {% endif %} diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php b/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php index 25f6f733ef7..cf3d5766524 100644 --- a/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php +++ b/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php @@ -7,8 +7,8 @@ use Doctrine\Common\Persistence\ObjectManager; use Oro\Bundle\TagBundle\Entity\TagManager; -use OroCRM\Bundle\ContactBundle\Entity\Contact; use OroCRM\Bundle\AccountBundle\Entity\Account; +use OroCRM\Bundle\ContactBundle\Entity\Contact; use Oro\Bundle\TagBundle\Form\Handler\TagHandlerInterface; class ContactHandler implements TagHandlerInterface diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig index 476d7b2ebd5..69a69752423 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig @@ -70,10 +70,12 @@ {% set dataSubBlocks = dataSubBlocks|merge([addressSubBlock]) %} {% endif %} - {% set dataSubBlocks = dataSubBlocks|merge([{ - title: '', - data : [UI.renderAttribute('Tags', _tag.renderView(entity))] - }]) %} + {% if resource_granted('oro_tag_view_tag_cloud') %} + {% set dataSubBlocks = dataSubBlocks|merge([{ + title: '', + data : [UI.renderAttribute('Tags', _tag.renderView(entity))] + }]) %} + {% endif %} {% set dataBlocks = [ { From 47dd0cfd9871b99242eb81a4faaaad52cd201b14 Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Thu, 11 Jul 2013 17:44:20 +0300 Subject: [PATCH 39/65] BAP-1027: Upgrade Symfony to version 2.3 - fixed search result templates --- .../Resources/views/Account/searchResult.html.twig | 8 +++----- .../Resources/views/Contact/searchResult.html.twig | 10 +++------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig index d26d8b2de1b..9f410ff7922 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig @@ -1,6 +1,6 @@ {# Available variables: - * entity - user entity OroCRM\Bundle\AccountBundle\Entity\Account + * entity - user entity OroCRM\Bundle\AccountBundle\Entity\Account or null * indexer_item - indexer item Oro\Bundle\SearchBundle\Query\Result\Item #} {% extends 'OroSearchBundle:Search:searchResultItem.html.twig' %} @@ -9,11 +9,9 @@ {% set format = oro_config_value('oro_user.name_format') %} {% set showImage = false %} -{% if entity %} - {% set recordUrl = indexer_item.recordUrl %} -{% endif %} - +{% set recordUrl = indexer_item.recordUrl %} {% set title = indexer_item.recordTitle %} + {% set entityType = 'Account'|trans %} {% set entityInfo = [ diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/searchResult.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/searchResult.html.twig index 64554443a3a..a8ad1165a0c 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/searchResult.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/searchResult.html.twig @@ -1,6 +1,6 @@ {# Available variables: - * entity - user entity OroCRM\Bundle\ContactBundle\Entity\Contact + * entity - user entity OroCRM\Bundle\ContactBundle\Entity\Contact or null * indexer_item - indexer item Oro\Bundle\SearchBundle\Query\Result\Item #} {% extends 'OroSearchBundle:Search:searchResultItem.html.twig' %} @@ -9,12 +9,8 @@ {% set format = oro_config_value('oro_user.name_format') %} {% set showImage = false %} -{% if entity %} - {% set recordUrl = indexer_item.recordUrl %} - {% set title = entity.__toString %} -{% else %} - {% set title = indexer_item.recordTitle %} -{% endif %} +{% set recordUrl = indexer_item.recordUrl %} +{% set title = entity ? entity.__toString : indexer_item.recordTitle %} {% set entityType = 'Contact'|trans %} From caf16ee40151da7c89cc285203ab261f9ab663e8 Mon Sep 17 00:00:00 2001 From: Ivan Shakuta Date: Thu, 11 Jul 2013 15:57:13 +0000 Subject: [PATCH 40/65] BAP-1104: move field tag to tag bundle --- .../AccountBundle/Resources/views/Account/update.html.twig | 2 +- .../ContactBundle/Resources/views/Contact/update.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig index bb353f5ad16..97dbd1a7ba1 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig @@ -1,6 +1,6 @@ {% extends 'OroUIBundle:actions:update.html.twig' %} {% import 'OroTagBundle::macros.html.twig' as _tag %} -{% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig'] %} +{% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig', 'OroTagBundle:Form:fields.html.twig'] %} {% set format = oro_config_value('oro_user.name_format') %} {% set title = form.vars.value.id ? form.vars.value.fullname(format)|default('N/A') ~ ' - ' ~ 'Update Account'|trans : 'New Account'|trans %} {% oro_title_set({params : {"%account.name%": form.vars.value.name|default('N/A')} }) %} diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig index 48ce93c0be4..d0d9a3e5662 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig @@ -1,6 +1,6 @@ {% extends 'OroUIBundle:actions:update.html.twig' %} {% import 'OroTagBundle::macros.html.twig' as _tag %} -{% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig'] %} +{% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig', 'OroTagBundle:Form:fields.html.twig'] %} {% set format = oro_config_value('oro_user.name_format') %} {% set fullname = entity.fullname(format)|default('N/A') %} {% oro_title_set({params : {"%contact.name%": fullname} }) %} From c57205813494d1f5b25cca449532f7266a8b6be3 Mon Sep 17 00:00:00 2001 From: Aleksandr Smaga Date: Fri, 12 Jul 2013 11:39:30 +0200 Subject: [PATCH 41/65] BAP-1104: Create/assign tags on entities - Fix unit tests --- .../Bundle/AccountBundle/Resources/config/services.yml | 2 ++ .../Tests/Unit/Form/Handler/AccountHandlerTest.php | 5 +++++ .../Tests/Unit/Form/Type/AccountApiTypeTest.php | 6 +++++- .../Tests/Unit/Form/Type/AccountTypeTest.php | 6 +++++- .../Bundle/ContactBundle/Resources/config/services.yml | 2 ++ .../Tests/Unit/Form/Handler/ContactHandlerTest.php | 5 +++++ .../Tests/Unit/Form/Type/ContactTypeTest.php | 10 +++++++--- 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml index 9f72d0fb94e..c6a8ec88313 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml +++ b/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml @@ -126,6 +126,8 @@ services: - @orocrm_account.form.account.api - @request - @doctrine.orm.entity_manager + tags: + - { name: oro_tag.tag_manager } orocrm_account.form.autocomplete.account.search_handler: parent: oro_form.autocomplete.search_handler diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php index 653058b8a62..1b2f2d1bcf7 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php @@ -51,6 +51,11 @@ protected function setUp() $this->entity = new Account(); $this->handler = new AccountHandler($this->form, $this->request, $this->manager); + $this->handler->setTagManager( + $this->getMockBuilder('Oro\Bundle\TagBundle\Entity\TagManager') + ->disableOriginalConstructor() + ->getMock() + ); } diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountApiTypeTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountApiTypeTest.php index c32fcfac6c9..115a7585f39 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountApiTypeTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountApiTypeTest.php @@ -55,9 +55,13 @@ public function testAddEntityFields() ->will($this->returnSelf()); $builder->expects($this->at(2)) ->method('add') - ->with('appendContacts', 'oro_entity_identifier') + ->with('tags', 'oro_tag_select') ->will($this->returnSelf()); $builder->expects($this->at(3)) + ->method('add') + ->with('appendContacts', 'oro_entity_identifier') + ->will($this->returnSelf()); + $builder->expects($this->at(4)) ->method('add') ->with('removeContacts', 'oro_entity_identifier') ->will($this->returnSelf()); diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountTypeTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountTypeTest.php index 181057cf44b..68e263673ed 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountTypeTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountTypeTest.php @@ -35,9 +35,13 @@ public function testAddEntityFields() ->will($this->returnSelf()); $builder->expects($this->at(2)) ->method('add') - ->with('appendContacts', 'oro_entity_identifier') + ->with('tags', 'oro_tag_select') ->will($this->returnSelf()); $builder->expects($this->at(3)) + ->method('add') + ->with('appendContacts', 'oro_entity_identifier') + ->will($this->returnSelf()); + $builder->expects($this->at(4)) ->method('add') ->with('removeContacts', 'oro_entity_identifier') ->will($this->returnSelf()); diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml index 30447e4a393..da8bbd10a05 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml @@ -146,6 +146,8 @@ services: - @orocrm_contact.form.contact.api - @request - @doctrine.orm.entity_manager + tags: + - { name: oro_tag.tag_manager } # Group API orocrm_contact.group.manager.api: diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Handler/ContactHandlerTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Handler/ContactHandlerTest.php index f9941f081e8..539a1f4169f 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Handler/ContactHandlerTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Handler/ContactHandlerTest.php @@ -49,6 +49,11 @@ protected function setUp() $this->entity = new Contact(); $this->handler = new ContactHandler($this->form, $this->request, $this->manager); + $this->handler->setTagManager( + $this->getMockBuilder('Oro\Bundle\TagBundle\Entity\TagManager') + ->disableOriginalConstructor() + ->getMock() + ); } diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Type/ContactTypeTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Type/ContactTypeTest.php index 8405edc6f90..2c2ca60cdc4 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Type/ContactTypeTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Unit/Form/Type/ContactTypeTest.php @@ -45,17 +45,21 @@ public function testAddEntityFields() $builder->expects($this->at(1)) ->method('add') - ->with('addresses', 'oro_address_collection') + ->with('tags', 'oro_tag_select') ->will($this->returnSelf()); $builder->expects($this->at(2)) ->method('add') - ->with('groups', 'entity') + ->with('addresses', 'oro_address_collection') ->will($this->returnSelf()); $builder->expects($this->at(3)) ->method('add') - ->with('appendAccounts', 'oro_entity_identifier') + ->with('groups', 'entity') ->will($this->returnSelf()); $builder->expects($this->at(4)) + ->method('add') + ->with('appendAccounts', 'oro_entity_identifier') + ->will($this->returnSelf()); + $builder->expects($this->at(5)) ->method('add') ->with('removeAccounts', 'oro_entity_identifier') ->will($this->returnSelf()); From 2adf21f734483b611fcf21ec7148f71c1f76ae6c Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Fri, 12 Jul 2013 15:22:59 +0300 Subject: [PATCH 42/65] CRM-266: Fix datagrid issues in PostgreSql environment - fixed datagrid managers --- .../AccountContactUpdateDatagridManager.php | 70 ++++++++++++------- .../ContactAccountUpdateDatagridManager.php | 70 ++++++++++++------- .../Datagrid/ContactDatagridManager.php | 5 +- 3 files changed, 90 insertions(+), 55 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php b/src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php index 62ba165bdb0..6312fc7df0a 100644 --- a/src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php +++ b/src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php @@ -2,7 +2,6 @@ namespace OroCRM\Bundle\AccountBundle\Datagrid; -use Oro\Bundle\GridBundle\Datagrid\FlexibleDatagridManager; use Oro\Bundle\GridBundle\Field\FieldDescriptionCollection; use Oro\Bundle\GridBundle\Field\FieldDescription; use Oro\Bundle\GridBundle\Field\FieldDescriptionInterface; @@ -10,9 +9,15 @@ use Oro\Bundle\GridBundle\Sorter\SorterInterface; use Oro\Bundle\GridBundle\Datagrid\ParametersInterface; use Oro\Bundle\GridBundle\Datagrid\ProxyQueryInterface; +use Oro\Bundle\GridBundle\Datagrid\ORM\QueryFactory\EntityQueryFactory; class AccountContactUpdateDatagridManager extends AccountContactDatagridManager { + /** + * @var string + */ + protected $hasAccountExpression; + /** * {@inheritDoc} */ @@ -22,16 +27,17 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) $fieldHasAccount->setName('has_account'); $fieldHasAccount->setOptions( array( - 'type' => FieldDescriptionInterface::TYPE_BOOLEAN, - 'label' => $this->translate('Assigned'), - 'field_name' => 'hasCurrentAccount', - 'expression' => 'hasCurrentAccount', - 'nullable' => false, - 'editable' => true, - 'sortable' => true, - 'filter_type' => FilterInterface::TYPE_BOOLEAN, - 'filterable' => true, - 'show_filter' => true, + 'type' => FieldDescriptionInterface::TYPE_BOOLEAN, + 'label' => $this->translate('Assigned'), + 'field_name' => 'hasCurrentAccount', + 'expression' => $this->getHasAccountExpression(), + 'nullable' => false, + 'editable' => true, + 'sortable' => true, + 'filter_type' => FilterInterface::TYPE_BOOLEAN, + 'filterable' => true, + 'show_filter' => true, + 'filter_by_where' => true, ) ); $fieldsCollection->add($fieldHasAccount); @@ -46,24 +52,34 @@ protected function prepareQuery(ProxyQueryInterface $query) { $this->applyJoinWithAddressAndCountry($query); - $entityAlias = $query->getRootAlias(); + $query->addSelect($this->getHasAccountExpression() . ' AS hasCurrentAccount', true); + } - if ($this->getAccount()->getId()) { - $query->addSelect( - "CASE WHEN " . - "(:account MEMBER OF $entityAlias.accounts OR $entityAlias.id IN (:data_in)) AND " . - "$entityAlias.id NOT IN (:data_not_in) ". - "THEN 1 ELSE 0 END AS hasCurrentAccount", - true - ); - } else { - $query->addSelect( - "CASE WHEN " . - "$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ". - "THEN 1 ELSE 0 END AS hasCurrentAccount", - true - ); + /** + * @return string + */ + protected function getHasAccountExpression() + { + if (null === $this->hasAccountExpression) { + /** @var EntityQueryFactory $queryFactory */ + $queryFactory = $this->queryFactory; + $entityAlias = $queryFactory->getAlias(); + + if ($this->getAccount()->getId()) { + $this->hasAccountExpression = + "CASE WHEN " . + "(:account MEMBER OF $entityAlias.accounts OR $entityAlias.id IN (:data_in)) AND " . + "$entityAlias.id NOT IN (:data_not_in) ". + "THEN true ELSE false END"; + } else { + $this->hasAccountExpression = + "CASE WHEN " . + "$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ". + "THEN true ELSE false END"; + } } + + return $this->hasAccountExpression; } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php index eb741836306..3eb5d85ff72 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php @@ -4,7 +4,6 @@ use Doctrine\ORM\QueryBuilder; -use Oro\Bundle\GridBundle\Datagrid\FlexibleDatagridManager; use Oro\Bundle\GridBundle\Field\FieldDescriptionCollection; use Oro\Bundle\GridBundle\Field\FieldDescription; use Oro\Bundle\GridBundle\Field\FieldDescriptionInterface; @@ -12,9 +11,15 @@ use Oro\Bundle\GridBundle\Sorter\SorterInterface; use Oro\Bundle\GridBundle\Datagrid\ParametersInterface; use Oro\Bundle\GridBundle\Datagrid\ProxyQueryInterface; +use Oro\Bundle\GridBundle\Datagrid\ORM\QueryFactory\EntityQueryFactory; class ContactAccountUpdateDatagridManager extends ContactAccountDatagridManager { + /** + * @var string + */ + protected $hasContactExpression; + /** * {@inheritDoc} */ @@ -24,16 +29,17 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) $fieldHasContact->setName('has_contact'); $fieldHasContact->setOptions( array( - 'type' => FieldDescriptionInterface::TYPE_BOOLEAN, - 'label' => $this->translate('Assigned'), - 'field_name' => 'hasCurrentContact', - 'expression' => 'hasCurrentContact', - 'nullable' => false, - 'editable' => true, - 'sortable' => true, - 'filter_type' => FilterInterface::TYPE_BOOLEAN, - 'filterable' => true, - 'show_filter' => true, + 'type' => FieldDescriptionInterface::TYPE_BOOLEAN, + 'label' => $this->translate('Assigned'), + 'field_name' => 'hasCurrentContact', + 'expression' => $this->getHasContactExpression(), + 'nullable' => false, + 'editable' => true, + 'sortable' => true, + 'filter_type' => FilterInterface::TYPE_BOOLEAN, + 'filterable' => true, + 'show_filter' => true, + 'filter_by_where' => true, ) ); $fieldsCollection->add($fieldHasContact); @@ -46,24 +52,34 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection) */ protected function prepareQuery(ProxyQueryInterface $query) { - $entityAlias = $query->getRootAlias(); + $query->addSelect($this->getHasContactExpression() . ' AS hasCurrentContact', true); + } - if ($this->getContact()->getId()) { - $query->addSelect( - "CASE WHEN " . - "(:contact MEMBER OF $entityAlias.contacts OR $entityAlias.id IN (:data_in)) AND " . - "$entityAlias.id NOT IN (:data_not_in) ". - 'THEN 1 ELSE 0 END AS hasCurrentContact', - true - ); - } else { - $query->addSelect( - "CASE WHEN ". - "$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ". - "THEN 1 ELSE 0 END AS hasCurrentContact", - true - ); + /** + * @return string + */ + protected function getHasContactExpression() + { + if (null === $this->hasContactExpression) { + /** @var EntityQueryFactory $queryFactory */ + $queryFactory = $this->queryFactory; + $entityAlias = $queryFactory->getAlias(); + + if ($this->getContact()->getId()) { + $this->hasContactExpression = + "CASE WHEN " . + "(:contact MEMBER OF $entityAlias.accounts OR $entityAlias.id IN (:data_in)) AND " . + "$entityAlias.id NOT IN (:data_not_in) ". + "THEN true ELSE false END"; + } else { + $this->hasContactExpression = + "CASE WHEN " . + "$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ". + "THEN true ELSE false END"; + } } + + return $this->hasContactExpression; } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php index 72ae084e486..ced85024d67 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php @@ -251,7 +251,7 @@ protected function applyJoinWithAddressAndCountry(ProxyQueryInterface $query) /** @var $query QueryBuilder */ $query - ->leftJoin("$entityAlias.addresses", 'address', 'WITH', 'address.primary = 1') + ->leftJoin("$entityAlias.addresses", 'address', 'WITH', 'address.primary = true') ->leftJoin("$entityAlias.groups", 'contactGroup') ->leftJoin('address.country', 'country') ->leftJoin('address.state', 'region'); @@ -261,6 +261,9 @@ protected function applyJoinWithAddressAndCountry(ProxyQueryInterface $query) $query->addSelect($this->regionExpression . ' AS regionLabel', true); } + /** + * @return array + */ protected function getDefaultSorters() { return array( From 4c4c641a06d5b4a6f1038e8b139f0b1be28b73d9 Mon Sep 17 00:00:00 2001 From: Bogdan Tsyganovskiy Date: Sun, 14 Jul 2013 18:08:07 +0300 Subject: [PATCH 43/65] BAP-1065: Pin tab experience update - Back button removed from view pages --- .../Bundle/AccountBundle/Resources/views/Account/view.html.twig | 1 - .../Bundle/ContactBundle/Resources/views/Contact/view.html.twig | 1 - 2 files changed, 2 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig index 135cfa0570a..77e62b1d45b 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig @@ -9,7 +9,6 @@ {% endblock %} {% block navButtons %} - {{ UI.button({'path': path('orocrm_account_index'), 'iClass': 'icon-chevron-left ', 'title': 'Back', 'label': 'Back'}) }} {% if resource_granted('orocrm_account_update') %} {{ UI.button({'path': path('orocrm_account_update', {'id': entity.id}), 'iClass': 'icon-edit', 'title': 'Edit account', 'label': 'Edit'}) }} {% endif %} diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig index e68cf21723d..40b4dbbdd8f 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig @@ -11,7 +11,6 @@ {% endblock %} {% block navButtons %} - {{ UI.button({'path' : path('orocrm_contact_index'), 'iClass' : 'icon-chevron-left ', 'title' : 'Back', 'label' : 'Back'}) }} {% if resource_granted('orocrm_contact_update') %} {{ UI.button({'path' : path('orocrm_contact_update', { 'id': entity.id }), 'iClass' : 'icon-edit ', 'title' : 'Update contact', 'label' : 'Edit'}) }} {% endif %} From aba728363e423da51cd7efe2d122a38534286106 Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Mon, 15 Jul 2013 13:26:10 +0300 Subject: [PATCH 44/65] CRM-266: Fix datagrid issues in PostgreSql environment - fixed CR issues --- .../Datagrid/ContactAccountUpdateDatagridManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php index 3eb5d85ff72..7998060bd90 100644 --- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php +++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php @@ -68,7 +68,7 @@ protected function getHasContactExpression() if ($this->getContact()->getId()) { $this->hasContactExpression = "CASE WHEN " . - "(:contact MEMBER OF $entityAlias.accounts OR $entityAlias.id IN (:data_in)) AND " . + "(:contact MEMBER OF $entityAlias.contacts OR $entityAlias.id IN (:data_in)) AND " . "$entityAlias.id NOT IN (:data_not_in) ". "THEN true ELSE false END"; } else { From 83e3ac7088488749bb1a2e6d029fe0a8eb6f9b38 Mon Sep 17 00:00:00 2001 From: yurio Date: Tue, 16 Jul 2013 19:01:03 +0300 Subject: [PATCH 45/65] BAP-1149: Form buttons - Add buttons in CRM --- .../AccountBundle/Controller/AccountController.php | 12 +++++++++--- .../Resources/views/Account/update.html.twig | 3 ++- .../ContactBundle/Controller/ContactController.php | 12 +++++++++--- .../ContactBundle/Controller/GroupController.php | 10 +++++++++- .../Resources/views/Contact/update.html.twig | 3 ++- .../Resources/views/Group/update.html.twig | 3 ++- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php b/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php index 83ed41fc2bf..ee62494e0ef 100644 --- a/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php +++ b/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php @@ -117,11 +117,17 @@ public function updateAction(Account $entity = null) return $this->get('oro_grid.renderer')->renderResultsJsonResponse($datagridView); } - $backUrl = $this->generateUrl('orocrm_account_index'); - if ($this->get('orocrm_account.form.handler.account')->process($entity)) { $this->getFlashBag()->add('success', 'Account successfully saved'); - return $this->redirect($backUrl); + if ($this->getRequest()->get('additional_data') == 'save_and_stay') { + $routeName = 'orocrm_account_update'; + $params = array('id' => $entity->getId()); + } else { + $routeName = 'orocrm_account_index'; + $params = null; + } + + return $this->redirect($this->generateUrl($routeName,$params)); } return array( diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig index 97dbd1a7ba1..925da74601f 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig @@ -39,7 +39,8 @@ {{ UI.buttonSeparator() }} {% endif %} {{ UI.button({'path' : path('orocrm_account_index'), 'title' : 'Cancel', 'label' : 'Cancel'}) }} - {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save'}) }} + {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save and Close'}) }} + {{ UI.buttonType({'type': 'button', 'class': 'btn-success', 'label': 'Save', 'additional_data': 'save_and_stay'}) }} {% endblock %} {% block pageHeader %} diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php index 4587bd2bf7b..69f3088a070 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php @@ -99,11 +99,17 @@ public function updateAction(Contact $entity = null) return $this->get('oro_grid.renderer')->renderResultsJsonResponse($datagridView); } - $backUrl = $this->generateUrl('orocrm_contact_index'); - if ($this->get('orocrm_contact.form.handler.contact')->process($entity)) { $this->getFlashBag()->add('success', 'Contact successfully saved'); - return $this->redirect($backUrl); + if ($this->getRequest()->get('additional_data') == 'save_and_stay') { + $routeName = 'orocrm_contact_update'; + $params = array('id' => $entity->getId()); + } else { + $routeName = 'orocrm_contact_index'; + $params = null; + } + + return $this->redirect($this->generateUrl($routeName,$params)); } return array( diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php b/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php index 300cdd960ef..a62879b6e7f 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php @@ -61,7 +61,15 @@ public function updateAction(Group $entity) $this->get('session')->getFlashBag()->add('success', 'Group successfully saved'); if (!$this->getRequest()->get('_widgetContainer')) { - return $this->redirect($this->generateUrl('orocrm_contact_group_index')); + if ($this->getRequest()->get('additional_data') == 'save_and_stay') { + $routeName = 'orocrm_contact_group_update'; + $params = array('id' => $entity->getId()); + } else { + $routeName = 'orocrm_contact_group_index'; + $params = null; + } + + return $this->redirect($this->generateUrl($routeName,$params)); } } diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig index d0d9a3e5662..5a904a866ba 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig @@ -41,7 +41,8 @@ {{ UI.buttonSeparator() }} {% endif %} {{ UI.button({'path' : path('orocrm_contact_index'), 'title' : 'Cancel', 'label' : 'Cancel'}) }} - {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save'}) }} + {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save and Close'}) }} + {{ UI.buttonType({'type': 'button', 'class': 'btn-success', 'label': 'Save', 'additional_data': 'save_and_stay'}) }} {% endblock %} {% block pageHeader %} diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig index b5da1f70682..0bbe9c82abb 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig @@ -40,7 +40,8 @@ {{ UI.buttonSeparator() }} {% endif %} {{ UI.button({'path' : path('orocrm_contact_group_index'), 'title' : 'Cancel', 'label' : 'Cancel'}) }} - {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save'}) }} + {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save and Close'}) }} + {{ UI.buttonType({'type': 'button', 'class': 'btn-success', 'label': 'Save', 'additional_data': 'save_and_stay'}) }} {% endblock navButtons %} {% block pageHeader %} From 25f5624d2534542828873fba81238178726fb50c Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Wed, 17 Jul 2013 14:05:09 +0300 Subject: [PATCH 46/65] BAP-1152: Functional Tests memory usage and speed optimization - memory and performance tests optimization --- .../Functional/API/RestAccountApiTest.php | 8 +++++-- .../Functional/API/SoapAccountApiTest.php | 23 +++++++++++-------- .../Functional/API/RestContactApiTest.php | 8 +++++-- .../API/RestContactGroupsApiTest.php | 8 +++++-- .../Functional/API/SoapContactApiTest.php | 23 +++++++++++-------- .../API/SoapContactGroupApiTest.php | 23 +++++++++++-------- 6 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php index b0c20328372..e3068cdde29 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php @@ -13,11 +13,15 @@ class RestAccountApiTest extends WebTestCase { /** @var Client */ - public $client = null; + protected $client; public function setUp() { - $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + if (!isset($this->client)) { + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + } else { + $this->client->restart(); + } } public function testCreateAccount() diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php index 8afc4613716..5509c9e9524 100644 --- a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php +++ b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php @@ -13,20 +13,25 @@ class SoapAccountApiTest extends WebTestCase { /** @var Client */ - protected $client = null; + protected $client; public function setUp() { $this->markTestSkipped('BAP-717'); - $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + if (!isset($this->client)) { + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); - $this->client->soap( - "http://localhost/api/soap", - array( - 'location' => 'http://localhost/api/soap', - 'soap_version' => SOAP_1_2 - ) - ); + $this->client->soap( + "http://localhost/api/soap", + array( + 'location' => 'http://localhost/api/soap', + 'soap_version' => SOAP_1_2 + ) + ); + + } else { + $this->client->restart(); + } } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php index ba8dedf4e37..c80cdb27c86 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php @@ -13,7 +13,7 @@ class RestContactApiTest extends WebTestCase { /** @var Client */ - public $client = null; + protected $client; /** * @var array @@ -29,7 +29,11 @@ class RestContactApiTest extends WebTestCase public function setUp() { - $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + if (!isset($this->client)) { + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + } else { + $this->client->restart(); + } } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php index a1823b46c50..d4574e8ca09 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactGroupsApiTest.php @@ -13,11 +13,15 @@ class RestContactGroupsApiTest extends WebTestCase { /** @var Client */ - protected $client = null; + protected $client; public function setUp() { - $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + if (!isset($this->client)) { + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + } else { + $this->client->restart(); + } } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactApiTest.php index 57727e7e89a..e95b3789065 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactApiTest.php @@ -13,20 +13,25 @@ class SoapContactApiTest extends WebTestCase { /** @var Client */ - protected $client = null; + protected $client; public function setUp() { $this->markTestSkipped('BAP-717'); - $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + if (!isset($this->client)) { + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); - $this->client->soap( - "http://localhost/api/soap", - array( - 'location' => 'http://localhost/api/soap', - 'soap_version' => SOAP_1_2 - ) - ); + $this->client->soap( + "http://localhost/api/soap", + array( + 'location' => 'http://localhost/api/soap', + 'soap_version' => SOAP_1_2 + ) + ); + + } else { + $this->client->restart(); + } } /** diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php index 3b76057c4cd..e13a0dd13ca 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/SoapContactGroupApiTest.php @@ -13,19 +13,24 @@ class SoapContactGroupApiTest extends WebTestCase { /** @var Client */ - protected $client = null; + protected $client; public function setUp() { - $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); + if (!isset($this->client)) { + $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader()); - $this->client->soap( - "http://localhost/api/soap", - array( - 'location' => 'http://localhost/api/soap', - 'soap_version' => SOAP_1_2 - ) - ); + $this->client->soap( + "http://localhost/api/soap", + array( + 'location' => 'http://localhost/api/soap', + 'soap_version' => SOAP_1_2 + ) + ); + + } else { + $this->client->restart(); + } } /** From 4df4de91a80cc54650323b1892ebc136897dcc28 Mon Sep 17 00:00:00 2001 From: bogdan Date: Thu, 18 Jul 2013 18:18:06 +0300 Subject: [PATCH 47/65] BAP-1167: Quick access menu updates - Create actions added to shortcuts --- .../Bundle/AccountBundle/Resources/config/navigation.yml | 1 + .../Bundle/ContactBundle/Resources/config/navigation.yml | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml index 138af99dbbf..b2ecfa41f15 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml +++ b/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml @@ -10,6 +10,7 @@ oro_menu_config: route: 'orocrm_account_index' extras: routes: ['orocrm_account_*'] + description: List of accounts shortcut_new_account: label: Create new account diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml index c3275662667..969225c38fc 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml @@ -10,11 +10,13 @@ oro_menu_config: route: 'orocrm_contact_index' extras: routes: ['/^orocrm_contact_(?!group\w+|group\w+)\w+$/'] + description: List of contacts contact_group_list: label: 'Contact Groups' route: 'orocrm_contact_group_index' extras: routes: ['orocrm_contact_group_*'] + description: List of contact groups shortcut_new_contact: label: Create new contact route: orocrm_contact_create @@ -26,6 +28,11 @@ oro_menu_config: route: orocrm_contact_index extras: description: List of contacts + shortcut_new_contact_group: + label: Create new contact group + route: orocrm_contact_group_create + extras: + description: Create new contact group instance tree: application_menu: @@ -39,6 +46,7 @@ oro_menu_config: children: shortcut_new_contact: ~ shortcut_list_contacts: ~ + shortcut_new_contact_group: ~ oro_titles: orocrm_contact_index: Contacts From 1cb61d0e4fbae6c091eacafe42e5b4827231e7f9 Mon Sep 17 00:00:00 2001 From: yurio Date: Thu, 18 Jul 2013 19:27:27 +0300 Subject: [PATCH 48/65] BAP-1149: Form buttons - Refactor buttons - Add tests --- .../Controller/AccountController.php | 17 +++++++++-------- .../Resources/views/Account/update.html.twig | 4 ++-- .../Controller/ContactController.php | 19 ++++++++++--------- .../Controller/GroupController.php | 17 +++++++++-------- .../Resources/views/Contact/update.html.twig | 4 ++-- .../Resources/views/Group/update.html.twig | 4 ++-- 6 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php b/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php index ee62494e0ef..431afb854b2 100644 --- a/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php +++ b/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php @@ -119,15 +119,16 @@ public function updateAction(Account $entity = null) if ($this->get('orocrm_account.form.handler.account')->process($entity)) { $this->getFlashBag()->add('success', 'Account successfully saved'); - if ($this->getRequest()->get('additional_data') == 'save_and_stay') { - $routeName = 'orocrm_account_update'; - $params = array('id' => $entity->getId()); - } else { - $routeName = 'orocrm_account_index'; - $params = null; - } - return $this->redirect($this->generateUrl($routeName,$params)); + return $this->get('oro_ui.router')->actionRedirect( + array( + 'route' => 'orocrm_account_update', + 'parameters' => array('id' => $entity->getId()), + ), + array( + 'route' => 'orocrm_account_index', + ) + ); } return array( diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig index 925da74601f..06a0beef009 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig +++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig @@ -39,8 +39,8 @@ {{ UI.buttonSeparator() }} {% endif %} {{ UI.button({'path' : path('orocrm_account_index'), 'title' : 'Cancel', 'label' : 'Cancel'}) }} - {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save and Close'}) }} - {{ UI.buttonType({'type': 'button', 'class': 'btn-success', 'label': 'Save', 'additional_data': 'save_and_stay'}) }} + {{ UI.saveAndStayButton() }} + {{ UI.saveAndCloseButton() }} {% endblock %} {% block pageHeader %} diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php index 69f3088a070..a1b6d8c1104 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php @@ -101,15 +101,16 @@ public function updateAction(Contact $entity = null) if ($this->get('orocrm_contact.form.handler.contact')->process($entity)) { $this->getFlashBag()->add('success', 'Contact successfully saved'); - if ($this->getRequest()->get('additional_data') == 'save_and_stay') { - $routeName = 'orocrm_contact_update'; - $params = array('id' => $entity->getId()); - } else { - $routeName = 'orocrm_contact_index'; - $params = null; - } - - return $this->redirect($this->generateUrl($routeName,$params)); + + return $this->get('oro_ui.router')->actionRedirect( + array( + 'route' => 'orocrm_contact_update', + 'parameters' => array('id' => $entity->getId()), + ), + array( + 'route' => 'orocrm_contact_index', + ) + ); } return array( diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php b/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php index a62879b6e7f..bf422901359 100644 --- a/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php +++ b/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php @@ -61,15 +61,16 @@ public function updateAction(Group $entity) $this->get('session')->getFlashBag()->add('success', 'Group successfully saved'); if (!$this->getRequest()->get('_widgetContainer')) { - if ($this->getRequest()->get('additional_data') == 'save_and_stay') { - $routeName = 'orocrm_contact_group_update'; - $params = array('id' => $entity->getId()); - } else { - $routeName = 'orocrm_contact_group_index'; - $params = null; - } - return $this->redirect($this->generateUrl($routeName,$params)); + return $this->get('oro_ui.router')->actionRedirect( + array( + 'route' => 'orocrm_contact_group_update', + 'parameters' => array('id' => $entity->getId()), + ), + array( + 'route' => 'orocrm_contact_group_index', + ) + ); } } diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig index 5a904a866ba..ebf2a733bcb 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig @@ -41,8 +41,8 @@ {{ UI.buttonSeparator() }} {% endif %} {{ UI.button({'path' : path('orocrm_contact_index'), 'title' : 'Cancel', 'label' : 'Cancel'}) }} - {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save and Close'}) }} - {{ UI.buttonType({'type': 'button', 'class': 'btn-success', 'label': 'Save', 'additional_data': 'save_and_stay'}) }} + {{ UI.saveAndStayButton() }} + {{ UI.saveAndCloseButton() }} {% endblock %} {% block pageHeader %} diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig b/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig index 0bbe9c82abb..6ce1c14dfeb 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig +++ b/src/OroCRM/Bundle/ContactBundle/Resources/views/Group/update.html.twig @@ -40,8 +40,8 @@ {{ UI.buttonSeparator() }} {% endif %} {{ UI.button({'path' : path('orocrm_contact_group_index'), 'title' : 'Cancel', 'label' : 'Cancel'}) }} - {{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save and Close'}) }} - {{ UI.buttonType({'type': 'button', 'class': 'btn-success', 'label': 'Save', 'additional_data': 'save_and_stay'}) }} + {{ UI.saveAndStayButton() }} + {{ UI.saveAndCloseButton() }} {% endblock navButtons %} {% block pageHeader %} From 458a91cf59e5fe113c0fb63c64bba3cea7890101 Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Fri, 19 Jul 2013 13:17:26 +0300 Subject: [PATCH 49/65] BAP-1160: Functional API Tests Address Types - added types to Contact Address --- .../API/ContactRequest/request#1.yml | 19 +++++++++++++++---- .../Functional/API/RestContactApiTest.php | 4 +++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/ContactRequest/request#1.yml b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/ContactRequest/request#1.yml index b06e2cde3d2..1d12c2f01ff 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/ContactRequest/request#1.yml +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/ContactRequest/request#1.yml @@ -2,9 +2,20 @@ request: groups: ~ attributes: - first_name: Contact_fname_%str% - last_name: Contact_lname - name_prefix: Contact name prefix - description: Contact description + first_name: Contact_fname_%str% + last_name: Contact_lname + name_prefix: Contact name prefix + description: Contact description + addresses: + - + firstName: Contact_fname_%str%_address + lastName: Contact_lnamea_ddress + street: avenu 230 + city: New York + country: US + postalCode: 10001 + types: ['billing'] + primary: true + response: return: true \ No newline at end of file diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php index c80cdb27c86..c2a268c22b3 100755 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/API/RestContactApiTest.php @@ -5,6 +5,7 @@ use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase; use Oro\Bundle\TestFrameworkBundle\Test\ToolsAPI; use Oro\Bundle\TestFrameworkBundle\Test\Client; +use Oro\Bundle\AddressBundle\Entity\AddressType; /** * @outputBuffering enabled @@ -19,12 +20,13 @@ class RestContactApiTest extends WebTestCase * @var array */ protected $testAddress = array( - 'types' => array('shipping'), 'street' => 'contact_street', 'city' => 'contact_city', 'country' => 'US', 'state' => 'US.FL', 'postalCode' => '12345', + 'primary' => true, + 'types' => array(AddressType::TYPE_BILLING, AddressType::TYPE_SHIPPING), ); public function setUp() From a01e37942c6f324de103820b191f074634256e52 Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Fri, 19 Jul 2013 20:51:03 +0300 Subject: [PATCH 50/65] BAP-1159: Functional Selenium Tests Address Types - added Addresses and Types to Contacts --- .../Selenium/Contacts/CreateContactTest.php | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php index d135a17ef9e..09efbec9c06 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php @@ -8,6 +8,30 @@ class CreateContactTest extends \PHPUnit_Extensions_Selenium2TestCase { protected $coverageScriptUrl = PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL_COVERAGE; + protected $addressPrimary = array( + 'types' => array('billing'), + 'primary' => true, + 'firstName' => 'Address First Name', + 'lastName' => 'Address Last Name', + 'street' => 'Address Street', + 'city' => 'Address City', + 'postalCode' => '10001', + 'country' => 'United States', + 'state' => 'New York' + ); + + protected $addressSecondary = array( + 'types' => array('shipping'), + 'primary' => false, + 'firstName' => 'Address1 First Name', + 'lastName' => 'Address1 Last Name', + 'street' => 'Address1 Street', + 'city' => 'Address1 City', + 'postalCode' => '10001', + 'country' => 'United States', + 'state' => 'New York' + ); + protected function setUp() { $this->setHost(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_HOST); @@ -27,6 +51,8 @@ protected function tearDown() public function testCreateContact() { $contactname = 'Contact_'.mt_rand(); + $addressPrimary = array(); + $addressSecondary = array(); $login = new Login($this); $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) @@ -37,9 +63,21 @@ public function testCreateContact() ->setFirstName($contactname . '_first') ->setLastName($contactname . '_last') ->setEmail($contactname . '@mail.com') + ->setAddress($this->addressPrimary) + ->setAddress($this->addressSecondary, 1) ->save() ->assertTitle('Contacts') - ->assertMessage('Contact successfully saved'); + ->assertMessage('Contact successfully saved') + ->close() + ->filterBy('Email', $contactname . '@mail.com') + ->open(array($contactname)) + ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts') + ->edit() + ->getAddress($addressPrimary) + ->getAddress($addressSecondary, 1); + + $this->assertEquals($this->addressPrimary, $addressPrimary); + $this->assertEquals($this->addressSecondary, $addressSecondary); return $contactname; } @@ -60,11 +98,11 @@ public function testContactAutocmplete($contactname) ->setLastName($contactname . '_last_autocomplete') ->setAssignedTo('admin') ->setReportsTo($contactname) - ->setStreet('Street') - ->setCity('City') - ->setZipCode('Zip Code 000') - ->setCountry('Kazak') - ->setState('Aqm') + ->setAddressStreet('Street') + ->setAddressCity('City') + ->setAddressPostalCode('Zip Code 000') + ->setAddressCountry('Kazak') + ->setAddressState('Aqm') ->save() ->assertTitle('Contacts') ->assertMessage('Contact successfully saved') From 11a392914a58d2d657d445754f19e4e779202f5d Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Fri, 26 Jul 2013 13:43:37 +0300 Subject: [PATCH 51/65] BAP-1263: Fix menu navigation according with new UI - fixed menu navigation with new UI - added search pane --- .../Tests/Selenium/AclTest/AclTest.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php index f9e9f113684..a5964c8bf2e 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php @@ -90,11 +90,20 @@ public function testUserAccess($username) $login->setUsername($username) ->setPassword('123123q') ->submit(); - $login->byXPath("//div[@class='navbar application-menu']//a[contains(.,'System')]")->click(); - $login->assertElementNotPresent("//div[@id='system_tab']//a[contains(.,'Users')]", 'Element present so ACL for Users do not work'); - $login->assertElementNotPresent("//div[@id='system_tab']//a[contains(.,'Roles')]", 'Element present so ACL for User Roles do not work'); - $login->assertElementNotPresent("//div[@id='system_tab']//a[contains(.,'Groups')]", 'Element present so ACL for User Groups do not work'); - $login->assertElementNotPresent("//div[@id='system_tab']//a[contains(.,'Data Audit')]", 'Element present so ACL for Data Audit do not work'); + $login->moveto($login->byXPath("//div[@id='main-menu']/ul/li/a[contains(.,'System')]")); + $login->assertElementNotPresent( + "//div[@id='main-menu']/ul/li[a[contains(.,'System')]]//a[contains(.,'Users')]", + 'Element present so ACL for Users do not work' + ); + $login->assertElementNotPresent( + "//div[@id='main-menu']/ul/li[a[contains(.,'System')]]//a[contains(.,'Roles')]", + 'Element present so ACL for User Roles do not work'); + $login->assertElementNotPresent( + "//div[@id='main-menu']/ul/li[a[contains(.,'System')]]//a[contains(.,'Groups')]", + 'Element present so ACL for User Groups do not work'); + $login->assertElementNotPresent( + "//div[@id='main-menu']/ul/li[a[contains(.,'System')]]//a[contains(.,'Data Audit')]", + 'Element present so ACL for Data Audit do not work'); $login->assertElementNotPresent("//div[@id='search-div']", 'Element present so ACL for Search do not work'); $login->byXPath("//ul[@class='nav pull-right']//a[@class='dropdown-toggle']")->click(); $login->assertElementNotPresent("//ul[@class='dropdown-menu']//a[contains(., 'My User')]", 'Element present so ACL for Search do not work'); From 734293fd90bb9b75d31866e543aca7552bfb11b2 Mon Sep 17 00:00:00 2001 From: Bogdan Tsyganovskiy Date: Fri, 26 Jul 2013 18:16:00 +0300 Subject: [PATCH 52/65] BAP-1250: Breadcrumbs in Page Titles - Update title configs --- .../AccountBundle/Resources/config/navigation.yml | 6 +++--- .../ContactBundle/Resources/config/navigation.yml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml index b2ecfa41f15..65b03524259 100644 --- a/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml +++ b/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml @@ -37,7 +37,7 @@ oro_menu_config: shortcut_list_accounts: ~ oro_titles: - orocrm_account_index: Accounts - orocrm_account_view: %%account.name%% - Accounts + orocrm_account_index: ~ + orocrm_account_view: %%account.name%% orocrm_account_create: Create Account - orocrm_account_update: %%account.name%% - Accounts + orocrm_account_update: %%account.name%% diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml index 969225c38fc..120b80bfab3 100644 --- a/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml +++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml @@ -49,11 +49,11 @@ oro_menu_config: shortcut_new_contact_group: ~ oro_titles: - orocrm_contact_index: Contacts - orocrm_contact_view: %%contact.name%% - Contacts + orocrm_contact_index: ~ + orocrm_contact_view: %%contact.name%% orocrm_contact_create: Create Contact - orocrm_contact_update: %%contact.name%% - Contacts + orocrm_contact_update: %%contact.name%% - orocrm_contact_group_index: Contact Groups + orocrm_contact_group_index: ~ orocrm_contact_group_create: Create Contact Group - orocrm_contact_group_update: %%group.label%% - Contact Group + orocrm_contact_group_update: %%group.label%% From a99b45552d333714027f6be28e292f71b2d9d516 Mon Sep 17 00:00:00 2001 From: yurio Date: Sat, 27 Jul 2013 18:09:10 +0300 Subject: [PATCH 53/65] BAP-1246: breadcrumbs - fix tests --- .../Tests/Selenium/Accounts/CreateAccountTest.php | 2 +- .../TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php index 1219b6536ce..3cd30f780ed 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php @@ -37,7 +37,7 @@ public function testCreateAccount() ->add() ->setAccountName($accountname) ->save() - ->assertTitle('Accounts') + ->assertTitle('Accounts - Customers - ORO') ->assertMessage('Account successfully saved'); return $accountname; diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php index a5964c8bf2e..52c3762beea 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php @@ -63,7 +63,7 @@ public function testCreateUser($roleName) ->submit() ->openUsers() ->add() - ->assertTitle('Create User') + ->assertTitle('Create User - Users - System - ORO') ->setUsername($username) ->enable() ->setFirstpassword('123123q') From 178e58c925033b8db17aa74cecea43dd996b83ef Mon Sep 17 00:00:00 2001 From: yurio Date: Sat, 27 Jul 2013 18:25:25 +0300 Subject: [PATCH 54/65] BAP-1246: breadcrumbs - fix tests --- .../Tests/Selenium/Accounts/CreateAccountTest.php | 4 ++-- .../TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php index 3cd30f780ed..16e48f47da7 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php @@ -62,7 +62,7 @@ public function testAccountAutocmplete($accountname) ->setState('Aqm') ->setZipCode('Zip Code 000') ->save() - ->assertTitle('Accounts') + ->assertTitle('Accounts - Customers - OR') ->assertMessage('Account successfully saved'); } @@ -83,7 +83,7 @@ public function testUpdateAccount($accountname) ->filterBy('Name', $accountname) ->open(array($accountname)) ->edit() - ->assertTitle($accountname . ' - Accounts') + ->assertTitle($accountname . ' - Accounts - Customers - ORO') ->setAccountName($newAccountname) ->save() ->assertTitle('Accounts') diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php index 52c3762beea..cc0e1449d0c 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php @@ -75,7 +75,7 @@ public function testCreateUser($roleName) ->save() ->assertMessage('User successfully saved') ->close() - ->assertTitle('Users'); + ->assertTitle('Users - System - ORO'); return $username; } From 49d87265c56ff93e3baa7db109accd89261c961c Mon Sep 17 00:00:00 2001 From: yurio Date: Sat, 27 Jul 2013 18:43:44 +0300 Subject: [PATCH 55/65] BAP-1246: breadcrumbs - fix tests --- .../Tests/Selenium/Accounts/CreateAccountTest.php | 4 ++-- .../Tests/Selenium/Contacts/CreateContactTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php index 16e48f47da7..306b9d98ad5 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php @@ -62,7 +62,7 @@ public function testAccountAutocmplete($accountname) ->setState('Aqm') ->setZipCode('Zip Code 000') ->save() - ->assertTitle('Accounts - Customers - OR') + ->assertTitle('Accounts - Customers - ORO') ->assertMessage('Account successfully saved'); } @@ -86,7 +86,7 @@ public function testUpdateAccount($accountname) ->assertTitle($accountname . ' - Accounts - Customers - ORO') ->setAccountName($newAccountname) ->save() - ->assertTitle('Accounts') + ->assertTitle('Accounts - Customers - ORO') ->assertMessage('Account successfully saved') ->close(); diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php index 09efbec9c06..a18cf881c9b 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php @@ -66,7 +66,7 @@ public function testCreateContact() ->setAddress($this->addressPrimary) ->setAddress($this->addressSecondary, 1) ->save() - ->assertTitle('Contacts') + ->assertTitle('Contacts - Customers - ORO') ->assertMessage('Contact successfully saved') ->close() ->filterBy('Email', $contactname . '@mail.com') From a018d7452540f71055cf0947db51774c9a73adfa Mon Sep 17 00:00:00 2001 From: yurio Date: Sat, 27 Jul 2013 18:56:20 +0300 Subject: [PATCH 56/65] BAP-1246: breadcrumbs - fix tests --- .../Tests/Selenium/Accounts/CreateAccountTest.php | 2 +- .../Tests/Selenium/Contacts/CreateContactTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php index 306b9d98ad5..b4bf945276c 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php @@ -108,7 +108,7 @@ public function testDeleteAccount($accountname) ->filterBy('Name', $accountname) ->open(array($accountname)) ->delete() - ->assertTitle('Accounts') + ->assertTitle('Accounts - Customers - ORO') ->assertMessage('Item was deleted'); $login->openUsers()->filterBy('Name', $accountname)->assertNoDataMessage('No Accounts were found to match your search'); diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php index a18cf881c9b..1111afbcc46 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php @@ -71,7 +71,7 @@ public function testCreateContact() ->close() ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) - ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts') + ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers - ORO') ->edit() ->getAddress($addressPrimary) ->getAddress($addressSecondary, 1); @@ -104,7 +104,7 @@ public function testContactAutocmplete($contactname) ->setAddressCountry('Kazak') ->setAddressState('Aqm') ->save() - ->assertTitle('Contacts') + ->assertTitle('Contacts - Customers - ORO') ->assertMessage('Contact successfully saved') ->close(); } @@ -129,7 +129,7 @@ public function testUpdateContact($contactname) ->edit() ->setFirstName($newContactname . '_first') ->save() - ->assertTitle('Contacts') + ->assertTitle('Contacts - Customers - ORO') ->assertMessage('Contact successfully saved') ->close(); @@ -151,7 +151,7 @@ public function testDeleteContact($contactname) ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) ->delete() - ->assertTitle('Contacts') + ->assertTitle('Contacts - Customers - ORO') ->assertMessage('Item was deleted'); $login->openUsers()->filterBy('Email', $contactname . '@mail.com')->assertNoDataMessage('No Contacts were found to match your search'); From e622176092e41d861f9ba30e6648c10f3e460378 Mon Sep 17 00:00:00 2001 From: yurio Date: Sat, 27 Jul 2013 19:08:12 +0300 Subject: [PATCH 57/65] BAP-1246: breadcrumbs - fix tests --- .../Tests/Selenium/Contacts/CreateContactTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php index 1111afbcc46..2371a333083 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php @@ -125,7 +125,7 @@ public function testUpdateContact($contactname) ->openContacts() ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) - ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts') + ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers - ORO') ->edit() ->setFirstName($newContactname . '_first') ->save() From 0550c0910fde2cc67fbbe7c3439896a81e8c821e Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Mon, 29 Jul 2013 13:09:53 +0300 Subject: [PATCH 58/65] BAP-1172: Functional Selenium Tests for Search by tag - CR changes --- .../Tests/Selenium/Tags/TagsAssignTest.php | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Tags/TagsAssignTest.php diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Tags/TagsAssignTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Tags/TagsAssignTest.php new file mode 100644 index 00000000000..0af99a16869 --- /dev/null +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Tags/TagsAssignTest.php @@ -0,0 +1,155 @@ +setHost(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_HOST); + $this->setPort(intval(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PORT)); + $this->setBrowser(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM2_BROWSER); + $this->setBrowserUrl(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL); + } + + protected function tearDown() + { + $this->cookie()->clear(); + } + + /** + * @return string + */ + public function testCreateTag() + { + $tagname = 'Tag_'.mt_rand(); + + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openTags() + ->add() + ->assertTitle('Create tag - Tags - System - ORO') + ->setTagname($tagname) + ->save() + ->assertMessage('Tag successfully saved') + ->assertTitle('Tags - System - ORO') + ->close(); + + return $tagname; + } + + /** + * @depends testCreateTag + * @param $tagname + */ + public function testAccountTag($tagname) + { + $accountname = 'Account_'.mt_rand(); + + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openAccounts() + ->add() + ->setAccountName($accountname) + ->verifyTag($tagname) + ->setTag('New_' . $tagname) + ->save() + ->assertMessage('Account successfully saved') + ->close() + ->filterBy('Name', $accountname) + ->open(array($accountname)) + ->verifyTag($tagname); + } + + /** + * @depends testCreateTag + * @param $tagname + */ + public function testContactTag($tagname) + { + $contactname = 'Contact_'.mt_rand(); + + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openContacts() + ->add() + ->setFirstName($contactname . '_first') + ->setLastName($contactname . '_last') + ->setEmail($contactname . '@mail.com') + ->verifyTag($tagname) + ->setTag('New_' . $tagname) + ->save() + ->assertMessage('Contact successfully saved') + ->close() + ->filterBy('Email', $contactname . '@mail.com') + ->open(array($contactname)) + ->verifyTag($tagname); + } + + /** + * @depends testCreateTag + * @param $tagname + */ + public function testUserTag($tagname) + { + $username = 'User_'.mt_rand(); + + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit() + ->openUsers() + ->add() + ->setUsername($username) + ->enable() + ->setFirstpassword('123123q') + ->setSecondpassword('123123q') + ->setFirstname('First_'.$username) + ->setLastname('Last_'.$username) + ->setEmail($username.'@mail.com') + ->setRoles(array('Manager')) + ->verifyTag($tagname) + ->setTag('New_' . $tagname) + ->save() + ->assertMessage('User successfully saved') + ->close() + ->filterBy('Username', $username) + ->open(array($username)) + ->verifyTag($tagname); + } + + + /** + * @depends testCreateTag + * @depends testAccountTag + * @depends testContactTag + * @depends testUserTag + * @param $tagname + */ + public function testTagSearch($tagname) + { + $login = new Login($this); + $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN) + ->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS) + ->submit(); + $tagsearch = new Search($this); + $result = $tagsearch->search('New_' . $tagname) + ->submit() + ->select('New_' . $tagname) + ->assertEntity('User', 1) + ->assertEntity('Contact', 1) + ->assertEntity('Account', 1); + $this->assertNotEmpty($result); + } +} From 9ac854b6bde12fa2e360b95743d20345724d422e Mon Sep 17 00:00:00 2001 From: Bogdan Tsyganovskiy Date: Mon, 29 Jul 2013 16:18:20 +0300 Subject: [PATCH 59/65] BAP-1284: Incorrect Titles and menu - Fixed Selenium Tests --- .../Tests/Selenium/Accounts/CreateAccountTest.php | 10 +++++----- .../Tests/Selenium/AclTest/AclTest.php | 4 ++-- .../Tests/Selenium/Contacts/CreateContactTest.php | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php index b4bf945276c..523f687e711 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php @@ -37,7 +37,7 @@ public function testCreateAccount() ->add() ->setAccountName($accountname) ->save() - ->assertTitle('Accounts - Customers - ORO') + ->assertTitle('Accounts - Customers - OroCRM') ->assertMessage('Account successfully saved'); return $accountname; @@ -62,7 +62,7 @@ public function testAccountAutocmplete($accountname) ->setState('Aqm') ->setZipCode('Zip Code 000') ->save() - ->assertTitle('Accounts - Customers - ORO') + ->assertTitle('Accounts - Customers - OroCRM') ->assertMessage('Account successfully saved'); } @@ -83,10 +83,10 @@ public function testUpdateAccount($accountname) ->filterBy('Name', $accountname) ->open(array($accountname)) ->edit() - ->assertTitle($accountname . ' - Accounts - Customers - ORO') + ->assertTitle($accountname . ' - Accounts - Customers - OroCRM') ->setAccountName($newAccountname) ->save() - ->assertTitle('Accounts - Customers - ORO') + ->assertTitle('Accounts - Customers - OroCRM') ->assertMessage('Account successfully saved') ->close(); @@ -108,7 +108,7 @@ public function testDeleteAccount($accountname) ->filterBy('Name', $accountname) ->open(array($accountname)) ->delete() - ->assertTitle('Accounts - Customers - ORO') + ->assertTitle('Accounts - Customers - OroCRM') ->assertMessage('Item was deleted'); $login->openUsers()->filterBy('Name', $accountname)->assertNoDataMessage('No Accounts were found to match your search'); diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php index 8f6883c2593..03e9413f9cd 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php @@ -63,7 +63,7 @@ public function testCreateUser($roleName) ->submit() ->openUsers() ->add() - ->assertTitle('Create User - Users - System - ORO') + ->assertTitle('Create User - Users - System - OroCRM') ->setUsername($username) ->enable() ->setFirstpassword('123123q') @@ -75,7 +75,7 @@ public function testCreateUser($roleName) ->save() ->assertMessage('User successfully saved') ->close() - ->assertTitle('Users - System - ORO'); + ->assertTitle('Users - System - OroCRM'); return $username; } diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php index 2371a333083..14eb5bd2d60 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php @@ -66,12 +66,12 @@ public function testCreateContact() ->setAddress($this->addressPrimary) ->setAddress($this->addressSecondary, 1) ->save() - ->assertTitle('Contacts - Customers - ORO') + ->assertTitle('Contacts - Customers - OroCRM') ->assertMessage('Contact successfully saved') ->close() ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) - ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers - ORO') + ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers - OroCRM') ->edit() ->getAddress($addressPrimary) ->getAddress($addressSecondary, 1); @@ -104,7 +104,7 @@ public function testContactAutocmplete($contactname) ->setAddressCountry('Kazak') ->setAddressState('Aqm') ->save() - ->assertTitle('Contacts - Customers - ORO') + ->assertTitle('Contacts - Customers - OroCRM') ->assertMessage('Contact successfully saved') ->close(); } @@ -125,11 +125,11 @@ public function testUpdateContact($contactname) ->openContacts() ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) - ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers - ORO') + ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers - OroCRM') ->edit() ->setFirstName($newContactname . '_first') ->save() - ->assertTitle('Contacts - Customers - ORO') + ->assertTitle('Contacts - Customers - OroCRM') ->assertMessage('Contact successfully saved') ->close(); @@ -151,7 +151,7 @@ public function testDeleteContact($contactname) ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) ->delete() - ->assertTitle('Contacts - Customers - ORO') + ->assertTitle('Contacts - Customers - OroCRM') ->assertMessage('Item was deleted'); $login->openUsers()->filterBy('Email', $contactname . '@mail.com')->assertNoDataMessage('No Contacts were found to match your search'); From 9ceb7a14de513c294b40ead357b8a1dac95191b9 Mon Sep 17 00:00:00 2001 From: Bogdan Tsyganovskiy Date: Mon, 29 Jul 2013 16:52:17 +0300 Subject: [PATCH 60/65] BAP-1284: Incorrect Titles and menu - Fixed Selenium Tests --- .../TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php index 03e9413f9cd..ff759e8ff0a 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php @@ -174,13 +174,13 @@ public function testViewAccountsContacts($username) ->setPassword('123123q') ->submit() ->openAccounts() - ->assertTitle('Accounts') + ->assertTitle('Accounts - Customers - OroCRM') ->assertElementNotPresent("//div[@class='container-fluid']//a[@title='Create account']") ->openContacts() - ->assertTitle('Contacts') + ->assertTitle('Contacts - Customers - OroCRM') ->assertElementNotPresent("//div[@class='container-fluid']//a[@title='Create contact']") ->openContactGroups() - ->assertTitle('Contact Groups') + ->assertTitle('Contact Groups - Customers - OroCRM') ->assertElementNotPresent("//div[@class='container-fluid']//a[@title='Create contact group']") ->openAclCheck() ->assertAcl('account/create') From 5cdf249c6b25ad4c7c3bb08bdcea2ec3ccb58adb Mon Sep 17 00:00:00 2001 From: Bogdan Tsyganovskiy Date: Mon, 29 Jul 2013 19:34:17 +0300 Subject: [PATCH 61/65] BAP-1301: Refactor pin Tabs titles - Removed Oro title suffix - Changed selenium tests --- .../Tests/Selenium/Accounts/CreateAccountTest.php | 10 +++++----- .../Tests/Selenium/AclTest/AclTest.php | 10 +++++----- .../Tests/Selenium/Contacts/CreateContactTest.php | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php index 523f687e711..95a004472b2 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Accounts/CreateAccountTest.php @@ -37,7 +37,7 @@ public function testCreateAccount() ->add() ->setAccountName($accountname) ->save() - ->assertTitle('Accounts - Customers - OroCRM') + ->assertTitle('Accounts - Customers') ->assertMessage('Account successfully saved'); return $accountname; @@ -62,7 +62,7 @@ public function testAccountAutocmplete($accountname) ->setState('Aqm') ->setZipCode('Zip Code 000') ->save() - ->assertTitle('Accounts - Customers - OroCRM') + ->assertTitle('Accounts - Customers') ->assertMessage('Account successfully saved'); } @@ -83,10 +83,10 @@ public function testUpdateAccount($accountname) ->filterBy('Name', $accountname) ->open(array($accountname)) ->edit() - ->assertTitle($accountname . ' - Accounts - Customers - OroCRM') + ->assertTitle($accountname . ' - Accounts - Customers') ->setAccountName($newAccountname) ->save() - ->assertTitle('Accounts - Customers - OroCRM') + ->assertTitle('Accounts - Customers') ->assertMessage('Account successfully saved') ->close(); @@ -108,7 +108,7 @@ public function testDeleteAccount($accountname) ->filterBy('Name', $accountname) ->open(array($accountname)) ->delete() - ->assertTitle('Accounts - Customers - OroCRM') + ->assertTitle('Accounts - Customers') ->assertMessage('Item was deleted'); $login->openUsers()->filterBy('Name', $accountname)->assertNoDataMessage('No Accounts were found to match your search'); diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php index ff759e8ff0a..94c2aa4f0e0 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/AclTest/AclTest.php @@ -63,7 +63,7 @@ public function testCreateUser($roleName) ->submit() ->openUsers() ->add() - ->assertTitle('Create User - Users - System - OroCRM') + ->assertTitle('Create User - Users - System') ->setUsername($username) ->enable() ->setFirstpassword('123123q') @@ -75,7 +75,7 @@ public function testCreateUser($roleName) ->save() ->assertMessage('User successfully saved') ->close() - ->assertTitle('Users - System - OroCRM'); + ->assertTitle('Users - System'); return $username; } @@ -174,13 +174,13 @@ public function testViewAccountsContacts($username) ->setPassword('123123q') ->submit() ->openAccounts() - ->assertTitle('Accounts - Customers - OroCRM') + ->assertTitle('Accounts - Customers') ->assertElementNotPresent("//div[@class='container-fluid']//a[@title='Create account']") ->openContacts() - ->assertTitle('Contacts - Customers - OroCRM') + ->assertTitle('Contacts - Customers') ->assertElementNotPresent("//div[@class='container-fluid']//a[@title='Create contact']") ->openContactGroups() - ->assertTitle('Contact Groups - Customers - OroCRM') + ->assertTitle('Contact Groups - Customers') ->assertElementNotPresent("//div[@class='container-fluid']//a[@title='Create contact group']") ->openAclCheck() ->assertAcl('account/create') diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php index 14eb5bd2d60..f655447f907 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Contacts/CreateContactTest.php @@ -66,12 +66,12 @@ public function testCreateContact() ->setAddress($this->addressPrimary) ->setAddress($this->addressSecondary, 1) ->save() - ->assertTitle('Contacts - Customers - OroCRM') + ->assertTitle('Contacts - Customers') ->assertMessage('Contact successfully saved') ->close() ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) - ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers - OroCRM') + ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers') ->edit() ->getAddress($addressPrimary) ->getAddress($addressSecondary, 1); @@ -104,7 +104,7 @@ public function testContactAutocmplete($contactname) ->setAddressCountry('Kazak') ->setAddressState('Aqm') ->save() - ->assertTitle('Contacts - Customers - OroCRM') + ->assertTitle('Contacts - Customers') ->assertMessage('Contact successfully saved') ->close(); } @@ -125,11 +125,11 @@ public function testUpdateContact($contactname) ->openContacts() ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) - ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers - OroCRM') + ->assertTitle($contactname . '_last, ' . $contactname . '_first - Contacts - Customers') ->edit() ->setFirstName($newContactname . '_first') ->save() - ->assertTitle('Contacts - Customers - OroCRM') + ->assertTitle('Contacts - Customers') ->assertMessage('Contact successfully saved') ->close(); @@ -151,7 +151,7 @@ public function testDeleteContact($contactname) ->filterBy('Email', $contactname . '@mail.com') ->open(array($contactname)) ->delete() - ->assertTitle('Contacts - Customers - OroCRM') + ->assertTitle('Contacts - Customers') ->assertMessage('Item was deleted'); $login->openUsers()->filterBy('Email', $contactname . '@mail.com')->assertNoDataMessage('No Contacts were found to match your search'); From 249d1cbd17efee7643954855366ebfb1c65f12f8 Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Tue, 30 Jul 2013 10:32:37 +0300 Subject: [PATCH 62/65] BAP-1284: Incorrect Titles and menu - Fixed Selenium Tests --- .../Tests/Selenium/Tags/TagsAssignTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Tags/TagsAssignTest.php b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Tags/TagsAssignTest.php index 0af99a16869..6d1abf8a6ff 100644 --- a/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Tags/TagsAssignTest.php +++ b/src/OroCRM/Bundle/TestFrameworkBundle/Tests/Selenium/Tags/TagsAssignTest.php @@ -35,11 +35,11 @@ public function testCreateTag() ->submit() ->openTags() ->add() - ->assertTitle('Create tag - Tags - System - ORO') + ->assertTitle('Create Tag - Tags - System') ->setTagname($tagname) ->save() ->assertMessage('Tag successfully saved') - ->assertTitle('Tags - System - ORO') + ->assertTitle('Tags - System') ->close(); return $tagname; From 5262e601a827c8fad688b97134bbfc6bf8239c64 Mon Sep 17 00:00:00 2001 From: Yevhen Shyshkin Date: Tue, 30 Jul 2013 13:33:18 +0300 Subject: [PATCH 63/65] BAP-1304: Home Page. Add product version at the bottom of page - added hardcoded application version --- .../DashboardBundle/Resources/views/Default/index.html.twig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/OroCRM/Bundle/DashboardBundle/Resources/views/Default/index.html.twig b/src/OroCRM/Bundle/DashboardBundle/Resources/views/Default/index.html.twig index b415cd2336d..71ff7c5850d 100644 --- a/src/OroCRM/Bundle/DashboardBundle/Resources/views/Default/index.html.twig +++ b/src/OroCRM/Bundle/DashboardBundle/Resources/views/Default/index.html.twig @@ -53,6 +53,11 @@ {{ __.renderWidget(widget) }} {% if loop.index is even %}{% endif %} {% endfor %} + + +
+ {# TODO Replace hardcoded version with data from backend #} + Version: 1.0.0-alpha4
{% endblock %} From 98f81f363fb7cf8e230dede8d9bdc84e410b20da Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Wed, 31 Jul 2013 14:30:24 +0300 Subject: [PATCH 64/65] Updated composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 056c6babe50..02657b32523 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ }, "require": { "php": ">=5.3.3", - "oro/platform": "dev-master" + "oro/platform": "dev-release" }, "repositories": [ { From 684f49ec33a4538ae58aa8ca96861bdfa728746a Mon Sep 17 00:00:00 2001 From: Roman Grebenchuk Date: Wed, 31 Jul 2013 16:14:27 +0300 Subject: [PATCH 65/65] Merge composer.json --- composer.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 02657b32523..510f5775d6c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "oro/crm", "description": "OroCRM", - "homepage": "https://github.com/laboro/crm.git", + "homepage": "https://github.com/orocrm/crm.git", "license": "The Open Software License version 3.0", "autoload": { "psr-0": { "OroCRM\\Bundle": "src/" } @@ -13,11 +13,7 @@ "repositories": [ { "type": "vcs", - "url": "https://github.com/laboro/platform.git" - }, - { - "type": "vcs", - "url": "https://github.com/laboro/SonataAdminBundle.git" + "url": "https://github.com/orocrm/SonataAdminBundle.git" } ], "minimum-stability": "dev"