From 82a9779b09a90fa076b4bf08b9272dc7f176d6d9 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 19 Feb 2021 14:28:57 +0200 Subject: [PATCH] renaming --- .../Classes/AddressFormatters/Formatter1.php | 4 +- .../Classes/AddressFormatters/Formatter2.php | 4 +- .../Classes/AddressFormatters/Formatter3.php | 4 +- .../Classes/AddressFormatters/Formatter4.php | 4 +- .../Core/Action/Actions/ConvertCurrency.php | 4 +- .../Address/{AddressValue.php => Address.php} | 6 +- ...ctor.php => AddressAttributeExtractor.php} | 4 +- ...essValueBuilder.php => AddressBuilder.php} | 8 +- ...essValueFactory.php => AddressFactory.php} | 7 +- .../FieldUtils/Address/AddressFormatter.php | 2 +- .../Address/AddressValueEntityMedium.php | 199 ------------------ .../{CurrencyValue.php => Currency.php} | 2 +- ...tor.php => CurrencyAttributeExtractor.php} | 4 +- .../FieldUtils/Currency/CurrencyConverter.php | 12 +- ...cyValueFactory.php => CurrencyFactory.php} | 6 +- .../Actions/MassConvertCurrency.php | 4 +- .../Espo/Tools/Export/Formats/Xlsx.php | 4 +- .../Address/AddressFormattersTest.php | 12 +- .../{AddressValueTest.php => AddressTest.php} | 16 +- .../Currency/CurrencyConverterTest.php | 10 +- ...CurrencyValueTest.php => CurrencyTest.php} | 34 +-- 21 files changed, 75 insertions(+), 275 deletions(-) rename application/Espo/Core/FieldUtils/Address/{AddressValue.php => Address.php} (96%) rename application/Espo/Core/FieldUtils/Address/{AddressValueAttributeExtractor.php => AddressAttributeExtractor.php} (93%) rename application/Espo/Core/FieldUtils/Address/{AddressValueBuilder.php => AddressBuilder.php} (94%) rename application/Espo/Core/FieldUtils/Address/{AddressValueFactory.php => AddressFactory.php} (93%) delete mode 100644 application/Espo/Core/FieldUtils/Address/AddressValueEntityMedium.php rename application/Espo/Core/FieldUtils/Currency/{CurrencyValue.php => Currency.php} (99%) rename application/Espo/Core/FieldUtils/Currency/{CurrencyValueAttributeExtractor.php => CurrencyAttributeExtractor.php} (92%) rename application/Espo/Core/FieldUtils/Currency/{CurrencyValueFactory.php => CurrencyFactory.php} (93%) rename tests/unit/Espo/Core/FieldUtils/Address/{AddressValueTest.php => AddressTest.php} (90%) rename tests/unit/Espo/Core/FieldUtils/Currency/{CurrencyValueTest.php => CurrencyTest.php} (83%) diff --git a/application/Espo/Classes/AddressFormatters/Formatter1.php b/application/Espo/Classes/AddressFormatters/Formatter1.php index 2b5183de38..2a6c68912a 100644 --- a/application/Espo/Classes/AddressFormatters/Formatter1.php +++ b/application/Espo/Classes/AddressFormatters/Formatter1.php @@ -31,12 +31,12 @@ namespace Espo\Classes\AddressFormatters; use Espo\Core\FieldUtils\Address\{ AddressFormatter, - AddressValue, + Address, }; class Formatter1 implements AddressFormatter { - public function format(AddressValue $address) : string + public function format(Address $address) : string { $result = ''; diff --git a/application/Espo/Classes/AddressFormatters/Formatter2.php b/application/Espo/Classes/AddressFormatters/Formatter2.php index ce362bd963..394de30778 100644 --- a/application/Espo/Classes/AddressFormatters/Formatter2.php +++ b/application/Espo/Classes/AddressFormatters/Formatter2.php @@ -31,12 +31,12 @@ namespace Espo\Classes\AddressFormatters; use Espo\Core\FieldUtils\Address\{ AddressFormatter, - AddressValue, + Address, }; class Formatter2 implements AddressFormatter { - public function format(AddressValue $address) : string + public function format(Address $address) : string { $result = ''; diff --git a/application/Espo/Classes/AddressFormatters/Formatter3.php b/application/Espo/Classes/AddressFormatters/Formatter3.php index 1184759d45..96a09d11c0 100644 --- a/application/Espo/Classes/AddressFormatters/Formatter3.php +++ b/application/Espo/Classes/AddressFormatters/Formatter3.php @@ -31,12 +31,12 @@ namespace Espo\Classes\AddressFormatters; use Espo\Core\FieldUtils\Address\{ AddressFormatter, - AddressValue, + Address, }; class Formatter3 implements AddressFormatter { - public function format(AddressValue $address) : string + public function format(Address $address) : string { $result = ''; diff --git a/application/Espo/Classes/AddressFormatters/Formatter4.php b/application/Espo/Classes/AddressFormatters/Formatter4.php index 799a95221d..66dec8c2b0 100644 --- a/application/Espo/Classes/AddressFormatters/Formatter4.php +++ b/application/Espo/Classes/AddressFormatters/Formatter4.php @@ -31,12 +31,12 @@ namespace Espo\Classes\AddressFormatters; use Espo\Core\FieldUtils\Address\{ AddressFormatter, - AddressValue, + Address, }; class Formatter4 implements AddressFormatter { - public function format(AddressValue $address) : string + public function format(Address $address) : string { $result = ''; diff --git a/application/Espo/Core/Action/Actions/ConvertCurrency.php b/application/Espo/Core/Action/Actions/ConvertCurrency.php index 75672b38c4..21f1b4f30c 100644 --- a/application/Espo/Core/Action/Actions/ConvertCurrency.php +++ b/application/Espo/Core/Action/Actions/ConvertCurrency.php @@ -42,7 +42,7 @@ use Espo\Core\{ Utils\Metadata, FieldUtils\Currency\CurrencyConfigDataProvider, FieldUtils\Currency\CurrencyConverter, - FieldUtils\Currency\CurrencyValue, + FieldUtils\Currency\Currency, FieldUtils\Currency\CurrencyRates, }; @@ -139,7 +139,7 @@ class ConvertCurrency implements Action continue; } - $value = new CurrencyValue($amount, $code); + $value = new Currency($amount, $code); $convertedValue = $this->currencyConverter->convertWithRates($value, $targetCurrency, $rates); diff --git a/application/Espo/Core/FieldUtils/Address/AddressValue.php b/application/Espo/Core/FieldUtils/Address/Address.php similarity index 96% rename from application/Espo/Core/FieldUtils/Address/AddressValue.php rename to application/Espo/Core/FieldUtils/Address/Address.php index e4b1993686..af1f2fb9a1 100644 --- a/application/Espo/Core/FieldUtils/Address/AddressValue.php +++ b/application/Espo/Core/FieldUtils/Address/Address.php @@ -32,7 +32,7 @@ namespace Espo\Core\FieldUtils\Address; /** * An address value. */ -class AddressValue +class Address { protected $street = null; @@ -157,8 +157,8 @@ class AddressValue return $obj; } - public static function createBuilder() : AddressValueBuilder + public static function createBuilder() : AddressBuilder { - return new AddressValueBuilder(); + return new AddressBuilder(); } } diff --git a/application/Espo/Core/FieldUtils/Address/AddressValueAttributeExtractor.php b/application/Espo/Core/FieldUtils/Address/AddressAttributeExtractor.php similarity index 93% rename from application/Espo/Core/FieldUtils/Address/AddressValueAttributeExtractor.php rename to application/Espo/Core/FieldUtils/Address/AddressAttributeExtractor.php index 05175ea67a..83eec85724 100644 --- a/application/Espo/Core/FieldUtils/Address/AddressValueAttributeExtractor.php +++ b/application/Espo/Core/FieldUtils/Address/AddressAttributeExtractor.php @@ -31,11 +31,11 @@ namespace Espo\Core\FieldUtils\Address; use StdClass; -class AddressValueAttributeExtractor // implements \Espo\ORM\Value\AttributeExtractable +class AddressAttributeExtractor // implements \Espo\ORM\Value\AttributeExtractable { private $value; - public function __construct(AddressValue $value) + public function __construct(Address $value) { $this->value = $value; } diff --git a/application/Espo/Core/FieldUtils/Address/AddressValueBuilder.php b/application/Espo/Core/FieldUtils/Address/AddressBuilder.php similarity index 94% rename from application/Espo/Core/FieldUtils/Address/AddressValueBuilder.php rename to application/Espo/Core/FieldUtils/Address/AddressBuilder.php index 9bb937bc59..7ada24a824 100644 --- a/application/Espo/Core/FieldUtils/Address/AddressValueBuilder.php +++ b/application/Espo/Core/FieldUtils/Address/AddressBuilder.php @@ -32,7 +32,7 @@ namespace Espo\Core\FieldUtils\Address; /** * An address value builder. */ -class AddressValueBuilder +class AddressBuilder { protected $street; @@ -44,7 +44,7 @@ class AddressValueBuilder protected $postalCode; - public function clone(AddressValue $address) : self + public function clone(Address $address) : self { $this->setStreet($address->getStreet()); $this->setCity($address->getCity()); @@ -90,9 +90,9 @@ class AddressValueBuilder return $this; } - public function build() : AddressValue + public function build() : Address { - return AddressValue::fromRaw([ + return Address::fromRaw([ 'street' => $this->street, 'city' => $this->city, 'country' => $this->country, diff --git a/application/Espo/Core/FieldUtils/Address/AddressValueFactory.php b/application/Espo/Core/FieldUtils/Address/AddressFactory.php similarity index 93% rename from application/Espo/Core/FieldUtils/Address/AddressValueFactory.php rename to application/Espo/Core/FieldUtils/Address/AddressFactory.php index 49320ef6db..ccda342077 100644 --- a/application/Espo/Core/FieldUtils/Address/AddressValueFactory.php +++ b/application/Espo/Core/FieldUtils/Address/AddressFactory.php @@ -33,17 +33,16 @@ use Espo\{ ORM\Entity, }; -class AddressValueFactory // implements \Espo\ORM\Value\ValueFactory +class AddressFactory // implements \Espo\ORM\Value\ValueFactory { - public function isCreatableFromEntity(Entity $entity, string $field) : bool { return true; } - public function createFromEntity(Entity $entity, string $field) : AddressValue + public function createFromEntity(Entity $entity, string $field) : Address { - return (new AddressValueBuilder()) + return (new AddressBuilder()) ->setStreet($entity->get($field . 'Street')) ->setCity($entity->get($field . 'City')) ->setCountry($entity->get($field . 'Country')) diff --git a/application/Espo/Core/FieldUtils/Address/AddressFormatter.php b/application/Espo/Core/FieldUtils/Address/AddressFormatter.php index baca2ef422..f43d2611e2 100644 --- a/application/Espo/Core/FieldUtils/Address/AddressFormatter.php +++ b/application/Espo/Core/FieldUtils/Address/AddressFormatter.php @@ -34,5 +34,5 @@ namespace Espo\Core\FieldUtils\Address; */ interface AddressFormatter { - public function format(AddressValue $address) : string; + public function format(Address $address) : string; } diff --git a/application/Espo/Core/FieldUtils/Address/AddressValueEntityMedium.php b/application/Espo/Core/FieldUtils/Address/AddressValueEntityMedium.php deleted file mode 100644 index 4aa4868384..0000000000 --- a/application/Espo/Core/FieldUtils/Address/AddressValueEntityMedium.php +++ /dev/null @@ -1,199 +0,0 @@ -street !== null; - } - - public function hasCity() : bool - { - return $this->city !== null; - } - - public function hasCountry() : bool - { - return $this->country !== null; - } - - public function hasState() : bool - { - return $this->state !== null; - } - - public function hasPostalCode() : bool - { - return $this->postalCode !== null; - } - - public function getStreet() : ?string - { - return $this->street; - } - - public function getCity() : ?string - { - return $this->city; - } - - public function getCountry() : ?string - { - return $this->country; - } - - public function getState() : ?string - { - return $this->state; - } - - public function getPostalCode() : ?string - { - return $this->postalCode; - } - - public function withStreet(?string $street) : self - { - $newAddress = self::createBuilder() - ->clone($this) - ->setStreet($street) - ->build(); - - return $newAddress; - } - - public function withCity(?string $city) : self - { - $newAddress = self::createBuilder() - ->clone($this) - ->setCity($city) - ->build(); - - return $newAddress; - } - - public function withCountry(?string $country) : self - { - $newAddress = self::createBuilder() - ->clone($this) - ->setCountry($country) - ->build(); - - return $newAddress; - } - - public function withState(?string $state) : self - { - $newAddress = self::createBuilder() - ->clone($this) - ->setState($state) - ->build(); - - return $newAddress; - } - - public function withPostalCode(?string $postalCode) : self - { - $newAddress = self::createBuilder() - ->clone($this) - ->setPostalCode($postalCode) - ->build(); - - return $newAddress; - } - - public function getValueMap(string $field) : StdClass - { - return (object) [ - $field . 'Street' => $this->street, - $field . 'City' => $this->city, - $field . 'Country' => $this->country, - $field . 'State' => $this->state, - $field . 'PostalCode' => $this->postalCode, - ]; - } - - public static function isSetInEntity(Entity $entity, string $field) : bool - { - return true; - } - - public static function fromEntity(Entity $entity, string $field) : self - { - $obj = new self(); - - $obj->street = $entity->get($field . 'Street'); - $obj->city = $entity->get($field . 'City'); - $obj->country = $entity->get($field . 'Country'); - $obj->state = $entity->get($field . 'State'); - $obj->postalCode = $entity->get($field . 'PostalCode'); - - return $obj; - } - - public static function fromRaw(array $raw) : self - { - $obj = new self(); - - $obj->street = $raw['street'] ?? null; - $obj->city = $raw['city'] ?? null; - $obj->country = $raw['country'] ?? null; - $obj->state = $raw['state'] ?? null; - $obj->postalCode = $raw['postalCode'] ?? null; - - return $obj; - } - - public static function createBuilder() : AddressBuilder - { - return new AddressBuilder(); - } -} diff --git a/application/Espo/Core/FieldUtils/Currency/CurrencyValue.php b/application/Espo/Core/FieldUtils/Currency/Currency.php similarity index 99% rename from application/Espo/Core/FieldUtils/Currency/CurrencyValue.php rename to application/Espo/Core/FieldUtils/Currency/Currency.php index 07cd86eeea..3abe77cae8 100644 --- a/application/Espo/Core/FieldUtils/Currency/CurrencyValue.php +++ b/application/Espo/Core/FieldUtils/Currency/Currency.php @@ -34,7 +34,7 @@ use RuntimeException; /** * A currency value. */ -class CurrencyValue +class Currency { private $amount; diff --git a/application/Espo/Core/FieldUtils/Currency/CurrencyValueAttributeExtractor.php b/application/Espo/Core/FieldUtils/Currency/CurrencyAttributeExtractor.php similarity index 92% rename from application/Espo/Core/FieldUtils/Currency/CurrencyValueAttributeExtractor.php rename to application/Espo/Core/FieldUtils/Currency/CurrencyAttributeExtractor.php index 8ba9bd2063..d94297856f 100644 --- a/application/Espo/Core/FieldUtils/Currency/CurrencyValueAttributeExtractor.php +++ b/application/Espo/Core/FieldUtils/Currency/CurrencyAttributeExtractor.php @@ -31,11 +31,11 @@ namespace Espo\Core\FieldUtils\Currency; use StdClass; -class CurrencyValueAttributeExtractor // implements \Espo\ORM\Value\AttributeExtractable +class CurrencyAttributeExtractor // implements \Espo\ORM\Value\AttributeExtractable { private $value; - public function __construct(CurrencyValue $value) + public function __construct(Currency $value) { $this->value = $value; } diff --git a/application/Espo/Core/FieldUtils/Currency/CurrencyConverter.php b/application/Espo/Core/FieldUtils/Currency/CurrencyConverter.php index aa043a36ea..7600929aac 100644 --- a/application/Espo/Core/FieldUtils/Currency/CurrencyConverter.php +++ b/application/Espo/Core/FieldUtils/Currency/CurrencyConverter.php @@ -48,7 +48,7 @@ class CurrencyConverter * * @throws RuntimeException */ - public function convert(CurrencyValue $value, string $targetCurrencyCode) : CurrencyValue + public function convert(Currency $value, string $targetCurrencyCode) : Currency { $amount = $value->getAmount(); @@ -64,13 +64,13 @@ class CurrencyConverter $amount /= $targetRate; - return new CurrencyValue($amount, $targetCurrencyCode); + return new Currency($amount, $targetCurrencyCode); } /** * Convert a currency value to the system default currency. */ - public function convertToDefault(CurrencyValue $value) : CurrencyValue + public function convertToDefault(Currency $value) : Currency { $targetCurrencyCode = $this->configDataProvider->getDefaultCurrency(); @@ -84,8 +84,8 @@ class CurrencyConverter * @throws RuntimeException */ public function convertWithRates( - CurrencyValue $value, string $targetCurrencyCode, CurrencyRates $rates - ) : CurrencyValue { + Currency $value, string $targetCurrencyCode, CurrencyRates $rates + ) : Currency { $amount = $value->getAmount(); @@ -107,6 +107,6 @@ class CurrencyConverter $amount /= $targetRate; - return new CurrencyValue($amount, $targetCurrencyCode); + return new Currency($amount, $targetCurrencyCode); } } diff --git a/application/Espo/Core/FieldUtils/Currency/CurrencyValueFactory.php b/application/Espo/Core/FieldUtils/Currency/CurrencyFactory.php similarity index 93% rename from application/Espo/Core/FieldUtils/Currency/CurrencyValueFactory.php rename to application/Espo/Core/FieldUtils/Currency/CurrencyFactory.php index befb53a721..4dbffc2a48 100644 --- a/application/Espo/Core/FieldUtils/Currency/CurrencyValueFactory.php +++ b/application/Espo/Core/FieldUtils/Currency/CurrencyFactory.php @@ -35,20 +35,20 @@ use Espo\{ use RuntimeException; -class CurrencyValueFactory // implements \Espo\ORM\Value\ValueFactory +class CurrencyFactory // implements \Espo\ORM\Value\ValueFactory { public function isCreatableFromEntity(Entity $entity, string $field) : bool { return $entity->has($field) && $entity->has($field . 'Currency'); } - public function createFromEntity(Entity $entity, string $field) : CurrencyValue + public function createFromEntity(Entity $entity, string $field) : Currency { if (!$this->isCreatableFromEntity($entity, $field)) { throw new RuntimeException(); } - return new CurrencyValue( + return new Currency( $entity->get($field), $entity->get($field . 'Currency') ); diff --git a/application/Espo/Core/MassAction/Actions/MassConvertCurrency.php b/application/Espo/Core/MassAction/Actions/MassConvertCurrency.php index b682705394..7ab42c9d07 100644 --- a/application/Espo/Core/MassAction/Actions/MassConvertCurrency.php +++ b/application/Espo/Core/MassAction/Actions/MassConvertCurrency.php @@ -43,7 +43,7 @@ use Espo\Core\{ Utils\Metadata, FieldUtils\Currency\CurrencyConfigDataProvider, FieldUtils\Currency\CurrencyConverter, - FieldUtils\Currency\CurrencyValue, + FieldUtils\Currency\Currency, FieldUtils\Currency\CurrencyRates, }; @@ -172,7 +172,7 @@ class MassConvertCurrency implements MassAction continue; } - $value = new CurrencyValue($amount, $code); + $value = new Currency($amount, $code); $convertedValue = $this->currencyConverter->convertWithRates($value, $targetCurrency, $rates); diff --git a/application/Espo/Tools/Export/Formats/Xlsx.php b/application/Espo/Tools/Export/Formats/Xlsx.php index f1bd8367cc..9fc80cdb33 100644 --- a/application/Espo/Tools/Export/Formats/Xlsx.php +++ b/application/Espo/Tools/Export/Formats/Xlsx.php @@ -40,7 +40,7 @@ use Espo\Core\{ FileStorage\Manager as FileStorageManager, Utils\File\Manager as FileManager, ORM\EntityManager, - FieldUtils\Address\AddressValue, + FieldUtils\Address\Address, FieldUtils\Address\AddressFormatterFactory, }; @@ -523,7 +523,7 @@ class Xlsx } } else if ($type == 'address') { - $address = AddressValue::createBuilder() + $address = Address::createBuilder() ->setStreet($row[$name . 'Street'] ?? null) ->setCity($row[$name . 'City'] ?? null) ->setState($row[$name . 'State'] ?? null) diff --git a/tests/unit/Espo/Core/FieldUtils/Address/AddressFormattersTest.php b/tests/unit/Espo/Core/FieldUtils/Address/AddressFormattersTest.php index 254b2cc458..b990196b95 100644 --- a/tests/unit/Espo/Core/FieldUtils/Address/AddressFormattersTest.php +++ b/tests/unit/Espo/Core/FieldUtils/Address/AddressFormattersTest.php @@ -30,7 +30,7 @@ namespace tests\unit\Espo\Core\FieldUtils\Address; use Espo\Core\{ - FieldUtils\Address\AddressValue, + FieldUtils\Address\Address, }; use Espo\Classes\{ @@ -49,7 +49,7 @@ class AddressFormattersTest extends \PHPUnit\Framework\TestCase public function testFormat1All() { - $address = AddressValue::createBuilder() + $address = Address::createBuilder() ->setStreet('street') ->setCity('city') ->setCountry('country') @@ -71,7 +71,7 @@ class AddressFormattersTest extends \PHPUnit\Framework\TestCase public function testFormat1NoState() { - $address = AddressValue::createBuilder() + $address = Address::createBuilder() ->setStreet('street') ->setCity('city') ->setCountry('country') @@ -93,7 +93,7 @@ class AddressFormattersTest extends \PHPUnit\Framework\TestCase public function testFormat2All() { - $address = AddressValue::createBuilder() + $address = Address::createBuilder() ->setStreet('street') ->setCity('city') ->setCountry('country') @@ -115,7 +115,7 @@ class AddressFormattersTest extends \PHPUnit\Framework\TestCase public function testFormat3All() { - $address = AddressValue::createBuilder() + $address = Address::createBuilder() ->setStreet('street') ->setCity('city') ->setCountry('country') @@ -137,7 +137,7 @@ class AddressFormattersTest extends \PHPUnit\Framework\TestCase public function testFormat4All() { - $address = AddressValue::createBuilder() + $address = Address::createBuilder() ->setStreet('street') ->setCity('city') ->setCountry('country') diff --git a/tests/unit/Espo/Core/FieldUtils/Address/AddressValueTest.php b/tests/unit/Espo/Core/FieldUtils/Address/AddressTest.php similarity index 90% rename from tests/unit/Espo/Core/FieldUtils/Address/AddressValueTest.php rename to tests/unit/Espo/Core/FieldUtils/Address/AddressTest.php index 251b9d44ec..ce4a07cc14 100644 --- a/tests/unit/Espo/Core/FieldUtils/Address/AddressValueTest.php +++ b/tests/unit/Espo/Core/FieldUtils/Address/AddressTest.php @@ -30,13 +30,13 @@ namespace tests\unit\Espo\Core\FieldUtils\Address; use Espo\Core\{ - FieldUtils\Address\AddressValue, - FieldUtils\Address\AddressValueFactory, + FieldUtils\Address\Address, + FieldUtils\Address\AddressFactory, }; use Espo\ORM\Entity; -class AddressValueTest extends \PHPUnit\Framework\TestCase +class AddressTest extends \PHPUnit\Framework\TestCase { protected function setUp() : void { @@ -45,7 +45,7 @@ class AddressValueTest extends \PHPUnit\Framework\TestCase public function testAddress1() { - $address = AddressValue::createBuilder() + $address = Address::createBuilder() ->setStreet('street') ->setCity('city') ->setCountry('country') @@ -62,7 +62,7 @@ class AddressValueTest extends \PHPUnit\Framework\TestCase public function testBuilderClone() { - $addressOriginal = AddressValue::createBuilder() + $addressOriginal = Address::createBuilder() ->setStreet('street') ->setCity('city') ->setCountry('country') @@ -70,7 +70,7 @@ class AddressValueTest extends \PHPUnit\Framework\TestCase ->setPostalCode('postalCode') ->build(); - $address = AddressValue::createBuilder() + $address = Address::createBuilder() ->clone($addressOriginal) ->build(); @@ -83,7 +83,7 @@ class AddressValueTest extends \PHPUnit\Framework\TestCase public function testAddressWith() { - $addressOriginal = AddressValue::createBuilder() + $addressOriginal = Address::createBuilder() ->setStreet('street') ->setCity('city') ->setCountry('country') @@ -112,7 +112,7 @@ class AddressValueTest extends \PHPUnit\Framework\TestCase ['addressPostalCode', null], ]); - $factory = new AddressValueFactory(); + $factory = new AddressFactory(); $address = $factory->createFromEntity($entity, 'address'); diff --git a/tests/unit/Espo/Core/FieldUtils/Currency/CurrencyConverterTest.php b/tests/unit/Espo/Core/FieldUtils/Currency/CurrencyConverterTest.php index 1c406bb3bd..03efc2cbc2 100644 --- a/tests/unit/Espo/Core/FieldUtils/Currency/CurrencyConverterTest.php +++ b/tests/unit/Espo/Core/FieldUtils/Currency/CurrencyConverterTest.php @@ -30,7 +30,7 @@ namespace tests\unit\Espo\Core\FieldUtils\Currency; use Espo\Core\{ - FieldUtils\Currency\CurrencyValue, + FieldUtils\Currency\Currency, FieldUtils\Currency\CurrencyConverter, FieldUtils\Currency\CurrencyConfigDataProvider, FieldUtils\Currency\CurrencyRates, @@ -61,7 +61,7 @@ class CurrencyConverterTest extends \PHPUnit\Framework\TestCase ['EUR', 1.2], ]); - $value = new CurrencyValue(2.0, 'USD'); + $value = new Currency(2.0, 'USD'); $converer = new CurrencyConverter($currencyConfigDataProvider); @@ -91,7 +91,7 @@ class CurrencyConverterTest extends \PHPUnit\Framework\TestCase ['UAH', 0.035], ]); - $value = new CurrencyValue(2.0, 'UAH'); + $value = new Currency(2.0, 'UAH'); $converer = new CurrencyConverter($currencyConfigDataProvider); @@ -125,7 +125,7 @@ class CurrencyConverterTest extends \PHPUnit\Framework\TestCase ['EUR', 1.2], ]); - $value = new CurrencyValue(2.0, 'EUR'); + $value = new Currency(2.0, 'EUR'); $converer = new CurrencyConverter($currencyConfigDataProvider); @@ -146,7 +146,7 @@ class CurrencyConverterTest extends \PHPUnit\Framework\TestCase 'UAH' => 0.035, ]); - $value = new CurrencyValue(2.0, 'UAH'); + $value = new Currency(2.0, 'UAH'); $converer = new CurrencyConverter($currencyConfigDataProvider); diff --git a/tests/unit/Espo/Core/FieldUtils/Currency/CurrencyValueTest.php b/tests/unit/Espo/Core/FieldUtils/Currency/CurrencyTest.php similarity index 83% rename from tests/unit/Espo/Core/FieldUtils/Currency/CurrencyValueTest.php rename to tests/unit/Espo/Core/FieldUtils/Currency/CurrencyTest.php index 7d278b3ad3..564082be22 100644 --- a/tests/unit/Espo/Core/FieldUtils/Currency/CurrencyValueTest.php +++ b/tests/unit/Espo/Core/FieldUtils/Currency/CurrencyTest.php @@ -30,8 +30,8 @@ namespace tests\unit\Espo\Core\FieldUtils\Currency; use Espo\Core\{ - FieldUtils\Currency\CurrencyValue, - FieldUtils\Currency\CurrencyValueFactory, + FieldUtils\Currency\Currency, + FieldUtils\Currency\CurrencyFactory, }; use Espo\{ @@ -40,7 +40,7 @@ use Espo\{ use RuntimeException; -class CurrencyValueTest extends \PHPUnit\Framework\TestCase +class CurrencyTest extends \PHPUnit\Framework\TestCase { protected function setUp() : void { @@ -48,7 +48,7 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase public function testValue() { - $value = new CurrencyValue(2.0, 'USD'); + $value = new Currency(2.0, 'USD'); $this->assertEquals(2.0, $value->getAmount()); @@ -57,8 +57,8 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase public function testAdd() { - $value = (new CurrencyValue(2.0, 'USD'))->add( - new CurrencyValue(1.0, 'USD') + $value = (new Currency(2.0, 'USD'))->add( + new Currency(1.0, 'USD') ); $this->assertEquals(3.0, $value->getAmount()); @@ -68,8 +68,8 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase public function testSubtract() { - $value = (new CurrencyValue(2.0, 'USD'))->subtract( - new CurrencyValue(3.0, 'USD') + $value = (new Currency(2.0, 'USD'))->subtract( + new Currency(3.0, 'USD') ); $this->assertEquals(-1.0, $value->getAmount()); @@ -79,7 +79,7 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase public function testMultiply() { - $value = (new CurrencyValue(2.0, 'USD'))->multiply(3.0); + $value = (new Currency(2.0, 'USD'))->multiply(3.0); $this->assertEquals(6.0, $value->getAmount()); @@ -88,7 +88,7 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase public function testDivide() { - $value = (new CurrencyValue(6.0, 'USD'))->divide(3.0); + $value = (new Currency(6.0, 'USD'))->divide(3.0); $this->assertEquals(2.0, $value->getAmount()); @@ -97,7 +97,7 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase public function testRound() { - $value = (new CurrencyValue(2.306, 'USD'))->round(2); + $value = (new Currency(2.306, 'USD'))->round(2); $this->assertEquals(2.31, $value->getAmount()); @@ -108,8 +108,8 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase { $this->expectException(RuntimeException::class); - (new CurrencyValue(2.0, 'USD'))->add( - new CurrencyValue(1.0, 'EUR') + (new Currency(2.0, 'USD'))->add( + new Currency(1.0, 'EUR') ); } @@ -117,7 +117,7 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase { $this->expectException(RuntimeException::class); - new CurrencyValue(2.0, ''); + new Currency(2.0, ''); } public function testCreateFromEntity() @@ -140,7 +140,7 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase ['testCurrency', true], ]); - $factory = new CurrencyValueFactory(); + $factory = new CurrencyFactory(); $value = $factory->createFromEntity($entity, 'test'); @@ -160,7 +160,7 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase ['testCurrency', true], ]); - $factory = new CurrencyValueFactory(); + $factory = new CurrencyFactory(); $this->assertTrue( $factory->isCreatableFromEntity($entity, 'test') @@ -179,7 +179,7 @@ class CurrencyValueTest extends \PHPUnit\Framework\TestCase ['testCurrency', False], ]); - $factory = new CurrencyValueFactory(); + $factory = new CurrencyFactory(); $this->assertFalse( $factory->isCreatableFromEntity($entity, 'test')