exception fix
This commit is contained in:
@@ -31,7 +31,6 @@ namespace Espo\Core\Field;
|
|||||||
|
|
||||||
use Espo\Core\Currency\CalculatorUtil;
|
use Espo\Core\Currency\CalculatorUtil;
|
||||||
|
|
||||||
use RuntimeException;
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +45,7 @@ class Currency
|
|||||||
/**
|
/**
|
||||||
* @param numeric-string|float|int $amount An amount.
|
* @param numeric-string|float|int $amount An amount.
|
||||||
* @param string $code A currency code.
|
* @param string $code A currency code.
|
||||||
* @throws RuntimeException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct($amount, string $code)
|
public function __construct($amount, string $code)
|
||||||
{
|
{
|
||||||
@@ -55,7 +54,7 @@ class Currency
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($code) !== 3) {
|
if (strlen($code) !== 3) {
|
||||||
throw new RuntimeException("Bad currency code.");
|
throw new InvalidArgumentException("Bad currency code.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_float($amount) || is_int($amount)) {
|
if (is_float($amount) || is_int($amount)) {
|
||||||
@@ -95,12 +94,12 @@ class Currency
|
|||||||
/**
|
/**
|
||||||
* Add a currency value.
|
* Add a currency value.
|
||||||
*
|
*
|
||||||
* @throws RuntimeException If currency codes are different.
|
* @throws InvalidArgumentException If currency codes are different.
|
||||||
*/
|
*/
|
||||||
public function add(self $value): self
|
public function add(self $value): self
|
||||||
{
|
{
|
||||||
if ($this->getCode() !== $value->getCode()) {
|
if ($this->getCode() !== $value->getCode()) {
|
||||||
throw new RuntimeException("Can't add a currency value with a different code.");
|
throw new InvalidArgumentException("Can't add a currency value with a different code.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$amount = CalculatorUtil::add(
|
$amount = CalculatorUtil::add(
|
||||||
@@ -114,12 +113,12 @@ class Currency
|
|||||||
/**
|
/**
|
||||||
* Subtract a currency value.
|
* Subtract a currency value.
|
||||||
*
|
*
|
||||||
* @throws RuntimeException If currency codes are different.
|
* @throws InvalidArgumentException If currency codes are different.
|
||||||
*/
|
*/
|
||||||
public function subtract(self $value): self
|
public function subtract(self $value): self
|
||||||
{
|
{
|
||||||
if ($this->getCode() !== $value->getCode()) {
|
if ($this->getCode() !== $value->getCode()) {
|
||||||
throw new RuntimeException("Can't subtract a currency value with a different code.");
|
throw new InvalidArgumentException("Can't subtract a currency value with a different code.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$amount = CalculatorUtil::subtract(
|
$amount = CalculatorUtil::subtract(
|
||||||
@@ -176,12 +175,12 @@ class Currency
|
|||||||
* - `0` if equal to the value;
|
* - `0` if equal to the value;
|
||||||
* - `-1` if less than the value.
|
* - `-1` if less than the value.
|
||||||
*
|
*
|
||||||
* @throws RuntimeException If currency codes are different.
|
* @throws InvalidArgumentException If currency codes are different.
|
||||||
*/
|
*/
|
||||||
public function compare(self $value): int
|
public function compare(self $value): int
|
||||||
{
|
{
|
||||||
if ($this->getCode() !== $value->getCode()) {
|
if ($this->getCode() !== $value->getCode()) {
|
||||||
throw new RuntimeException("Can't compare currencies with different codes.");
|
throw new InvalidArgumentException("Can't compare currencies with different codes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return CalculatorUtil::compare(
|
return CalculatorUtil::compare(
|
||||||
@@ -203,7 +202,7 @@ class Currency
|
|||||||
*
|
*
|
||||||
* @param numeric-string|float|int $amount An amount.
|
* @param numeric-string|float|int $amount An amount.
|
||||||
* @param string $code A currency code.
|
* @param string $code A currency code.
|
||||||
* @throws RuntimeException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function create($amount, string $code): self
|
public static function create($amount, string $code): self
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ use DateTimeImmutable;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
|
use InvalidArgumentException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,12 +46,15 @@ class Date implements DateTimeable
|
|||||||
private string $value;
|
private string $value;
|
||||||
private DateTimeImmutable $dateTime;
|
private DateTimeImmutable $dateTime;
|
||||||
|
|
||||||
private const SYSTEM_FORMAT = 'Y-m-d';
|
private const string SYSTEM_FORMAT = 'Y-m-d';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
public function __construct(string $value)
|
public function __construct(string $value)
|
||||||
{
|
{
|
||||||
if (!$value) {
|
if (!$value) {
|
||||||
throw new RuntimeException("Empty value.");
|
throw new InvalidArgumentException("Empty value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
@@ -62,13 +66,13 @@ class Date implements DateTimeable
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($parsedValue === false) {
|
if ($parsedValue === false) {
|
||||||
throw new RuntimeException("Bad value.");
|
throw new InvalidArgumentException("Bad value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dateTime = $parsedValue;
|
$this->dateTime = $parsedValue;
|
||||||
|
|
||||||
if ($this->value !== $this->dateTime->format(self::SYSTEM_FORMAT)) {
|
if ($this->value !== $this->dateTime->format(self::SYSTEM_FORMAT)) {
|
||||||
throw new RuntimeException("Bad value.");
|
throw new InvalidArgumentException("Bad value.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +263,8 @@ class Date implements DateTimeable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from a string with a date in `Y-m-d` format.
|
* Create from a string with a date in `Y-m-d` format.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function fromString(string $value): self
|
public static function fromString(string $value): self
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ use DateTimeInterface;
|
|||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A date-time value object. Immutable.
|
* A date-time value object. Immutable.
|
||||||
@@ -45,12 +46,15 @@ class DateTime implements DateTimeable
|
|||||||
private string $value;
|
private string $value;
|
||||||
private DateTimeImmutable $dateTime;
|
private DateTimeImmutable $dateTime;
|
||||||
|
|
||||||
private const SYSTEM_FORMAT = 'Y-m-d H:i:s';
|
private const string SYSTEM_FORMAT = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
public function __construct(string $value)
|
public function __construct(string $value)
|
||||||
{
|
{
|
||||||
if (!$value) {
|
if (!$value) {
|
||||||
throw new RuntimeException("Empty value.");
|
throw new InvalidArgumentException("Empty value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$normValue = strlen($value) === 16 ? $value . ':00' : $value;
|
$normValue = strlen($value) === 16 ? $value . ':00' : $value;
|
||||||
@@ -64,13 +68,13 @@ class DateTime implements DateTimeable
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($parsedValue === false) {
|
if ($parsedValue === false) {
|
||||||
throw new RuntimeException("Bad value.");
|
throw new InvalidArgumentException("Bad value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dateTime = $parsedValue;
|
$this->dateTime = $parsedValue;
|
||||||
|
|
||||||
if ($this->value !== $this->dateTime->format(self::SYSTEM_FORMAT)) {
|
if ($this->value !== $this->dateTime->format(self::SYSTEM_FORMAT)) {
|
||||||
throw new RuntimeException("Bad value.");
|
throw new InvalidArgumentException("Bad value.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,6 +347,8 @@ class DateTime implements DateTimeable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from a string with a date-time in `Y-m-d H:i:s` format.
|
* Create from a string with a date-time in `Y-m-d H:i:s` format.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function fromString(string $value): self
|
public static function fromString(string $value): self
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ use DateTimeImmutable;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A date-time or date. Immutable.
|
* A date-time or date. Immutable.
|
||||||
@@ -45,9 +45,12 @@ class DateTimeOptional implements DateTimeable
|
|||||||
private ?DateTime $dateTimeValue = null;
|
private ?DateTime $dateTimeValue = null;
|
||||||
private ?Date $dateValue = null;
|
private ?Date $dateValue = null;
|
||||||
|
|
||||||
private const SYSTEM_FORMAT = 'Y-m-d H:i:s';
|
private const string SYSTEM_FORMAT = 'Y-m-d H:i:s';
|
||||||
private const SYSTEM_FORMAT_DATE = 'Y-m-d';
|
private const string SYSTEM_FORMAT_DATE = 'Y-m-d';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
public function __construct(string $value)
|
public function __construct(string $value)
|
||||||
{
|
{
|
||||||
if (self::isStringDateTime($value)) {
|
if (self::isStringDateTime($value)) {
|
||||||
@@ -59,6 +62,8 @@ class DateTimeOptional implements DateTimeable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from a string with a date-time in `Y-m-d H:i:s` format or date in `Y-m-d`.
|
* Create from a string with a date-time in `Y-m-d H:i:s` format or date in `Y-m-d`.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function fromString(string $value): self
|
public static function fromString(string $value): self
|
||||||
{
|
{
|
||||||
@@ -67,12 +72,14 @@ class DateTimeOptional implements DateTimeable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from a string with a date-time in `Y-m-d H:i:s` format.
|
* Create from a string with a date-time in `Y-m-d H:i:s` format.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
* @noinspection PhpUnused
|
* @noinspection PhpUnused
|
||||||
*/
|
*/
|
||||||
public static function fromDateTimeString(string $value): self
|
public static function fromDateTimeString(string $value): self
|
||||||
{
|
{
|
||||||
if (!self::isStringDateTime($value)) {
|
if (!self::isStringDateTime($value)) {
|
||||||
throw new RuntimeException("Bad value.");
|
throw new InvalidArgumentException("Bad value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::fromString($value);
|
return self::fromString($value);
|
||||||
@@ -434,12 +441,14 @@ class DateTimeOptional implements DateTimeable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from a string with a date in `Y-m-d` format.
|
* Create from a string with a date in `Y-m-d` format.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
* @noinspection PhpUnused
|
* @noinspection PhpUnused
|
||||||
*/
|
*/
|
||||||
public static function fromDateString(string $value): self
|
public static function fromDateString(string $value): self
|
||||||
{
|
{
|
||||||
if (self::isStringDateTime($value)) {
|
if (self::isStringDateTime($value)) {
|
||||||
throw new RuntimeException("Bad value.");
|
throw new InvalidArgumentException("Bad value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::fromString($value);
|
return self::fromString($value);
|
||||||
|
|||||||
@@ -29,9 +29,9 @@
|
|||||||
|
|
||||||
namespace Espo\Core\Field;
|
namespace Espo\Core\Field;
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
use FILTER_VALIDATE_EMAIL;
|
use const FILTER_VALIDATE_EMAIL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An email address value. Immutable.
|
* An email address value. Immutable.
|
||||||
@@ -42,14 +42,17 @@ class EmailAddress
|
|||||||
private bool $isOptedOut = false;
|
private bool $isOptedOut = false;
|
||||||
private bool $isInvalid = false;
|
private bool $isInvalid = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
public function __construct(string $address)
|
public function __construct(string $address)
|
||||||
{
|
{
|
||||||
if ($address === '') {
|
if ($address === '') {
|
||||||
throw new RuntimeException("Empty email address.");
|
throw new InvalidArgumentException("Empty email address.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filter_var($address, FILTER_VALIDATE_EMAIL)) {
|
if (!filter_var($address, FILTER_VALIDATE_EMAIL)) {
|
||||||
throw new RuntimeException("Not valid email address '{$address}'.");
|
throw new InvalidArgumentException("Not valid email address '$address'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->address = $address;
|
$this->address = $address;
|
||||||
@@ -129,6 +132,8 @@ class EmailAddress
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from an address.
|
* Create from an address.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function create(string $address): self
|
public static function create(string $address): self
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace Espo\Core\Field;
|
namespace Espo\Core\Field;
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An email address group. Contains a list of email addresses. One email address is set as primary.
|
* An email address group. Contains a list of email addresses. One email address is set as primary.
|
||||||
@@ -43,7 +43,7 @@ class EmailAddressGroup
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param EmailAddress[] $list
|
* @param EmailAddress[] $list
|
||||||
* @throws RuntimeException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct(array $list = [])
|
public function __construct(array $list = [])
|
||||||
{
|
{
|
||||||
@@ -80,11 +80,7 @@ class EmailAddressGroup
|
|||||||
{
|
{
|
||||||
$primary = $this->getPrimary();
|
$primary = $this->getPrimary();
|
||||||
|
|
||||||
if (!$primary) {
|
return $primary?->getAddress();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $primary->getAddress();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -274,17 +270,20 @@ class EmailAddressGroup
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
private function validateList(): void
|
private function validateList(): void
|
||||||
{
|
{
|
||||||
$addressList = [];
|
$addressList = [];
|
||||||
|
|
||||||
foreach ($this->list as $item) {
|
foreach ($this->list as $item) {
|
||||||
if (!$item instanceof EmailAddress) {
|
if (!$item instanceof EmailAddress) {
|
||||||
throw new RuntimeException("Bad item.");
|
throw new InvalidArgumentException("Bad item.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(strtolower($item->getAddress()), $addressList)) {
|
if (in_array(strtolower($item->getAddress()), $addressList)) {
|
||||||
throw new RuntimeException("Address list contains a duplicate.");
|
throw new InvalidArgumentException("Address list contains a duplicate.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$addressList[] = strtolower($item->getAddress());
|
$addressList[] = strtolower($item->getAddress());
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace Espo\Core\Field;
|
namespace Espo\Core\Field;
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A link value object. Immutable.
|
* A link value object. Immutable.
|
||||||
@@ -42,7 +42,7 @@ class Link
|
|||||||
public function __construct(string $id)
|
public function __construct(string $id)
|
||||||
{
|
{
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
throw new RuntimeException("Empty ID.");
|
throw new InvalidArgumentException("Empty ID.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace Espo\Core\Field;
|
namespace Espo\Core\Field;
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A link-multiple value object. Immutable.
|
* A link-multiple value object. Immutable.
|
||||||
@@ -38,7 +38,7 @@ class LinkMultiple
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param LinkMultipleItem[] $list
|
* @param LinkMultipleItem[] $list
|
||||||
* @throws RuntimeException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct(private array $list = [])
|
public function __construct(private array $list = [])
|
||||||
{
|
{
|
||||||
@@ -148,8 +148,7 @@ class LinkMultiple
|
|||||||
* Clone with an added item list.
|
* Clone with an added item list.
|
||||||
* .
|
* .
|
||||||
* @param LinkMultipleItem[] $list
|
* @param LinkMultipleItem[] $list
|
||||||
*
|
* @throws InvalidArgumentException
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
*/
|
||||||
public function withAddedList(array $list): self
|
public function withAddedList(array $list): self
|
||||||
{
|
{
|
||||||
@@ -201,7 +200,7 @@ class LinkMultiple
|
|||||||
*
|
*
|
||||||
* @param LinkMultipleItem[] $list
|
* @param LinkMultipleItem[] $list
|
||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function create(array $list = []): self
|
public static function create(array $list = []): self
|
||||||
{
|
{
|
||||||
@@ -214,11 +213,11 @@ class LinkMultiple
|
|||||||
|
|
||||||
foreach ($this->list as $item) {
|
foreach ($this->list as $item) {
|
||||||
if (!$item instanceof LinkMultipleItem) {
|
if (!$item instanceof LinkMultipleItem) {
|
||||||
throw new RuntimeException("Bad item.");
|
throw new InvalidArgumentException("Bad item.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($item->getId(), $idList)) {
|
if (in_array($item->getId(), $idList)) {
|
||||||
throw new RuntimeException("List contains duplicates.");
|
throw new InvalidArgumentException("List contains duplicates.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$idList[] = strtolower($item->getId());
|
$idList[] = strtolower($item->getId());
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace Espo\Core\Field;
|
namespace Espo\Core\Field;
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A link-multiple item. Immutable.
|
* A link-multiple item. Immutable.
|
||||||
@@ -42,12 +42,12 @@ class LinkMultipleItem
|
|||||||
private array $columnData = [];
|
private array $columnData = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct(string $id)
|
public function __construct(string $id)
|
||||||
{
|
{
|
||||||
if ($id === '') {
|
if ($id === '') {
|
||||||
throw new RuntimeException("Empty ID.");
|
throw new InvalidArgumentException("Empty ID.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
@@ -124,7 +124,7 @@ class LinkMultipleItem
|
|||||||
/**
|
/**
|
||||||
* Create.
|
* Create.
|
||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function create(string $id, ?string $name = null): self
|
public static function create(string $id, ?string $name = null): self
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
namespace Espo\Core\Field;
|
namespace Espo\Core\Field;
|
||||||
|
|
||||||
use Espo\ORM\Entity;
|
use Espo\ORM\Entity;
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A link-parent value object. Immutable.
|
* A link-parent value object. Immutable.
|
||||||
@@ -44,11 +44,11 @@ class LinkParent
|
|||||||
public function __construct(string $entityType, string $id)
|
public function __construct(string $entityType, string $id)
|
||||||
{
|
{
|
||||||
if (!$entityType) {
|
if (!$entityType) {
|
||||||
throw new RuntimeException("Empty entity type.");
|
throw new InvalidArgumentException("Empty entity type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
throw new RuntimeException("Empty ID.");
|
throw new InvalidArgumentException("Empty ID.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->entityType = $entityType;
|
$this->entityType = $entityType;
|
||||||
@@ -93,6 +93,8 @@ class LinkParent
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create.
|
* Create.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function create(string $entityType, string $id): self
|
public static function create(string $entityType, string $id): self
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace Espo\Core\Field;
|
namespace Espo\Core\Field;
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A phone number value. Immutable.
|
* A phone number value. Immutable.
|
||||||
@@ -44,7 +44,7 @@ class PhoneNumber
|
|||||||
public function __construct(string $number)
|
public function __construct(string $number)
|
||||||
{
|
{
|
||||||
if ($number === '') {
|
if ($number === '') {
|
||||||
throw new RuntimeException("Empty phone number.");
|
throw new InvalidArgumentException("Empty phone number.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->number = $number;
|
$this->number = $number;
|
||||||
@@ -144,6 +144,8 @@ class PhoneNumber
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create with a number.
|
* Create with a number.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function create(string $number): self
|
public static function create(string $number): self
|
||||||
{
|
{
|
||||||
@@ -152,6 +154,8 @@ class PhoneNumber
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from a number and type.
|
* Create from a number and type.
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function createWithType(string $number, string $type): self
|
public static function createWithType(string $number, string $type): self
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace Espo\Core\Field;
|
namespace Espo\Core\Field;
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A phone number group. Contains a list of phone numbers. One phone number is set as primary.
|
* A phone number group. Contains a list of phone numbers. One phone number is set as primary.
|
||||||
@@ -43,8 +43,7 @@ class PhoneNumberGroup
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PhoneNumber[] $list
|
* @param PhoneNumber[] $list
|
||||||
*
|
* @throws InvalidArgumentException
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
*/
|
||||||
public function __construct(array $list = [])
|
public function __construct(array $list = [])
|
||||||
{
|
{
|
||||||
@@ -81,11 +80,8 @@ class PhoneNumberGroup
|
|||||||
{
|
{
|
||||||
$primary = $this->getPrimary();
|
$primary = $this->getPrimary();
|
||||||
|
|
||||||
if (!$primary) {
|
return $primary?->getNumber();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $primary->getNumber();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,7 +165,7 @@ class PhoneNumberGroup
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether an number is in the list.
|
* Whether the number is in the list.
|
||||||
*/
|
*/
|
||||||
public function hasNumber(string $number): bool
|
public function hasNumber(string $number): bool
|
||||||
{
|
{
|
||||||
@@ -258,6 +254,7 @@ class PhoneNumberGroup
|
|||||||
* Create with an optional phone number list. A first item will be set as primary.
|
* Create with an optional phone number list. A first item will be set as primary.
|
||||||
*
|
*
|
||||||
* @param PhoneNumber[] $list
|
* @param PhoneNumber[] $list
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function create(array $list = []): self
|
public static function create(array $list = []): self
|
||||||
{
|
{
|
||||||
@@ -281,11 +278,11 @@ class PhoneNumberGroup
|
|||||||
|
|
||||||
foreach ($this->list as $item) {
|
foreach ($this->list as $item) {
|
||||||
if (!$item instanceof PhoneNumber) {
|
if (!$item instanceof PhoneNumber) {
|
||||||
throw new RuntimeException("Bad item.");
|
throw new InvalidArgumentException("Bad item.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($item->getNumber(), $numberList)) {
|
if (in_array($item->getNumber(), $numberList)) {
|
||||||
throw new RuntimeException("Number list contains a duplicate.");
|
throw new InvalidArgumentException("Number list contains a duplicate.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$numberList[] = strtolower($item->getNumber());
|
$numberList[] = strtolower($item->getNumber());
|
||||||
|
|||||||
@@ -29,16 +29,15 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\Currency;
|
namespace tests\unit\Espo\Core\Field\Currency;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\Currency;
|
||||||
Field\Currency,
|
use Espo\Core\Field\Currency\CurrencyFactory;
|
||||||
Field\Currency\CurrencyFactory,
|
|
||||||
};
|
|
||||||
|
|
||||||
use Espo\ORM\Entity;
|
use Espo\ORM\Entity;
|
||||||
|
|
||||||
use RuntimeException;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class CurrencyTest extends \PHPUnit\Framework\TestCase
|
class CurrencyTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testValue()
|
public function testValue()
|
||||||
{
|
{
|
||||||
@@ -122,7 +121,7 @@ class CurrencyTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testBadAdd()
|
public function testBadAdd()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
(new Currency(2.0, 'USD'))->add(
|
(new Currency(2.0, 'USD'))->add(
|
||||||
new Currency(1.0, 'EUR')
|
new Currency(1.0, 'EUR')
|
||||||
@@ -131,7 +130,7 @@ class CurrencyTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testGetBadCode()
|
public function testGetBadCode()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
new Currency(2.0, '');
|
new Currency(2.0, '');
|
||||||
}
|
}
|
||||||
@@ -237,7 +236,7 @@ class CurrencyTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testCompare4(): void
|
public function testCompare4(): void
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
Currency::create(2.1, 'EUR')
|
Currency::create(2.1, 'EUR')
|
||||||
->compare(
|
->compare(
|
||||||
|
|||||||
@@ -29,16 +29,15 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\Date;
|
namespace tests\unit\Espo\Core\Field\Date;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\Date;
|
||||||
Field\Date,
|
|
||||||
};
|
|
||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
|
||||||
class DateTest extends \PHPUnit\Framework\TestCase
|
class DateTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testFromString()
|
public function testFromString()
|
||||||
{
|
{
|
||||||
@@ -58,21 +57,21 @@ class DateTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testBad1()
|
public function testBad1()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
Date::fromString('2021-05-A');
|
Date::fromString('2021-05-A');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBad2()
|
public function testBad2()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
Date::fromString('2021-05-1');
|
Date::fromString('2021-05-1');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
Date::fromString('');
|
Date::fromString('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,10 +33,11 @@ use Espo\Core\Field\DateTime;
|
|||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use RuntimeException;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
|
||||||
class DateTimeTest extends \PHPUnit\Framework\TestCase
|
class DateTimeTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testFromString1()
|
public function testFromString1()
|
||||||
{
|
{
|
||||||
@@ -72,21 +73,21 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testBad1()
|
public function testBad1()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTime::fromString('2021-05-A 10:20:30');
|
DateTime::fromString('2021-05-A 10:20:30');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBad2()
|
public function testBad2()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTime::fromString('2021-05-1 10:20:30');
|
DateTime::fromString('2021-05-1 10:20:30');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTime::fromString('');
|
DateTime::fromString('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,16 +29,15 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\DateTimeOptional;
|
namespace tests\unit\Espo\Core\Field\DateTimeOptional;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\DateTimeOptional;
|
||||||
Field\DateTimeOptional,
|
|
||||||
};
|
|
||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use RuntimeException;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
|
||||||
class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase
|
class DateTimeOptionalDateTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testFromString()
|
public function testFromString()
|
||||||
{
|
{
|
||||||
@@ -60,21 +59,21 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testBad1()
|
public function testBad1()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTimeOptional::fromString('2021-05-A');
|
DateTimeOptional::fromString('2021-05-A');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBad2()
|
public function testBad2()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTimeOptional::fromString('2021-05-1');
|
DateTimeOptional::fromString('2021-05-1');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTimeOptional::fromString('');
|
DateTimeOptional::fromString('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,16 +29,15 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\DateTimeOptionalTest;
|
namespace tests\unit\Espo\Core\Field\DateTimeOptionalTest;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\DateTimeOptional;
|
||||||
Field\DateTime,
|
|
||||||
Field\DateTimeOptional};
|
|
||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use RuntimeException;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
|
||||||
class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase
|
class DateTimeOptionalTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testFromString1()
|
public function testFromString1()
|
||||||
{
|
{
|
||||||
@@ -78,21 +77,21 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testBad1()
|
public function testBad1()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTimeOptional::fromString('2021-05-A 10:20:30');
|
DateTimeOptional::fromString('2021-05-A 10:20:30');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBad2()
|
public function testBad2()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTimeOptional::fromString('2021-05-1 10:20:30');
|
DateTimeOptional::fromString('2021-05-1 10:20:30');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
DateTimeOptional::fromString('');
|
DateTimeOptional::fromString('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,12 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\EmailAddress;
|
namespace tests\unit\Espo\Core\Field\EmailAddress;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\EmailAddress;
|
||||||
Field\EmailAddress,
|
use Espo\Core\Field\EmailAddress\EmailAddressGroupAttributeExtractor;
|
||||||
Field\EmailAddressGroup,
|
use Espo\Core\Field\EmailAddressGroup;
|
||||||
Field\EmailAddress\EmailAddressGroupAttributeExtractor,
|
use PHPUnit\Framework\TestCase;
|
||||||
};
|
|
||||||
|
|
||||||
class EmailAddressGroupAttributeExtractorTest extends \PHPUnit\Framework\TestCase
|
class EmailAddressGroupAttributeExtractorTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testExtract()
|
public function testExtract()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,14 +29,13 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\EmailAddress;
|
namespace tests\unit\Espo\Core\Field\EmailAddress;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\EmailAddress;
|
||||||
Field\EmailAddress,
|
use Espo\Core\Field\EmailAddressGroup;
|
||||||
Field\EmailAddressGroup,
|
|
||||||
};
|
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase
|
class EmailAddressGroupTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
@@ -53,7 +52,7 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testDuplicate1()
|
public function testDuplicate1()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
EmailAddressGroup
|
EmailAddressGroup
|
||||||
::create([
|
::create([
|
||||||
@@ -64,7 +63,7 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testDuplicate2()
|
public function testDuplicate2()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
EmailAddressGroup
|
EmailAddressGroup
|
||||||
::create([
|
::create([
|
||||||
|
|||||||
@@ -29,24 +29,23 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\EmailAddress;
|
namespace tests\unit\Espo\Core\Field\EmailAddress;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\EmailAddress;
|
||||||
Field\EmailAddress,
|
|
||||||
};
|
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class EmailAddressTest extends \PHPUnit\Framework\TestCase
|
class EmailAddressTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testInvalidAddress()
|
public function testInvalidAddress()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
EmailAddress::create('one');
|
EmailAddress::create('one');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidEmpty()
|
public function testInvalidEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
EmailAddress::create('');
|
EmailAddress::create('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,12 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\Link;
|
namespace tests\unit\Espo\Core\Field\Link;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\Link;
|
||||||
Field\Link,
|
|
||||||
};
|
|
||||||
|
|
||||||
use RuntimeException;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class LinkTest extends \PHPUnit\Framework\TestCase
|
class LinkTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testCreate()
|
public function testCreate()
|
||||||
{
|
{
|
||||||
@@ -47,7 +46,7 @@ class LinkTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testBad1()
|
public function testBad1()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
Link::create('');
|
Link::create('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,10 @@ namespace tests\unit\Espo\Core\Field\LinkMultiple;
|
|||||||
use Espo\Core\Field\LinkMultiple;
|
use Espo\Core\Field\LinkMultiple;
|
||||||
use Espo\Core\Field\LinkMultipleItem;
|
use Espo\Core\Field\LinkMultipleItem;
|
||||||
|
|
||||||
use RuntimeException;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class LinkMultipleTest extends \PHPUnit\Framework\TestCase
|
class LinkMultipleTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
@@ -47,7 +48,7 @@ class LinkMultipleTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testDuplicate()
|
public function testDuplicate()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
LinkMultiple
|
LinkMultiple
|
||||||
::create([
|
::create([
|
||||||
|
|||||||
@@ -29,13 +29,12 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\LinkParent;
|
namespace tests\unit\Espo\Core\Field\LinkParent;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\LinkParent;
|
||||||
Field\LinkParent,
|
|
||||||
};
|
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class LinkParentTest extends \PHPUnit\Framework\TestCase
|
class LinkParentTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testCreate()
|
public function testCreate()
|
||||||
{
|
{
|
||||||
@@ -48,14 +47,14 @@ class LinkParentTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testBad1()
|
public function testBad1()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
LinkParent::create('Test', '');
|
LinkParent::create('Test', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBad2()
|
public function testBad2()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
LinkParent::create('', 'id');
|
LinkParent::create('', 'id');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,12 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\PhoneNumber;
|
namespace tests\unit\Espo\Core\Field\PhoneNumber;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\PhoneNumber;
|
||||||
Field\PhoneNumber,
|
use Espo\Core\Field\PhoneNumber\PhoneNumberGroupAttributeExtractor;
|
||||||
Field\PhoneNumberGroup,
|
use Espo\Core\Field\PhoneNumberGroup;
|
||||||
Field\PhoneNumber\PhoneNumberGroupAttributeExtractor,
|
use PHPUnit\Framework\TestCase;
|
||||||
};
|
|
||||||
|
|
||||||
class PhoneNumberGroupAttributeExtractorTest extends \PHPUnit\Framework\TestCase
|
class PhoneNumberGroupAttributeExtractorTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testExtract()
|
public function testExtract()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,21 +29,19 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\PhoneNumber;
|
namespace tests\unit\Espo\Core\Field\PhoneNumber;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\PhoneNumber\PhoneNumberGroupFactory;
|
||||||
Field\PhoneNumber\PhoneNumberGroupFactory,
|
use Espo\Core\Utils\Metadata;
|
||||||
Utils\Metadata,
|
|
||||||
};
|
|
||||||
|
|
||||||
use Espo\ORM\{
|
use Espo\ORM\Entity;
|
||||||
EntityManager,
|
use Espo\ORM\EntityManager;
|
||||||
Entity,
|
|
||||||
};
|
|
||||||
|
|
||||||
use Espo\Repositories\PhoneNumber as PhoneNumberRepository;
|
use Espo\Repositories\PhoneNumber as PhoneNumberRepository;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
class PhoneNumberGroupFactoryTest extends \PHPUnit\Framework\TestCase
|
class PhoneNumberGroupFactoryTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Metadata
|
* @var Metadata
|
||||||
|
|||||||
@@ -29,14 +29,13 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\PhoneNumber;
|
namespace tests\unit\Espo\Core\Field\PhoneNumber;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\PhoneNumber;
|
||||||
Field\PhoneNumber,
|
use Espo\Core\Field\PhoneNumberGroup;
|
||||||
Field\PhoneNumberGroup,
|
|
||||||
};
|
|
||||||
|
|
||||||
use RuntimeException;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase
|
class PhoneNumberGroupTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
@@ -53,7 +52,7 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
public function testDuplicate()
|
public function testDuplicate()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
PhoneNumberGroup
|
PhoneNumberGroup
|
||||||
::create([
|
::create([
|
||||||
|
|||||||
@@ -29,17 +29,16 @@
|
|||||||
|
|
||||||
namespace tests\unit\Espo\Core\Field\PhoneNumber;
|
namespace tests\unit\Espo\Core\Field\PhoneNumber;
|
||||||
|
|
||||||
use Espo\Core\{
|
use Espo\Core\Field\PhoneNumber;
|
||||||
Field\PhoneNumber,
|
|
||||||
};
|
|
||||||
|
|
||||||
use RuntimeException;
|
use InvalidArgumentException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class PhoneNumberTest extends \PHPUnit\Framework\TestCase
|
class PhoneNumberTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testInvalidEmpty()
|
public function testInvalidEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
PhoneNumber::create('');
|
PhoneNumber::create('');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user