email phone fields save fix
This commit is contained in:
@@ -69,7 +69,7 @@ class Saver implements SaverInterface
|
||||
$emailAddressData = $entity->get('emailAddressData');
|
||||
}
|
||||
|
||||
if ($emailAddressData !== null) {
|
||||
if ($emailAddressData !== null && $entity->isAttributeChanged('emailAddressData')) {
|
||||
$this->storeData($entity);
|
||||
|
||||
return;
|
||||
|
||||
@@ -74,7 +74,7 @@ class Saver implements SaverInterface
|
||||
$phoneNumberData = $entity->get('phoneNumberData');
|
||||
}
|
||||
|
||||
if ($phoneNumberData !== null) {
|
||||
if ($phoneNumberData !== null && $entity->isAttributeChanged('phoneNumberData')) {
|
||||
$this->storeData($entity);
|
||||
|
||||
return;
|
||||
|
||||
@@ -31,10 +31,12 @@ namespace tests\integration\Espo\Core\FieldProcessing;
|
||||
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
use Espo\Modules\Crm\Entities\Contact;
|
||||
use Espo\Core\{
|
||||
Field\EmailAddressGroup,
|
||||
Field\EmailAddress,
|
||||
};
|
||||
Record\ServiceContainer,
|
||||
Record\UpdateParams};
|
||||
|
||||
class EmailAddressTest extends \tests\integration\Core\BaseTestCase
|
||||
{
|
||||
@@ -120,4 +122,22 @@ class EmailAddressTest extends \tests\integration\Core\BaseTestCase
|
||||
|
||||
$this->assertEquals('test@test.com', $group->getPrimary()->getAddress());
|
||||
}
|
||||
|
||||
public function testEmailAddress3(): void
|
||||
{
|
||||
$service = $this->getContainer()->getByClass(ServiceContainer::class)->getByClass(Contact::class);
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
/** @var Contact $contact */
|
||||
$contact = $em->createEntity(Contact::ENTITY_TYPE);
|
||||
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
$service->update($contact->getId(), (object) [
|
||||
'emailAddress' => 'test@test.com',
|
||||
], UpdateParams::create());
|
||||
|
||||
$em->refreshEntity($contact);
|
||||
|
||||
$this->assertEquals('test@test.com', $contact->getEmailAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ namespace tests\integration\Espo\Core\FieldProcessing;
|
||||
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
use Espo\Modules\Crm\Entities\Contact;
|
||||
use Espo\Core\{
|
||||
Field\PhoneNumberGroup,
|
||||
Field\PhoneNumber,
|
||||
};
|
||||
Record\ServiceContainer,
|
||||
Record\UpdateParams};
|
||||
|
||||
class PhoneNumberTest extends \tests\integration\Core\BaseTestCase
|
||||
{
|
||||
@@ -99,4 +101,22 @@ class PhoneNumberTest extends \tests\integration\Core\BaseTestCase
|
||||
|
||||
$this->assertEquals(1, $group5->getCount());
|
||||
}
|
||||
|
||||
public function testPhoneNumber2(): void
|
||||
{
|
||||
$service = $this->getContainer()->getByClass(ServiceContainer::class)->getByClass(Contact::class);
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
/** @var Contact $contact */
|
||||
$contact = $em->createEntity(Contact::ENTITY_TYPE);
|
||||
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
$service->update($contact->getId(), (object) [
|
||||
'phoneNumber' => '+11111111111',
|
||||
], UpdateParams::create());
|
||||
|
||||
$em->refreshEntity($contact);
|
||||
|
||||
$this->assertEquals('+11111111111', $contact->getPhoneNumber());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user