mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 01:31:45 +01:00
Merge branch 'master' of github.com:meritoo/common-library
This commit is contained in:
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
Common and useful classes, methods, exceptions etc.
|
Common and useful classes, methods, exceptions etc.
|
||||||
|
|
||||||
|
# 0.1.6
|
||||||
|
|
||||||
|
1. Arrays > refactoring & more tests
|
||||||
|
2. ValueObject > Human > represents a human
|
||||||
|
3. Tests > use `Meritoo\Test\Common` namespace (instead of `Meritoo\Common\Test`)
|
||||||
|
4. Tests > use @dataProvider
|
||||||
|
|
||||||
# 0.1.5
|
# 0.1.5
|
||||||
|
|
||||||
1. Tests > Date > one more test case
|
1. Tests > Date > one more test case
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Meritoo\\Common\\Test\\": "tests/"
|
"Meritoo\\Test\\Common\\": "tests/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ $asString = (string)$address; // "4th Avenue 10/200, 00123, New York"
|
|||||||
|
|
||||||
Represents bank account. Contains properties:
|
Represents bank account. Contains properties:
|
||||||
1. `$bankName` - name of bank
|
1. `$bankName` - name of bank
|
||||||
2. $accountNumber` - number of bank's account
|
2. `$accountNumber` - number of bank's account
|
||||||
|
|
||||||
##### New instance
|
##### New instance
|
||||||
|
|
||||||
@@ -137,6 +137,46 @@ $company = new Company(
|
|||||||
$asString = (string)$company; // "Test 1, 4th Avenue 10/200, 00123, New York, Bank 1, 12345"
|
$asString = (string)$company; // "Test 1, 4th Avenue 10/200, 00123, New York, Bank 1, 12345"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Human
|
||||||
|
|
||||||
|
##### Namespace
|
||||||
|
|
||||||
|
`Meritoo\Common\ValueObject\Human`
|
||||||
|
|
||||||
|
##### Info
|
||||||
|
|
||||||
|
Represents human. Based on `\Meritoo\Common\Traits\ValueObject\HumanTrait` trait. Contains properties same as `HumanTrait` trait:
|
||||||
|
1. `$firstName` - first name
|
||||||
|
2. `$lastName` - last name
|
||||||
|
3. `$email` - email address
|
||||||
|
4. `$birthDate` - birth date
|
||||||
|
|
||||||
|
##### New instance
|
||||||
|
|
||||||
|
New instance can be created using constructor:
|
||||||
|
|
||||||
|
```php
|
||||||
|
new Human('John', 'Scott', 'john@scott.com', new \DateTime('2001-01-01'));
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Methods
|
||||||
|
|
||||||
|
Has getters for each property, e.g. `getFirstName()`, `getEmail()` etc.
|
||||||
|
|
||||||
|
##### Conversion to string (the `__toString()` method)
|
||||||
|
|
||||||
|
Instance of `Human` may be represented as string that contains first name, last name and email address (if provided).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$human1 = new Human('John', 'Scott');
|
||||||
|
$asString1 = (string)$human1; // "John Scott"
|
||||||
|
|
||||||
|
$human2 = new Human('John', 'Scott', 'john@scott.com', new \DateTime('2001-01-01'));
|
||||||
|
$asString2 = (string)$human2; // "John Scott <john@scott.com>"
|
||||||
|
```
|
||||||
|
|
||||||
### Version
|
### Version
|
||||||
|
|
||||||
##### Namespace
|
##### Namespace
|
||||||
@@ -173,6 +213,17 @@ New instance can be created using:
|
|||||||
Version::fromString('1.0.2');
|
Version::fromString('1.0.2');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Conversion to string (the `__toString()` method)
|
||||||
|
|
||||||
|
Instance of `Version` may be represented as string that contains all properties separated by `.` (`$majorPart`.`$minorPart`.`$patchPart`).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$version = new Version(1, 0, 2);
|
||||||
|
$asString = (string)$version; // "1.0.2"
|
||||||
|
```
|
||||||
|
|
||||||
# More
|
# More
|
||||||
|
|
||||||
1. [Base test case (with common methods and data providers)](Base-test-case.md)
|
1. [Base test case (with common methods and data providers)](Base-test-case.md)
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ class Collection implements Countable, ArrayAccess, IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the collection
|
* Returns representation of object as array
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|||||||
137
src/Traits/ValueObject/HumanTrait.php
Normal file
137
src/Traits/ValueObject/HumanTrait.php
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Meritoo\Common\Traits\ValueObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Methods and properties related to human
|
||||||
|
*
|
||||||
|
* @author Meritoo <github@meritoo.pl>
|
||||||
|
* @copyright Meritoo <http://www.meritoo.pl>
|
||||||
|
*/
|
||||||
|
trait HumanTrait
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* First name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $firstName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $lastName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Email address
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Birth date
|
||||||
|
*
|
||||||
|
* @var \DateTime
|
||||||
|
*/
|
||||||
|
protected $birthDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor
|
||||||
|
*
|
||||||
|
* @param string $firstName First name
|
||||||
|
* @param string $lastName Last name
|
||||||
|
* @param string $email (optional) Email address
|
||||||
|
* @param \DateTime $birthDate (optional) Birth date
|
||||||
|
*/
|
||||||
|
public function __construct($firstName, $lastName, $email = null, \DateTime $birthDate = null)
|
||||||
|
{
|
||||||
|
$this->firstName = $firstName;
|
||||||
|
$this->lastName = $lastName;
|
||||||
|
$this->email = $email;
|
||||||
|
$this->birthDate = $birthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns representation of object as string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
$template = '%s';
|
||||||
|
|
||||||
|
if ('' !== $this->email && null !== $this->email) {
|
||||||
|
$template .= ' <%s>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprintf($template, $this->getFullName(), $this->email);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns first name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFirstName()
|
||||||
|
{
|
||||||
|
return $this->firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns last name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLastName()
|
||||||
|
{
|
||||||
|
return $this->lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns email address
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getEmail()
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns birth date
|
||||||
|
*
|
||||||
|
* @return \DateTime|null
|
||||||
|
*/
|
||||||
|
public function getBirthDate()
|
||||||
|
{
|
||||||
|
return $this->birthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full name
|
||||||
|
*
|
||||||
|
* @param bool $firstNameFirst (optional) If is set to true, first name is the first part. Otherwise - last name.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFullName($firstNameFirst = true)
|
||||||
|
{
|
||||||
|
$beginning = $this->lastName;
|
||||||
|
$finish = $this->firstName;
|
||||||
|
|
||||||
|
if ($firstNameFirst) {
|
||||||
|
$beginning = $this->firstName;
|
||||||
|
$finish = $this->lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim(sprintf('%s %s', $beginning, $finish));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,78 +27,114 @@ class Arrays
|
|||||||
* Converts given array's column to string.
|
* Converts given array's column to string.
|
||||||
* Recursive call is made for multi-dimensional arrays.
|
* Recursive call is made for multi-dimensional arrays.
|
||||||
*
|
*
|
||||||
* @param array $array Array data to be converted
|
* @param array $array Data to be converted
|
||||||
* @param string|int $arrayColumnKey (optional) Column name
|
* @param string|int $arrayColumnKey (optional) Column name. Default: "".
|
||||||
* @param string $separator (optional) Separator used in resultant string
|
* @param string $separator (optional) Separator used between values. Default: ",".
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function values2string(array $array, $arrayColumnKey = '', $separator = ',')
|
public static function values2string(array $array, $arrayColumnKey = '', $separator = ',')
|
||||||
{
|
{
|
||||||
$effect = '';
|
/*
|
||||||
|
* No elements?
|
||||||
if (!empty($array)) {
|
* Nothing to do
|
||||||
foreach ($array as $key => $value) {
|
*/
|
||||||
if (!empty($effect) &&
|
if (empty($array)) {
|
||||||
(
|
return null;
|
||||||
empty($arrayColumnKey) || (!is_array($value) && $key === $arrayColumnKey)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$effect .= $separator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$values = [];
|
||||||
|
|
||||||
|
foreach ($array as $key => $value) {
|
||||||
|
$appendMe = null;
|
||||||
|
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$effect .= self::values2string($value, $arrayColumnKey, $separator);
|
$appendMe = self::values2string($value, $arrayColumnKey, $separator);
|
||||||
} elseif (empty($arrayColumnKey)) {
|
} elseif (empty($arrayColumnKey)) {
|
||||||
$effect .= $value;
|
$appendMe = $value;
|
||||||
} elseif ($key === $arrayColumnKey) {
|
} elseif ($key === $arrayColumnKey) {
|
||||||
$effect .= $array[$arrayColumnKey];
|
$appendMe = $array[$arrayColumnKey];
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $effect;
|
/*
|
||||||
|
* Part to append is unknown?
|
||||||
|
* Let's go to next part
|
||||||
|
*/
|
||||||
|
if (null === $appendMe) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$values[] = $appendMe;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* No values found?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($values)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode($separator, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts given array to string with keys, e.g. abc=1&def=2 or abc="1" def="2"
|
* Converts given array to string with keys, e.g. abc=1&def=2 or abc="1" def="2"
|
||||||
*
|
*
|
||||||
* @param array $array Array data to be converted
|
* @param array $array Data to be converted
|
||||||
* @param string $separator (optional) Separator used between name-value pairs in resultant string
|
* @param string $separator (optional) Separator used between name-value pairs. Default: ",".
|
||||||
* @param string $valuesKeysSeparator (optional) Separator used between name and value in resultant string
|
* @param string $valuesKeysSeparator (optional) Separator used between name and value. Default: "=".
|
||||||
* @param string $valuesWrapper (optional) Wrapper used to wrap values, e.g. double-quote: key="value"
|
* @param string $valuesWrapper (optional) Wrapper used to wrap values, e.g. double-quote: key="value".
|
||||||
* @return string
|
* Default: "".
|
||||||
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function valuesKeys2string($array, $separator = ',', $valuesKeysSeparator = '=', $valuesWrapper = '')
|
public static function valuesKeys2string(
|
||||||
{
|
array $array,
|
||||||
$effect = '';
|
$separator = ',',
|
||||||
|
$valuesKeysSeparator = '=',
|
||||||
|
$valuesWrapper = ''
|
||||||
|
) {
|
||||||
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = '';
|
||||||
|
|
||||||
if (is_array($array) && !empty($array)) {
|
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (!empty($effect)) {
|
if (!empty($result)) {
|
||||||
$effect .= $separator;
|
$result .= $separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($valuesWrapper)) {
|
if (!empty($valuesWrapper)) {
|
||||||
$value = sprintf('%s%s%s', $valuesWrapper, $value, $valuesWrapper);
|
$value = sprintf('%s%s%s', $valuesWrapper, $value, $valuesWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect .= $key . $valuesKeysSeparator . $value;
|
$result .= $key . $valuesKeysSeparator . $value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $effect;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts given array's rows to csv string
|
* Converts given array's rows to csv string
|
||||||
*
|
*
|
||||||
* @param array $array Array data to be converted. It have to be an array that represents database table.
|
* @param array $array Data to be converted. It have to be an array that represents database table.
|
||||||
* @param string $separator (optional) Separator used in resultant string
|
* @param string $separator (optional) Separator used between values. Default: ",".
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function values2csv($array, $separator = ',')
|
public static function values2csv(array $array, $separator = ',')
|
||||||
{
|
{
|
||||||
if (is_array($array) && !empty($array)) {
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
$lineSeparator = "\n";
|
$lineSeparator = "\n";
|
||||||
|
|
||||||
@@ -117,12 +153,11 @@ class Arrays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($rows)) {
|
if (empty($rows)) {
|
||||||
return implode($lineSeparator, $rows);
|
return '';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return implode($lineSeparator, $rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,12 +277,20 @@ class Arrays
|
|||||||
/**
|
/**
|
||||||
* Returns breadcrumb (a path) to the last element of array
|
* Returns breadcrumb (a path) to the last element of array
|
||||||
*
|
*
|
||||||
* @param array $array The array to get the breadcrumb
|
* @param array $array Data to get the breadcrumb
|
||||||
* @param string $separator (optional) Separator used to stick the elements
|
* @param string $separator (optional) Separator used to stick the elements. Default: "/".
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function getLastElementBreadCrumb($array, $separator = '/')
|
public static function getLastElementBreadCrumb(array $array, $separator = '/')
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$keys = array_keys($array);
|
$keys = array_keys($array);
|
||||||
$keysCount = count($keys);
|
$keysCount = count($keys);
|
||||||
|
|
||||||
@@ -350,7 +393,7 @@ class Arrays
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect = '';
|
$result = '';
|
||||||
$counter = 0;
|
$counter = 0;
|
||||||
|
|
||||||
$arrayCount = count($array);
|
$arrayCount = count($array);
|
||||||
@@ -366,14 +409,14 @@ class Arrays
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($jsVariableName) && is_string($jsVariableName)) {
|
if (!empty($jsVariableName) && is_string($jsVariableName)) {
|
||||||
$effect .= sprintf('var %s = ', $jsVariableName);
|
$result .= sprintf('var %s = ', $jsVariableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect .= 'new Array(';
|
$result .= 'new Array(';
|
||||||
|
|
||||||
if ($preserveIndexes || $isMultiDimensional) {
|
if ($preserveIndexes || $isMultiDimensional) {
|
||||||
$effect .= $arrayCount;
|
$result .= $arrayCount;
|
||||||
$effect .= ');';
|
$result .= ');';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($array as $index => $value) {
|
foreach ($array as $index => $value) {
|
||||||
@@ -397,20 +440,20 @@ class Arrays
|
|||||||
* autoGeneratedVariable[1] = new Array(...);
|
* autoGeneratedVariable[1] = new Array(...);
|
||||||
*/
|
*/
|
||||||
if (1 === $counter) {
|
if (1 === $counter) {
|
||||||
$effect .= "\n";
|
$result .= "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect .= $value . "\n";
|
$result .= $value . "\n";
|
||||||
$effect .= sprintf('%s[%s] = %s;', $jsVariableName, Miscellaneous::quoteValue($index), $variable);
|
$result .= sprintf('%s[%s] = %s;', $jsVariableName, Miscellaneous::quoteValue($index), $variable);
|
||||||
|
|
||||||
if ($counter !== $arrayCount) {
|
if ($counter !== $arrayCount) {
|
||||||
$effect .= "\n";
|
$result .= "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($preserveIndexes) {
|
} elseif ($preserveIndexes) {
|
||||||
if (!empty($jsVariableName)) {
|
if (!empty($jsVariableName)) {
|
||||||
$index = Miscellaneous::quoteValue($index);
|
$index = Miscellaneous::quoteValue($index);
|
||||||
$effect .= sprintf("\n%s[%s] = %s;", $jsVariableName, $index, $value);
|
$result .= sprintf("\n%s[%s] = %s;", $jsVariableName, $index, $value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$format = '%s';
|
$format = '%s';
|
||||||
@@ -419,29 +462,34 @@ class Arrays
|
|||||||
$format .= ', ';
|
$format .= ', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect .= sprintf($format, $value);
|
$result .= sprintf($format, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$preserveIndexes && !$isMultiDimensional) {
|
if (!$preserveIndexes && !$isMultiDimensional) {
|
||||||
$effect .= ');';
|
$result .= ');';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $effect;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quotes (adds quotes) to elements of an array that are strings
|
* Quotes (adds quotes) to elements that are strings and returns new array (with quoted elements)
|
||||||
*
|
*
|
||||||
* @param array $array The array to check for string values
|
* @param array $array The array to check for string values
|
||||||
* @return array
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function quoteStrings($array)
|
public static function quoteStrings(array $array)
|
||||||
{
|
{
|
||||||
$effect = $array;
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($array) && !empty($array)) {
|
$result = [];
|
||||||
$effect = [];
|
|
||||||
|
|
||||||
foreach ($array as $index => $value) {
|
foreach ($array as $index => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
@@ -452,11 +500,10 @@ class Arrays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect[$index] = $value;
|
$result[$index] = $value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $effect;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -495,6 +542,14 @@ class Arrays
|
|||||||
*/
|
*/
|
||||||
public static function getLastKey(array $array)
|
public static function getLastKey(array $array)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$keys = array_keys($array);
|
$keys = array_keys($array);
|
||||||
|
|
||||||
return end($keys);
|
return end($keys);
|
||||||
@@ -543,9 +598,9 @@ class Arrays
|
|||||||
* @param bool $before (optional) If is set to true, all elements before given needle are removed. Otherwise - all
|
* @param bool $before (optional) If is set to true, all elements before given needle are removed. Otherwise - all
|
||||||
* after needle.
|
* after needle.
|
||||||
*/
|
*/
|
||||||
public static function removeElements(&$array, $needle, $before = true)
|
public static function removeElements(array &$array, $needle, $before = true)
|
||||||
{
|
{
|
||||||
if (is_array($array) && !empty($array)) {
|
if (!empty($array)) {
|
||||||
if (!$before) {
|
if (!$before) {
|
||||||
$array = array_reverse($array, true);
|
$array = array_reverse($array, true);
|
||||||
}
|
}
|
||||||
@@ -587,7 +642,7 @@ class Arrays
|
|||||||
* value will be used with it's key, because other will be overridden.
|
* value will be used with it's key, because other will be overridden.
|
||||||
* Otherwise - values are preserved and keys assigned to that values are
|
* Otherwise - values are preserved and keys assigned to that values are
|
||||||
* returned as an array.
|
* returned as an array.
|
||||||
* @return array
|
* @return array|null
|
||||||
*
|
*
|
||||||
* Example of $ignoreDuplicatedValues = false:
|
* Example of $ignoreDuplicatedValues = false:
|
||||||
* - provided array
|
* - provided array
|
||||||
@@ -613,7 +668,7 @@ class Arrays
|
|||||||
* Nothing to do
|
* Nothing to do
|
||||||
*/
|
*/
|
||||||
if (empty($array)) {
|
if (empty($array)) {
|
||||||
return [];
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$replaced = [];
|
$replaced = [];
|
||||||
@@ -724,8 +779,9 @@ class Arrays
|
|||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* @param string $string The string to be converted
|
* @param string $string The string to be converted
|
||||||
* @param string $separator (optional) Separator used between name-value pairs in the string
|
* @param string $separator (optional) Separator used between name-value pairs in the string.
|
||||||
* @param string $valuesKeysSeparator (optional) Separator used between name and value in the string
|
* Default: "|".
|
||||||
|
* @param string $valuesKeysSeparator (optional) Separator used between name and value in the string. Default: ":".
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function string2array($string, $separator = '|', $valuesKeysSeparator = ':')
|
public static function string2array($string, $separator = '|', $valuesKeysSeparator = ':')
|
||||||
@@ -759,52 +815,52 @@ class Arrays
|
|||||||
* Returns information if given keys exist in given array
|
* Returns information if given keys exist in given array
|
||||||
*
|
*
|
||||||
* @param array $keys The keys to find
|
* @param array $keys The keys to find
|
||||||
* @param array $array The array which maybe contains keys
|
* @param array $array The array that maybe contains keys
|
||||||
* @param bool $explicit (optional) If is set to true, all keys should exist in given array. Otherwise - not all.
|
* @param bool $explicit (optional) If is set to true, all keys should exist in given array. Otherwise - not all.
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function areKeysInArray($keys, $array, $explicit = true)
|
public static function areKeysInArray(array $keys, array $array, $explicit = true)
|
||||||
{
|
{
|
||||||
$effect = false;
|
$result = false;
|
||||||
|
|
||||||
if (is_array($array) && !empty($array)) {
|
if (!empty($array)) {
|
||||||
$firstKey = true;
|
$firstKey = true;
|
||||||
|
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$exists = array_key_exists($key, $array);
|
$exists = array_key_exists($key, $array);
|
||||||
|
|
||||||
if ($firstKey) {
|
if ($firstKey) {
|
||||||
$effect = $exists;
|
$result = $exists;
|
||||||
$firstKey = false;
|
$firstKey = false;
|
||||||
} elseif ($explicit) {
|
} elseif ($explicit) {
|
||||||
$effect = $effect && $exists;
|
$result = $result && $exists;
|
||||||
|
|
||||||
if (!$effect) {
|
if (!$result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$effect = $effect || $exists;
|
$result = $result || $exists;
|
||||||
|
|
||||||
if ($effect) {
|
if ($result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $effect;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns paths of the last elements
|
* Returns paths of the last elements
|
||||||
*
|
*
|
||||||
* @param array $array The array with elements
|
* @param array $array The array with elements
|
||||||
* @param string $separator (optional) Separator used in resultant strings. Default: ".".
|
* @param string $separator (optional) Separator used between elements. Default: ".".
|
||||||
* @param string $parentPath (optional) Path of the parent element. Default: "".
|
* @param string $parentPath (optional) Path of the parent element. Default: "".
|
||||||
* @param string|array $stopIfMatchedBy (optional) Patterns of keys or paths that matched will stop the process
|
* @param string|array $stopIfMatchedBy (optional) Patterns of keys or paths that matched will stop the process
|
||||||
* of path building and including children of those keys or paths (recursive
|
* of path building and including children of those keys or paths (recursive
|
||||||
* will not be used for keys in lower level of given array)
|
* will not be used for keys in lower level of given array). Default: "".
|
||||||
* @return array
|
* @return array|null
|
||||||
*
|
*
|
||||||
* Examples - $stopIfMatchedBy argument:
|
* Examples - $stopIfMatchedBy argument:
|
||||||
* a) "\d+"
|
* a) "\d+"
|
||||||
@@ -820,7 +876,7 @@ class Arrays
|
|||||||
* Nothing to do
|
* Nothing to do
|
||||||
*/
|
*/
|
||||||
if (empty($array)) {
|
if (empty($array)) {
|
||||||
return [];
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($stopIfMatchedBy)) {
|
if (!empty($stopIfMatchedBy)) {
|
||||||
@@ -906,12 +962,13 @@ class Arrays
|
|||||||
* first level only.
|
* first level only.
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function areAllKeysMatchedByPattern($array, $pattern, $firstLevelOnly = false)
|
public static function areAllKeysMatchedByPattern(array $array, $pattern, $firstLevelOnly = false)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* It's not an array or it's empty array?
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
*/
|
*/
|
||||||
if (!is_array($array) || (is_array($array) && empty($array))) {
|
if (empty($array)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -955,10 +1012,10 @@ class Arrays
|
|||||||
*
|
*
|
||||||
* @param array $array The array to check
|
* @param array $array The array to check
|
||||||
* @param bool $firstLevelOnly (optional) If is set to true, all keys / indexes are checked. Otherwise - from the
|
* @param bool $firstLevelOnly (optional) If is set to true, all keys / indexes are checked. Otherwise - from the
|
||||||
* first level only.
|
* first level only (default behaviour).
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function areAllKeysIntegers($array, $firstLevelOnly = false)
|
public static function areAllKeysIntegers(array $array, $firstLevelOnly = false)
|
||||||
{
|
{
|
||||||
$pattern = '\d+';
|
$pattern = '\d+';
|
||||||
|
|
||||||
@@ -996,9 +1053,17 @@ class Arrays
|
|||||||
*/
|
*/
|
||||||
public static function getValueByKeysPath(array $array, array $keys)
|
public static function getValueByKeysPath(array $array, array $keys)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$value = null;
|
$value = null;
|
||||||
|
|
||||||
if (!empty($array) && self::issetRecursive($array, $keys)) {
|
if (self::issetRecursive($array, $keys)) {
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$value = $array[$key];
|
$value = $array[$key];
|
||||||
array_shift($keys);
|
array_shift($keys);
|
||||||
@@ -1042,9 +1107,16 @@ class Arrays
|
|||||||
*/
|
*/
|
||||||
public static function issetRecursive(array $array, array $keys)
|
public static function issetRecursive(array $array, array $keys)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$isset = false;
|
$isset = false;
|
||||||
|
|
||||||
if (!empty($array)) {
|
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$isset = isset($array[$key]);
|
$isset = isset($array[$key]);
|
||||||
|
|
||||||
@@ -1059,7 +1131,6 @@ class Arrays
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $isset;
|
return $isset;
|
||||||
}
|
}
|
||||||
@@ -1113,11 +1184,18 @@ class Arrays
|
|||||||
* @param string $keyName (optional) Name of key which will contain the position value
|
* @param string $keyName (optional) Name of key which will contain the position value
|
||||||
* @param int $startPosition (optional) Default, start value of the position for main / given array, not the
|
* @param int $startPosition (optional) Default, start value of the position for main / given array, not the
|
||||||
* children
|
* children
|
||||||
* @return array
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function setPositions(array $array, $keyName = self::POSITION_KEY_NAME, $startPosition = null)
|
public static function setPositions(array $array, $keyName = self::POSITION_KEY_NAME, $startPosition = null)
|
||||||
{
|
{
|
||||||
if (!empty($array)) {
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$childPosition = 1;
|
$childPosition = 1;
|
||||||
|
|
||||||
if (null !== $startPosition) {
|
if (null !== $startPosition) {
|
||||||
@@ -1130,7 +1208,6 @@ class Arrays
|
|||||||
++$childPosition;
|
++$childPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
@@ -1143,14 +1220,19 @@ class Arrays
|
|||||||
*/
|
*/
|
||||||
public static function trimRecursive(array $array)
|
public static function trimRecursive(array $array)
|
||||||
{
|
{
|
||||||
$effect = $array;
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($array)) {
|
$result = [];
|
||||||
$effect = [];
|
|
||||||
|
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$effect[$key] = self::trimRecursive($value);
|
$result[$key] = self::trimRecursive($value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1158,11 +1240,10 @@ class Arrays
|
|||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect[$key] = $value;
|
$result[$key] = $value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $effect;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1255,7 +1336,7 @@ class Arrays
|
|||||||
*
|
*
|
||||||
* @param array $array The array with elements to implode
|
* @param array $array The array with elements to implode
|
||||||
* @param string $separator Separator used to stick together elements of given array
|
* @param string $separator Separator used to stick together elements of given array
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function implodeSmart(array $array, $separator)
|
public static function implodeSmart(array $array, $separator)
|
||||||
{
|
{
|
||||||
@@ -1264,7 +1345,7 @@ class Arrays
|
|||||||
* Nothing to do
|
* Nothing to do
|
||||||
*/
|
*/
|
||||||
if (empty($array)) {
|
if (empty($array)) {
|
||||||
return '';
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($array as &$element) {
|
foreach ($array as &$element) {
|
||||||
@@ -1454,11 +1535,18 @@ class Arrays
|
|||||||
* @param int|null $startIndex (optional) Index from which incrementation should be started. If not provided,
|
* @param int|null $startIndex (optional) Index from which incrementation should be started. If not provided,
|
||||||
* the first index / key will be used.
|
* the first index / key will be used.
|
||||||
* @param int $incrementStep (optional) Value used for incrementation. The step of incrementation.
|
* @param int $incrementStep (optional) Value used for incrementation. The step of incrementation.
|
||||||
* @return array
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function incrementIndexes(array $array, $startIndex = null, $incrementStep = 1)
|
public static function incrementIndexes(array $array, $startIndex = null, $incrementStep = 1)
|
||||||
{
|
{
|
||||||
if (!empty($array)) {
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$valuesToIncrement = [];
|
$valuesToIncrement = [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1498,7 +1586,6 @@ class Arrays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
@@ -1554,6 +1641,14 @@ class Arrays
|
|||||||
*/
|
*/
|
||||||
public static function getDimensionsCount(array $array)
|
public static function getDimensionsCount(array $array)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$dimensionsCount = 1;
|
$dimensionsCount = 1;
|
||||||
|
|
||||||
foreach ($array as $value) {
|
foreach ($array as $value) {
|
||||||
@@ -1577,7 +1672,7 @@ class Arrays
|
|||||||
* Returns non-empty values, e.g. without "" (empty string), null or []
|
* Returns non-empty values, e.g. without "" (empty string), null or []
|
||||||
*
|
*
|
||||||
* @param array $values The values to filter
|
* @param array $values The values to filter
|
||||||
* @return array
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function getNonEmptyValues(array $values)
|
public static function getNonEmptyValues(array $values)
|
||||||
{
|
{
|
||||||
@@ -1586,7 +1681,7 @@ class Arrays
|
|||||||
* Nothing to do
|
* Nothing to do
|
||||||
*/
|
*/
|
||||||
if (empty($values)) {
|
if (empty($values)) {
|
||||||
return [];
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_filter($values, function ($value) {
|
return array_filter($values, function ($value) {
|
||||||
@@ -1602,10 +1697,18 @@ class Arrays
|
|||||||
*
|
*
|
||||||
* @param array $values The values to filter
|
* @param array $values The values to filter
|
||||||
* @param string $separator (optional) Separator used to implode the values. Default: ", ".
|
* @param string $separator (optional) Separator used to implode the values. Default: ", ".
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function getNonEmptyValuesAsString(array $values, $separator = ', ')
|
public static function getNonEmptyValuesAsString(array $values, $separator = ', ')
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($values)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$nonEmpty = self::getNonEmptyValues($values);
|
$nonEmpty = self::getNonEmptyValues($values);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1629,6 +1732,14 @@ class Arrays
|
|||||||
*/
|
*/
|
||||||
private static function getNeighbour(array $array, $element, $next = true)
|
private static function getNeighbour(array $array, $element, $next = true)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$noNext = $next && self::isLastElement($array, $element);
|
$noNext = $next && self::isLastElement($array, $element);
|
||||||
$noPrevious = !$next && self::isFirstElement($array, $element);
|
$noPrevious = !$next && self::isFirstElement($array, $element);
|
||||||
|
|
||||||
|
|||||||
@@ -425,6 +425,14 @@ class Miscellaneous
|
|||||||
*/
|
*/
|
||||||
public static function replace($subject, $search, $replacement, $quoteStrings = false)
|
public static function replace($subject, $search, $replacement, $quoteStrings = false)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Unknown source or item to find or replacement is an empty array?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($subject) || empty($search) || [] === $replacement) {
|
||||||
|
return $subject;
|
||||||
|
}
|
||||||
|
|
||||||
$effect = $subject;
|
$effect = $subject;
|
||||||
|
|
||||||
$searchIsString = is_string($search);
|
$searchIsString = is_string($search);
|
||||||
@@ -444,37 +452,47 @@ class Miscellaneous
|
|||||||
$bothAreStrings = $searchIsString && $replacementIsString;
|
$bothAreStrings = $searchIsString && $replacementIsString;
|
||||||
$bothAreArrays = $searchIsArray && $replacementIsArray;
|
$bothAreArrays = $searchIsArray && $replacementIsArray;
|
||||||
|
|
||||||
/*
|
|
||||||
* First step: replace strings, simple operation with strings
|
|
||||||
*/
|
|
||||||
if ($searchIsString && $replacementIsString) {
|
|
||||||
if ($quoteStrings) {
|
if ($quoteStrings) {
|
||||||
|
if ($replacementIsString) {
|
||||||
$replacement = '\'' . $replacement . '\'';
|
$replacement = '\'' . $replacement . '\'';
|
||||||
|
} elseif ($replacementIsArray) {
|
||||||
|
foreach ($replacement as &$item) {
|
||||||
|
if (is_string($item)) {
|
||||||
|
$item = '\'' . $item . '\'';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1st step: replace strings, simple operation with strings
|
||||||
|
*/
|
||||||
|
if ($bothAreStrings) {
|
||||||
$effect = str_replace($search, $replacement, $subject);
|
$effect = str_replace($search, $replacement, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Second step: replace with regular expressions.
|
* 2nd step: replace with regular expressions.
|
||||||
* Attention. Searched and replacement value should be the same type: strings or arrays.
|
* Attention. Searched and replacement value should be the same type: strings or arrays.
|
||||||
*/
|
*/
|
||||||
if ($effect === $subject && ($bothAreStrings || $bothAreArrays)) {
|
if ($effect === $subject && ($bothAreStrings || $bothAreArrays)) {
|
||||||
if ($quoteStrings && $replacementIsString) {
|
|
||||||
$replacement = '\'' . $replacement . '\'';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I have to avoid string that contains spaces only, e.g. " ".
|
* I have to avoid string that contains spaces only, e.g. " ".
|
||||||
* It's required to avoid bug: preg_replace(): Empty regular expression.
|
* It's required to avoid bug: preg_replace(): Empty regular expression.
|
||||||
*/
|
*/
|
||||||
if ($searchIsArray || ($searchIsString && !empty(trim($search)))) {
|
if ($searchIsArray || ($searchIsString && !empty(trim($search)))) {
|
||||||
$effect = preg_replace($search, $replacement, $subject);
|
$replaced = @preg_replace($search, $replacement, $subject);
|
||||||
|
|
||||||
|
if (null !== $replaced && [] !== $replaced) {
|
||||||
|
$effect = $replaced;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Third step: complex replace of the replacement defined as an array.
|
* 3rd step: complex replace of the replacement defined as an array.
|
||||||
* It may be useful when you want to search for a one string and replace the string with multiple values.
|
* It may be useful when you want to search for a one string and replace the string with multiple values.
|
||||||
*/
|
*/
|
||||||
if ($effect === $subject && $searchIsString && $replacementIsArray) {
|
if ($effect === $subject && $searchIsString && $replacementIsArray) {
|
||||||
@@ -500,16 +518,6 @@ class Miscellaneous
|
|||||||
$exploded = explode($search, $subSubject);
|
$exploded = explode($search, $subSubject);
|
||||||
$explodedCount = count($exploded);
|
$explodedCount = count($exploded);
|
||||||
|
|
||||||
if ($quoteStrings) {
|
|
||||||
foreach ($replacement as &$item) {
|
|
||||||
if (is_string($item)) {
|
|
||||||
$item = '\'' . $item . '\'';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($exploded as $key => $item) {
|
foreach ($exploded as $key => $item) {
|
||||||
$subEffect .= $item;
|
$subEffect .= $item;
|
||||||
|
|
||||||
|
|||||||
22
src/ValueObject/Human.php
Normal file
22
src/ValueObject/Human.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Meritoo\Common\ValueObject;
|
||||||
|
|
||||||
|
use Meritoo\Common\Traits\ValueObject\HumanTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Human
|
||||||
|
*
|
||||||
|
* @author Meritoo <github@meritoo.pl>
|
||||||
|
* @copyright Meritoo <http://www.meritoo.pl>
|
||||||
|
*/
|
||||||
|
class Human
|
||||||
|
{
|
||||||
|
use HumanTrait;
|
||||||
|
}
|
||||||
@@ -88,7 +88,7 @@ class Version
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns string representation of instance of this class
|
* Returns representation of object as string
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Collection;
|
namespace Meritoo\Test\Common\Collection;
|
||||||
|
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Generator;
|
use Generator;
|
||||||
@@ -45,12 +45,12 @@ class CollectionTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testEmptyCollection()
|
public function testEmptyCollection()
|
||||||
{
|
{
|
||||||
static::assertEquals(0, $this->emptyCollection->count());
|
static::assertSame(0, $this->emptyCollection->count());
|
||||||
static::assertCount(0, $this->emptyCollection);
|
static::assertCount(0, $this->emptyCollection);
|
||||||
static::assertEmpty($this->emptyCollection);
|
static::assertEmpty($this->emptyCollection);
|
||||||
|
|
||||||
static::assertTrue($this->emptyCollection->isEmpty());
|
static::assertTrue($this->emptyCollection->isEmpty());
|
||||||
static::assertEquals([], $this->emptyCollection->toArray());
|
static::assertSame([], $this->emptyCollection->toArray());
|
||||||
static::assertEmpty($this->emptyCollection->toArray());
|
static::assertEmpty($this->emptyCollection->toArray());
|
||||||
|
|
||||||
static::assertNull($this->emptyCollection->getFirst());
|
static::assertNull($this->emptyCollection->getFirst());
|
||||||
@@ -61,23 +61,23 @@ class CollectionTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testNotEmptyCollection()
|
public function testNotEmptyCollection()
|
||||||
{
|
{
|
||||||
static::assertEquals(4, $this->simpleCollection->count());
|
static::assertSame(4, $this->simpleCollection->count());
|
||||||
static::assertCount(4, $this->simpleCollection);
|
static::assertCount(4, $this->simpleCollection);
|
||||||
static::assertNotEmpty($this->simpleCollection);
|
static::assertNotEmpty($this->simpleCollection);
|
||||||
|
|
||||||
static::assertFalse($this->simpleCollection->isEmpty());
|
static::assertFalse($this->simpleCollection->isEmpty());
|
||||||
static::assertEquals($this->simpleElements, $this->simpleCollection->toArray());
|
static::assertSame($this->simpleElements, $this->simpleCollection->toArray());
|
||||||
static::assertNotEmpty($this->simpleCollection->toArray());
|
static::assertNotEmpty($this->simpleCollection->toArray());
|
||||||
|
|
||||||
static::assertEquals('lorem', $this->simpleCollection->getFirst());
|
static::assertSame('lorem', $this->simpleCollection->getFirst());
|
||||||
static::assertEquals('sit', $this->simpleCollection->getLast());
|
static::assertSame('sit', $this->simpleCollection->getLast());
|
||||||
static::assertEquals('dolor', $this->simpleCollection[123]);
|
static::assertSame('dolor', $this->simpleCollection[123]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCount()
|
public function testCount()
|
||||||
{
|
{
|
||||||
static::assertEquals(0, $this->emptyCollection->count());
|
static::assertSame(0, $this->emptyCollection->count());
|
||||||
static::assertEquals(4, $this->simpleCollection->count());
|
static::assertSame(4, $this->simpleCollection->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOffsetExists()
|
public function testOffsetExists()
|
||||||
@@ -94,8 +94,8 @@ class CollectionTest extends BaseTestCase
|
|||||||
static::assertNull($this->emptyCollection['abc']);
|
static::assertNull($this->emptyCollection['abc']);
|
||||||
static::assertNull($this->simpleCollection['abc']);
|
static::assertNull($this->simpleCollection['abc']);
|
||||||
|
|
||||||
static::assertEquals('lorem', $this->simpleCollection[0]);
|
static::assertSame('lorem', $this->simpleCollection[0]);
|
||||||
static::assertEquals('sit', $this->simpleCollection[345]);
|
static::assertSame('sit', $this->simpleCollection[345]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOffsetSet()
|
public function testOffsetSet()
|
||||||
@@ -104,10 +104,10 @@ class CollectionTest extends BaseTestCase
|
|||||||
$this->simpleCollection['test2'] = 5678;
|
$this->simpleCollection['test2'] = 5678;
|
||||||
|
|
||||||
static::assertTrue($this->emptyCollection->has(1234));
|
static::assertTrue($this->emptyCollection->has(1234));
|
||||||
static::assertEquals(1234, $this->emptyCollection['test1']);
|
static::assertSame(1234, $this->emptyCollection['test1']);
|
||||||
|
|
||||||
static::assertTrue($this->simpleCollection->has(5678));
|
static::assertTrue($this->simpleCollection->has(5678));
|
||||||
static::assertEquals(5678, $this->simpleCollection['test2']);
|
static::assertSame(5678, $this->simpleCollection['test2']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOffsetUnset()
|
public function testOffsetUnset()
|
||||||
@@ -115,14 +115,14 @@ class CollectionTest extends BaseTestCase
|
|||||||
unset($this->simpleCollection[0]);
|
unset($this->simpleCollection[0]);
|
||||||
|
|
||||||
static::assertFalse($this->simpleCollection->has('lorem'));
|
static::assertFalse($this->simpleCollection->has('lorem'));
|
||||||
static::assertEquals('ipsum', $this->simpleCollection[1]);
|
static::assertSame('ipsum', $this->simpleCollection[1]);
|
||||||
static::assertEquals(3, $this->simpleCollection->count());
|
static::assertSame(3, $this->simpleCollection->count());
|
||||||
|
|
||||||
unset($this->simpleCollection[123]);
|
unset($this->simpleCollection[123]);
|
||||||
|
|
||||||
static::assertFalse($this->simpleCollection->has('dolor'));
|
static::assertFalse($this->simpleCollection->has('dolor'));
|
||||||
static::assertEquals('ipsum', $this->simpleCollection[1]);
|
static::assertSame('ipsum', $this->simpleCollection[1]);
|
||||||
static::assertEquals(2, $this->simpleCollection->count());
|
static::assertSame(2, $this->simpleCollection->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIterator()
|
public function testGetIterator()
|
||||||
@@ -143,8 +143,8 @@ class CollectionTest extends BaseTestCase
|
|||||||
$collection->add($element);
|
$collection->add($element);
|
||||||
|
|
||||||
static::assertTrue($collection->has($element));
|
static::assertTrue($collection->has($element));
|
||||||
static::assertEquals($expectedCount, $collection->count());
|
static::assertSame($expectedCount, $collection->count());
|
||||||
static::assertEquals($element, $collection[$expectedIndex]);
|
static::assertSame($element, $collection[$expectedIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,15 +161,15 @@ class CollectionTest extends BaseTestCase
|
|||||||
$collection->add($element, $index);
|
$collection->add($element, $index);
|
||||||
|
|
||||||
static::assertTrue($collection->has($element));
|
static::assertTrue($collection->has($element));
|
||||||
static::assertEquals($expectedCount, $collection->count());
|
static::assertSame($expectedCount, $collection->count());
|
||||||
static::assertEquals($element, $collection[$expectedIndex]);
|
static::assertSame($element, $collection[$expectedIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddMultipleUsingEmptyArray()
|
public function testAddMultipleUsingEmptyArray()
|
||||||
{
|
{
|
||||||
$this->emptyCollection->addMultiple([]);
|
$this->emptyCollection->addMultiple([]);
|
||||||
|
|
||||||
static::assertEquals(0, $this->emptyCollection->count());
|
static::assertSame(0, $this->emptyCollection->count());
|
||||||
static::assertTrue($this->emptyCollection->isEmpty());
|
static::assertTrue($this->emptyCollection->isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,12 +185,12 @@ class CollectionTest extends BaseTestCase
|
|||||||
$this->emptyCollection->addMultiple($elements);
|
$this->emptyCollection->addMultiple($elements);
|
||||||
|
|
||||||
static::assertFalse($this->emptyCollection->isEmpty());
|
static::assertFalse($this->emptyCollection->isEmpty());
|
||||||
static::assertEquals(4, $this->emptyCollection->count());
|
static::assertSame(4, $this->emptyCollection->count());
|
||||||
|
|
||||||
static::assertEquals('test1', $this->emptyCollection[0]);
|
static::assertSame('test1', $this->emptyCollection[0]);
|
||||||
static::assertEquals('test2', $this->emptyCollection[1]);
|
static::assertSame('test2', $this->emptyCollection[1]);
|
||||||
static::assertEquals('test3', $this->emptyCollection[2]);
|
static::assertSame('test3', $this->emptyCollection[2]);
|
||||||
static::assertEquals('test4', $this->emptyCollection[3]);
|
static::assertSame('test4', $this->emptyCollection[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddMultipleUsingIndexes()
|
public function testAddMultipleUsingIndexes()
|
||||||
@@ -205,12 +205,12 @@ class CollectionTest extends BaseTestCase
|
|||||||
$this->emptyCollection->addMultiple($elements, true);
|
$this->emptyCollection->addMultiple($elements, true);
|
||||||
|
|
||||||
static::assertFalse($this->emptyCollection->isEmpty());
|
static::assertFalse($this->emptyCollection->isEmpty());
|
||||||
static::assertEquals(4, $this->emptyCollection->count());
|
static::assertSame(4, $this->emptyCollection->count());
|
||||||
|
|
||||||
static::assertEquals('test1', $this->emptyCollection[0]);
|
static::assertSame('test1', $this->emptyCollection[0]);
|
||||||
static::assertEquals('test2', $this->emptyCollection[1]);
|
static::assertSame('test2', $this->emptyCollection[1]);
|
||||||
static::assertEquals('test3', $this->emptyCollection[1234]);
|
static::assertSame('test3', $this->emptyCollection[1234]);
|
||||||
static::assertEquals('test4', $this->emptyCollection[5678]);
|
static::assertSame('test4', $this->emptyCollection[5678]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPrepend()
|
public function testPrepend()
|
||||||
@@ -218,14 +218,14 @@ class CollectionTest extends BaseTestCase
|
|||||||
$this->emptyCollection->prepend('lorem-ipsum');
|
$this->emptyCollection->prepend('lorem-ipsum');
|
||||||
|
|
||||||
static::assertFalse($this->emptyCollection->isEmpty());
|
static::assertFalse($this->emptyCollection->isEmpty());
|
||||||
static::assertEquals(1, $this->emptyCollection->count());
|
static::assertSame(1, $this->emptyCollection->count());
|
||||||
static::assertEquals('lorem-ipsum', $this->emptyCollection[0]);
|
static::assertSame('lorem-ipsum', $this->emptyCollection[0]);
|
||||||
|
|
||||||
$this->simpleCollection->prepend('lorem-ipsum');
|
$this->simpleCollection->prepend('lorem-ipsum');
|
||||||
|
|
||||||
static::assertFalse($this->simpleCollection->isEmpty());
|
static::assertFalse($this->simpleCollection->isEmpty());
|
||||||
static::assertEquals(5, $this->simpleCollection->count());
|
static::assertSame(5, $this->simpleCollection->count());
|
||||||
static::assertEquals('lorem-ipsum', $this->simpleCollection[0]);
|
static::assertSame('lorem-ipsum', $this->simpleCollection[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemoveNotExistingElement()
|
public function testRemoveNotExistingElement()
|
||||||
@@ -233,24 +233,24 @@ class CollectionTest extends BaseTestCase
|
|||||||
$this->emptyCollection->remove('abc');
|
$this->emptyCollection->remove('abc');
|
||||||
|
|
||||||
static::assertTrue($this->emptyCollection->isEmpty());
|
static::assertTrue($this->emptyCollection->isEmpty());
|
||||||
static::assertEquals(0, $this->emptyCollection->count());
|
static::assertSame(0, $this->emptyCollection->count());
|
||||||
|
|
||||||
$this->simpleCollection->remove('abc');
|
$this->simpleCollection->remove('abc');
|
||||||
|
|
||||||
static::assertFalse($this->simpleCollection->isEmpty());
|
static::assertFalse($this->simpleCollection->isEmpty());
|
||||||
static::assertEquals(4, $this->simpleCollection->count());
|
static::assertSame(4, $this->simpleCollection->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function testRemove()
|
||||||
{
|
{
|
||||||
static::assertFalse($this->simpleCollection->isEmpty());
|
static::assertFalse($this->simpleCollection->isEmpty());
|
||||||
static::assertEquals(4, $this->simpleCollection->count());
|
static::assertSame(4, $this->simpleCollection->count());
|
||||||
static::assertEquals('ipsum', $this->simpleCollection[1]);
|
static::assertSame('ipsum', $this->simpleCollection[1]);
|
||||||
|
|
||||||
$this->simpleCollection->remove('ipsum');
|
$this->simpleCollection->remove('ipsum');
|
||||||
|
|
||||||
static::assertFalse($this->simpleCollection->isEmpty());
|
static::assertFalse($this->simpleCollection->isEmpty());
|
||||||
static::assertEquals(3, $this->simpleCollection->count());
|
static::assertSame(3, $this->simpleCollection->count());
|
||||||
static::assertNull($this->simpleCollection[1]);
|
static::assertNull($this->simpleCollection[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,8 +290,8 @@ class CollectionTest extends BaseTestCase
|
|||||||
static::assertNull($this->simpleCollection->getPrevious('abc'));
|
static::assertNull($this->simpleCollection->getPrevious('abc'));
|
||||||
static::assertNull($this->simpleCollection->getPrevious('lorem'));
|
static::assertNull($this->simpleCollection->getPrevious('lorem'));
|
||||||
|
|
||||||
static::assertEquals('lorem', $this->simpleCollection->getPrevious('ipsum'));
|
static::assertSame('lorem', $this->simpleCollection->getPrevious('ipsum'));
|
||||||
static::assertEquals('dolor', $this->simpleCollection->getPrevious('sit'));
|
static::assertSame('dolor', $this->simpleCollection->getPrevious('sit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetNext()
|
public function testGetNext()
|
||||||
@@ -300,26 +300,26 @@ class CollectionTest extends BaseTestCase
|
|||||||
static::assertNull($this->simpleCollection->getNext('abc'));
|
static::assertNull($this->simpleCollection->getNext('abc'));
|
||||||
static::assertNull($this->simpleCollection->getNext('sit'));
|
static::assertNull($this->simpleCollection->getNext('sit'));
|
||||||
|
|
||||||
static::assertEquals('dolor', $this->simpleCollection->getNext('ipsum'));
|
static::assertSame('dolor', $this->simpleCollection->getNext('ipsum'));
|
||||||
static::assertEquals('sit', $this->simpleCollection->getNext('dolor'));
|
static::assertSame('sit', $this->simpleCollection->getNext('dolor'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFirst()
|
public function testGetFirst()
|
||||||
{
|
{
|
||||||
static::assertNull($this->emptyCollection->getFirst());
|
static::assertNull($this->emptyCollection->getFirst());
|
||||||
static::assertEquals('lorem', $this->simpleCollection->getFirst());
|
static::assertSame('lorem', $this->simpleCollection->getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLast()
|
public function testGetLast()
|
||||||
{
|
{
|
||||||
static::assertNull($this->emptyCollection->getLast());
|
static::assertNull($this->emptyCollection->getLast());
|
||||||
static::assertEquals('sit', $this->simpleCollection->getLast());
|
static::assertSame('sit', $this->simpleCollection->getLast());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testToArray()
|
public function testToArray()
|
||||||
{
|
{
|
||||||
static::assertEquals([], $this->emptyCollection->toArray());
|
static::assertSame([], $this->emptyCollection->toArray());
|
||||||
static::assertEquals($this->simpleElements, $this->simpleCollection->toArray());
|
static::assertSame($this->simpleElements, $this->simpleCollection->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExistsVisibilityAndArguments()
|
public function testExistsVisibilityAndArguments()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Base;
|
namespace Meritoo\Test\Common\Exception\Base;
|
||||||
|
|
||||||
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
|||||||
74
tests/Exception/Bundle/IncorrectBundleNameExceptionTest.php
Normal file
74
tests/Exception/Bundle/IncorrectBundleNameExceptionTest.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Meritoo\Test\Common\Exception\Bundle;
|
||||||
|
|
||||||
|
use Meritoo\Common\Exception\Bundle\IncorrectBundleNameException;
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test case of an exception used while name of bundle is incorrect
|
||||||
|
*
|
||||||
|
* @author Meritoo <github@meritoo.pl>
|
||||||
|
* @copyright Meritoo <http://www.meritoo.pl>
|
||||||
|
*/
|
||||||
|
class IncorrectBundleNameExceptionTest extends BaseTestCase
|
||||||
|
{
|
||||||
|
public function testConstructor()
|
||||||
|
{
|
||||||
|
static::assertConstructorVisibilityAndArguments(
|
||||||
|
IncorrectBundleNameException::class,
|
||||||
|
OopVisibilityType::IS_PUBLIC,
|
||||||
|
3
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $description Description of test
|
||||||
|
* @param string $bundleName Incorrect name of bundle
|
||||||
|
* @param string $expectedMessage Expected exception's message
|
||||||
|
*
|
||||||
|
* @dataProvider provideBundleNameAndMessage
|
||||||
|
*/
|
||||||
|
public function testCreate($description, $bundleName, $expectedMessage)
|
||||||
|
{
|
||||||
|
$exception = IncorrectBundleNameException::create($bundleName);
|
||||||
|
static::assertSame($expectedMessage, $exception->getMessage(), $description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideBundleNameAndMessage()
|
||||||
|
{
|
||||||
|
$template = 'Name of bundle \'%s\' is incorrect. It should start with big letter and end with "Bundle". Is'
|
||||||
|
. ' there everything ok?';
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty string as name of bundle',
|
||||||
|
'',
|
||||||
|
sprintf($template, ''),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Null as name of bundle',
|
||||||
|
null,
|
||||||
|
sprintf($template, ''),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'String with spaces as name of bundle',
|
||||||
|
'This is test',
|
||||||
|
sprintf($template, 'This is test'),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'String without spaces as name of bundle',
|
||||||
|
'ThisIsTest',
|
||||||
|
sprintf($template, 'ThisIsTest'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Date;
|
namespace Meritoo\Test\Common\Exception\Date;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Type\UnknownDatePartTypeException;
|
use Meritoo\Common\Exception\Type\UnknownDatePartTypeException;
|
||||||
@@ -37,7 +37,7 @@ class UnknownDatePartTypeExceptionTest extends BaseTestCase
|
|||||||
public function testMessage($unknownDatePart, $value, $expectedMessage)
|
public function testMessage($unknownDatePart, $value, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = UnknownDatePartTypeException::createException($unknownDatePart, $value);
|
$exception = UnknownDatePartTypeException::createException($unknownDatePart, $value);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\File;
|
namespace Meritoo\Test\Common\Exception\File;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\File\EmptyFileException;
|
use Meritoo\Common\Exception\File\EmptyFileException;
|
||||||
@@ -35,7 +35,7 @@ class EmptyFileExceptionTest extends BaseTestCase
|
|||||||
public function testMessage($emptyFilePath, $expectedMessage)
|
public function testMessage($emptyFilePath, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = EmptyFileException::create($emptyFilePath);
|
$exception = EmptyFileException::create($emptyFilePath);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\File;
|
namespace Meritoo\Test\Common\Exception\File;
|
||||||
|
|
||||||
use Meritoo\Common\Exception\File\EmptyFilePathException;
|
use Meritoo\Common\Exception\File\EmptyFilePathException;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
@@ -28,6 +28,6 @@ class EmptyFilePathExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage()
|
public function testConstructorMessage()
|
||||||
{
|
{
|
||||||
$exception = EmptyFilePathException::create();
|
$exception = EmptyFilePathException::create();
|
||||||
static::assertEquals('Path of the file is empty. Did you provide path of proper file?', $exception->getMessage());
|
static::assertSame('Path of the file is empty. Did you provide path of proper file?', $exception->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\File;
|
namespace Meritoo\Test\Common\Exception\File;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\File\NotExistingFileException;
|
use Meritoo\Common\Exception\File\NotExistingFileException;
|
||||||
@@ -35,7 +35,7 @@ class NotExistingFileExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($notExistingFilePath, $expectedMessage)
|
public function testConstructorMessage($notExistingFilePath, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = NotExistingFileException::create($notExistingFilePath);
|
$exception = NotExistingFileException::create($notExistingFilePath);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Method;
|
namespace Meritoo\Test\Common\Exception\Method;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Method\DisabledMethodException;
|
use Meritoo\Common\Exception\Method\DisabledMethodException;
|
||||||
@@ -37,7 +37,7 @@ class DisabledMethodExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($disabledMethod, $alternativeMethod, $expectedMessage)
|
public function testConstructorMessage($disabledMethod, $alternativeMethod, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = DisabledMethodException::create($disabledMethod, $alternativeMethod);
|
$exception = DisabledMethodException::create($disabledMethod, $alternativeMethod);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Reflection;
|
namespace Meritoo\Test\Common\Exception\Reflection;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Reflection\CannotResolveClassNameException;
|
use Meritoo\Common\Exception\Reflection\CannotResolveClassNameException;
|
||||||
@@ -38,7 +38,7 @@ class CannotResolveClassNameExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($source, $forClass, $expectedMessage)
|
public function testConstructorMessage($source, $forClass, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = CannotResolveClassNameException::create($source, $forClass);
|
$exception = CannotResolveClassNameException::create($source, $forClass);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Reflection;
|
namespace Meritoo\Test\Common\Exception\Reflection;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Reflection\MissingChildClassesException;
|
use Meritoo\Common\Exception\Reflection\MissingChildClassesException;
|
||||||
@@ -36,7 +36,7 @@ class MissingChildClassesExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($parentClass, $expectedMessage)
|
public function testConstructorMessage($parentClass, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = MissingChildClassesException::create($parentClass);
|
$exception = MissingChildClassesException::create($parentClass);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Meritoo\Test\Common\Exception\Reflection;
|
||||||
|
|
||||||
|
use Meritoo\Common\Exception\Reflection\NotExistingPropertyException;
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class NotExistingPropertyExceptionTest
|
||||||
|
*
|
||||||
|
* @author Meritoo <github@meritoo.pl>
|
||||||
|
* @copyright Meritoo <http://www.meritoo.pl>
|
||||||
|
*/
|
||||||
|
class NotExistingPropertyExceptionTest extends BaseTestCase
|
||||||
|
{
|
||||||
|
public function testConstructor()
|
||||||
|
{
|
||||||
|
static::assertConstructorVisibilityAndArguments(
|
||||||
|
NotExistingPropertyException::class,
|
||||||
|
OopVisibilityType::IS_PUBLIC,
|
||||||
|
3
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $description Description of test
|
||||||
|
* @param mixed $object Object that should contains given property
|
||||||
|
* @param string $property Name of the property
|
||||||
|
* @param string $expectedMessage Expected exception's message
|
||||||
|
*
|
||||||
|
* @dataProvider provideObjectPropertyAndMessage
|
||||||
|
*/
|
||||||
|
public function testCreate($description, $object, $property, $expectedMessage)
|
||||||
|
{
|
||||||
|
$exception = NotExistingPropertyException::create($object, $property);
|
||||||
|
static::assertSame($expectedMessage, $exception->getMessage(), $description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideObjectPropertyAndMessage()
|
||||||
|
{
|
||||||
|
$template = 'Property \'%s\' does not exist in instance of class \'%s\'. Did you use proper name of property?';
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty string as name of property',
|
||||||
|
new \stdClass(),
|
||||||
|
'',
|
||||||
|
sprintf($template, '', get_class(new \stdClass())),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Null as name of property',
|
||||||
|
new \stdClass(),
|
||||||
|
null,
|
||||||
|
sprintf($template, '', get_class(new \stdClass())),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'String with spaces as name of property',
|
||||||
|
new \stdClass(),
|
||||||
|
'This is test',
|
||||||
|
sprintf($template, 'This is test', get_class(new \stdClass())),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'String without spaces as name of property',
|
||||||
|
new \stdClass(),
|
||||||
|
'ThisIsTest',
|
||||||
|
sprintf($template, 'ThisIsTest', get_class(new \stdClass())),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Reflection;
|
namespace Meritoo\Test\Common\Exception\Reflection;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Reflection\TooManyChildClassesException;
|
use Meritoo\Common\Exception\Reflection\TooManyChildClassesException;
|
||||||
@@ -37,7 +37,7 @@ class TooManyChildClassesExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($parentClass, array $childClasses, $expectedMessage)
|
public function testConstructorMessage($parentClass, array $childClasses, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = TooManyChildClassesException::create($parentClass, $childClasses);
|
$exception = TooManyChildClassesException::create($parentClass, $childClasses);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Regex;
|
namespace Meritoo\Test\Common\Exception\Regex;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;
|
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;
|
||||||
@@ -35,7 +35,7 @@ class IncorrectColorHexLengthExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($color, $expectedMessage)
|
public function testConstructorMessage($color, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = IncorrectColorHexLengthException::create($color);
|
$exception = IncorrectColorHexLengthException::create($color);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Regex;
|
namespace Meritoo\Test\Common\Exception\Regex;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
|
use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
|
||||||
@@ -35,7 +35,7 @@ class InvalidColorHexValueExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($color, $expectedMessage)
|
public function testConstructorMessage($color, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = InvalidColorHexValueException::create($color);
|
$exception = InvalidColorHexValueException::create($color);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Regex;
|
namespace Meritoo\Test\Common\Exception\Regex;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Regex\InvalidHtmlAttributesException;
|
use Meritoo\Common\Exception\Regex\InvalidHtmlAttributesException;
|
||||||
@@ -35,7 +35,7 @@ class InvalidHtmlAttributesExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($htmlAttributes, $expectedMessage)
|
public function testConstructorMessage($htmlAttributes, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = InvalidHtmlAttributesException::create($htmlAttributes);
|
$exception = InvalidHtmlAttributesException::create($htmlAttributes);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Regex;
|
namespace Meritoo\Test\Common\Exception\Regex;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Regex\InvalidUrlException;
|
use Meritoo\Common\Exception\Regex\InvalidUrlException;
|
||||||
@@ -35,7 +35,7 @@ class InvalidUrlExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($url, $expectedMessage)
|
public function testConstructorMessage($url, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = InvalidUrlException::create($url);
|
$exception = InvalidUrlException::create($url);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Exception\Type;
|
namespace Meritoo\Test\Common\Exception\Type;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException;
|
use Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException;
|
||||||
@@ -36,7 +36,7 @@ class UnknownOopVisibilityTypeExceptionTest extends BaseTestCase
|
|||||||
public function testConstructorMessage($unknownType, $expectedMessage)
|
public function testConstructorMessage($unknownType, $expectedMessage)
|
||||||
{
|
{
|
||||||
$exception = UnknownOopVisibilityTypeException::createException($unknownType);
|
$exception = UnknownOopVisibilityTypeException::createException($unknownType);
|
||||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
static::assertSame($expectedMessage, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Test\Base;
|
namespace Meritoo\Test\Common\Test\Base;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Generator;
|
use Generator;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Type\Base;
|
namespace Meritoo\Test\Common\Type\Base;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Type;
|
namespace Meritoo\Test\Common\Type;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTypeTestCase;
|
use Meritoo\Common\Test\Base\BaseTypeTestCase;
|
||||||
use Meritoo\Common\Type\DatePartType;
|
use Meritoo\Common\Type\DatePartType;
|
||||||
@@ -19,29 +19,6 @@ use Meritoo\Common\Type\DatePartType;
|
|||||||
*/
|
*/
|
||||||
class DatePartTypeTest extends BaseTypeTestCase
|
class DatePartTypeTest extends BaseTypeTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getAllExpectedTypes()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'DAY' => DatePartType::DAY,
|
|
||||||
'HOUR' => DatePartType::HOUR,
|
|
||||||
'MINUTE' => DatePartType::MINUTE,
|
|
||||||
'MONTH' => DatePartType::MONTH,
|
|
||||||
'SECOND' => DatePartType::SECOND,
|
|
||||||
'YEAR' => DatePartType::YEAR,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getTestedTypeInstance()
|
|
||||||
{
|
|
||||||
return new DatePartType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -97,4 +74,27 @@ class DatePartTypeTest extends BaseTypeTestCase
|
|||||||
true,
|
true,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function getAllExpectedTypes()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'DAY' => DatePartType::DAY,
|
||||||
|
'HOUR' => DatePartType::HOUR,
|
||||||
|
'MINUTE' => DatePartType::MINUTE,
|
||||||
|
'MONTH' => DatePartType::MONTH,
|
||||||
|
'SECOND' => DatePartType::SECOND,
|
||||||
|
'YEAR' => DatePartType::YEAR,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function getTestedTypeInstance()
|
||||||
|
{
|
||||||
|
return new DatePartType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Type;
|
namespace Meritoo\Test\Common\Type;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Generator;
|
use Generator;
|
||||||
@@ -214,34 +214,6 @@ class DatePeriodTest extends BaseTypeTestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all expected types of the tested type
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function getAllExpectedTypes()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'LAST_MONTH' => DatePeriod::LAST_MONTH,
|
|
||||||
'LAST_WEEK' => DatePeriod::LAST_WEEK,
|
|
||||||
'LAST_YEAR' => DatePeriod::LAST_YEAR,
|
|
||||||
'NEXT_MONTH' => DatePeriod::NEXT_MONTH,
|
|
||||||
'NEXT_WEEK' => DatePeriod::NEXT_WEEK,
|
|
||||||
'NEXT_YEAR' => DatePeriod::NEXT_YEAR,
|
|
||||||
'THIS_MONTH' => DatePeriod::THIS_MONTH,
|
|
||||||
'THIS_WEEK' => DatePeriod::THIS_WEEK,
|
|
||||||
'THIS_YEAR' => DatePeriod::THIS_YEAR,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getTestedTypeInstance()
|
|
||||||
{
|
|
||||||
return new DatePeriod();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -277,4 +249,32 @@ class DatePeriodTest extends BaseTypeTestCase
|
|||||||
true,
|
true,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all expected types of the tested type
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getAllExpectedTypes()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'LAST_MONTH' => DatePeriod::LAST_MONTH,
|
||||||
|
'LAST_WEEK' => DatePeriod::LAST_WEEK,
|
||||||
|
'LAST_YEAR' => DatePeriod::LAST_YEAR,
|
||||||
|
'NEXT_MONTH' => DatePeriod::NEXT_MONTH,
|
||||||
|
'NEXT_WEEK' => DatePeriod::NEXT_WEEK,
|
||||||
|
'NEXT_YEAR' => DatePeriod::NEXT_YEAR,
|
||||||
|
'THIS_MONTH' => DatePeriod::THIS_MONTH,
|
||||||
|
'THIS_WEEK' => DatePeriod::THIS_WEEK,
|
||||||
|
'THIS_YEAR' => DatePeriod::THIS_YEAR,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function getTestedTypeInstance()
|
||||||
|
{
|
||||||
|
return new DatePeriod();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Arrays;
|
namespace Meritoo\Test\Common\Utilities\Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple class convertible to string.
|
* Simple class convertible to string.
|
||||||
@@ -35,7 +35,9 @@ class SimpleToString
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Returns representation of object as string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Test\Utilities\Arrays\SimpleToString;
|
|
||||||
use Meritoo\Common\Utilities\Arrays;
|
use Meritoo\Common\Utilities\Arrays;
|
||||||
|
use Meritoo\Test\Common\Utilities\Arrays\SimpleToString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case of the useful arrays methods
|
* Test case of the useful arrays methods
|
||||||
@@ -31,50 +31,95 @@ class ArraysTest extends BaseTestCase
|
|||||||
static::assertHasNoConstructor(Arrays::class);
|
static::assertHasNoConstructor(Arrays::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValues2string()
|
/**
|
||||||
|
* @param string $description Description of test
|
||||||
|
* @param string $expected Expected array converted to string
|
||||||
|
* @param array $array Data to be converted
|
||||||
|
* @param string $arrayColumnKey (optional) Column name. Default: "".
|
||||||
|
* @param string $separator (optional) Separator used between values. Default: ",".
|
||||||
|
*
|
||||||
|
* @dataProvider provideArrayValues2string
|
||||||
|
*/
|
||||||
|
public function testValues2string($description, $expected, array $array, $arrayColumnKey = '', $separator = ',')
|
||||||
{
|
{
|
||||||
/*
|
self::assertSame($expected, Arrays::values2string($array, $arrayColumnKey, $separator), $description);
|
||||||
* Simple array / string
|
|
||||||
*/
|
|
||||||
$simpleString = 'Lorem,ipsum,dolor,sit,amet';
|
|
||||||
$simpleStringWithDots = str_replace(',', '.', $simpleString);
|
|
||||||
|
|
||||||
self::assertEquals($simpleString, Arrays::values2string($this->simpleArray));
|
|
||||||
self::assertEquals('ipsum', Arrays::values2string($this->simpleArray, 1));
|
|
||||||
self::assertEquals($simpleStringWithDots, Arrays::values2string($this->simpleArray, '', '.'));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Complex array / string
|
|
||||||
*/
|
|
||||||
$complexString = 'sit,egestas,adipiscing,1234,,donec,quis,elit,iaculis,primis';
|
|
||||||
$complexStringWithDots = str_replace(',', '.', $complexString);
|
|
||||||
|
|
||||||
self::assertEquals($complexString, Arrays::values2string($this->complexArray));
|
|
||||||
self::assertEquals($complexStringWithDots, Arrays::values2string($this->complexArray, '', '.'));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Other cases
|
|
||||||
*/
|
|
||||||
self::assertEquals('', Arrays::values2string([]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValuesKeys2string()
|
/**
|
||||||
{
|
* @param string $description Description of test
|
||||||
self::assertEquals('0=Lorem,1=ipsum,2=dolor,3=sit,4=amet', Arrays::valuesKeys2string($this->simpleArray));
|
* @param string $expected Expected array converted to string
|
||||||
self::assertEquals('0=Lorem;1=ipsum;2=dolor;3=sit;4=amet', Arrays::valuesKeys2string($this->simpleArray, ';'));
|
* @param array $array Data to be converted
|
||||||
self::assertEquals('0=Lorem 1=ipsum 2=dolor 3=sit 4=amet', Arrays::valuesKeys2string($this->simpleArray, ' '));
|
* @param string $separator (optional) Separator used between name-value pairs. Default: ",".
|
||||||
|
* @param string $valuesKeysSeparator (optional) Separator used between name and value. Default: "=".
|
||||||
|
* @param string $valuesWrapper (optional) Wrapper used to wrap values, e.g. double-quote: key="value".
|
||||||
|
* Default: "".
|
||||||
|
*
|
||||||
|
* @dataProvider provideArrayValuesKeysConverted2string
|
||||||
|
*/
|
||||||
|
public function testValuesKeys2string(
|
||||||
|
$description,
|
||||||
|
$expected,
|
||||||
|
array $array,
|
||||||
|
$separator = ',',
|
||||||
|
$valuesKeysSeparator = '=',
|
||||||
|
$valuesWrapper = ''
|
||||||
|
) {
|
||||||
|
self::assertSame(
|
||||||
|
$expected,
|
||||||
|
Arrays::valuesKeys2string($array, $separator, $valuesKeysSeparator, $valuesWrapper),
|
||||||
|
$description
|
||||||
|
);
|
||||||
|
|
||||||
self::assertEquals('0="Lorem" 1="ipsum" 2="dolor" 3="sit" 4="amet"', Arrays::valuesKeys2string($this->simpleArray, ' ', '=', '"'));
|
self::assertSame(
|
||||||
self::assertEquals('0="Lorem", 1="ipsum", 2="dolor", 3="sit", 4="amet"', Arrays::valuesKeys2string($this->simpleArray, ', ', '=', '"'));
|
'0=Lorem,1=ipsum,2=dolor,3=sit,4=amet',
|
||||||
|
Arrays::valuesKeys2string($this->simpleArray),
|
||||||
|
'Simple array'
|
||||||
|
);
|
||||||
|
|
||||||
|
self::assertSame(
|
||||||
|
'0=Lorem;1=ipsum;2=dolor;3=sit;4=amet',
|
||||||
|
Arrays::valuesKeys2string($this->simpleArray, ';'),
|
||||||
|
'Simple array (with custom separator)'
|
||||||
|
);
|
||||||
|
|
||||||
|
self::assertSame(
|
||||||
|
'0=Lorem 1=ipsum 2=dolor 3=sit 4=amet',
|
||||||
|
Arrays::valuesKeys2string($this->simpleArray, ' '),
|
||||||
|
'Simple array (with custom separator)'
|
||||||
|
);
|
||||||
|
|
||||||
|
self::assertSame(
|
||||||
|
'0="Lorem" 1="ipsum" 2="dolor" 3="sit" 4="amet"',
|
||||||
|
Arrays::valuesKeys2string($this->simpleArray, ' ', '=', '"'),
|
||||||
|
'Simple array (with custom separators)'
|
||||||
|
);
|
||||||
|
|
||||||
|
self::assertSame(
|
||||||
|
'0="Lorem", 1="ipsum", 2="dolor", 3="sit", 4="amet"',
|
||||||
|
Arrays::valuesKeys2string($this->simpleArray, ', ', '=', '"'),
|
||||||
|
'Simple array (with custom separators)'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValues2csv()
|
/**
|
||||||
|
* @param string $description Description of test
|
||||||
|
* @param string $expected Expected array converted to csv string
|
||||||
|
* @param array $array Data to be converted. It have to be an array that represents database table.
|
||||||
|
* @param string $separator (optional) Separator used between values. Default: ",".
|
||||||
|
*
|
||||||
|
* @dataProvider provideArrayValues2csv
|
||||||
|
*/
|
||||||
|
public function testValues2csv($description, $expected, array $array, $separator = ',')
|
||||||
{
|
{
|
||||||
self::assertEquals('', Arrays::values2csv($this->simpleArray));
|
self::assertSame($expected, Arrays::values2csv($array, $separator), $description);
|
||||||
|
self::assertSame('', Arrays::values2csv($this->simpleArray), 'Simple array');
|
||||||
|
|
||||||
self::assertEquals("lorem,ipsum,dolor,sit,amet\n"
|
self::assertSame("lorem,ipsum,dolor,sit,amet\n"
|
||||||
. "consectetur,adipiscing,elit\n"
|
. "consectetur,adipiscing,elit\n"
|
||||||
. 'donec,sagittis,fringilla,eleifend', Arrays::values2csv($this->twoDimensionsArray));
|
. 'donec,sagittis,fringilla,eleifend',
|
||||||
|
Arrays::values2csv($this->twoDimensionsArray),
|
||||||
|
'Two dimensions array'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFirstKey()
|
public function testGetFirstKey()
|
||||||
@@ -93,6 +138,7 @@ class ArraysTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testGetLastKey()
|
public function testGetLastKey()
|
||||||
{
|
{
|
||||||
|
self::assertNull(Arrays::getLastKey([]));
|
||||||
self::assertEquals(4, Arrays::getLastKey($this->simpleArray));
|
self::assertEquals(4, Arrays::getLastKey($this->simpleArray));
|
||||||
self::assertEquals('amet', Arrays::getLastKey($this->complexArray));
|
self::assertEquals('amet', Arrays::getLastKey($this->complexArray));
|
||||||
}
|
}
|
||||||
@@ -146,6 +192,7 @@ class ArraysTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testGetLastElementBreadCrumb()
|
public function testGetLastElementBreadCrumb()
|
||||||
{
|
{
|
||||||
|
self::assertNull(Arrays::getLastElementBreadCrumb([]));
|
||||||
self::assertEquals('4/amet', Arrays::getLastElementBreadCrumb($this->simpleArray));
|
self::assertEquals('4/amet', Arrays::getLastElementBreadCrumb($this->simpleArray));
|
||||||
self::assertEquals('2/3/eleifend', Arrays::getLastElementBreadCrumb($this->twoDimensionsArray));
|
self::assertEquals('2/3/eleifend', Arrays::getLastElementBreadCrumb($this->twoDimensionsArray));
|
||||||
self::assertEquals('amet/1/primis', Arrays::getLastElementBreadCrumb($this->complexArray));
|
self::assertEquals('amet/1/primis', Arrays::getLastElementBreadCrumb($this->complexArray));
|
||||||
@@ -279,6 +326,18 @@ letsTest[2] = value_2;';
|
|||||||
self::assertEquals($effect, Arrays::array2JavaScript($this->twoDimensionsArray, 'letsTest', true));
|
self::assertEquals($effect, Arrays::array2JavaScript($this->twoDimensionsArray, 'letsTest', true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $description Description of test case
|
||||||
|
* @param array|null $expected Expected new array (with quoted elements)
|
||||||
|
* @param array $array The array to check for string values
|
||||||
|
*
|
||||||
|
* @dataProvider provideArrayToQuoteStrings
|
||||||
|
*/
|
||||||
|
public function testQuoteStrings($description, $expected, array $array)
|
||||||
|
{
|
||||||
|
self::assertSame($expected, Arrays::quoteStrings($array), $description);
|
||||||
|
}
|
||||||
|
|
||||||
public function testRemoveMarginalElement()
|
public function testRemoveMarginalElement()
|
||||||
{
|
{
|
||||||
$array = $this->simpleArray;
|
$array = $this->simpleArray;
|
||||||
@@ -343,7 +402,7 @@ letsTest[2] = value_2;';
|
|||||||
|
|
||||||
public function testSetKeysAsValuesEmptyArray()
|
public function testSetKeysAsValuesEmptyArray()
|
||||||
{
|
{
|
||||||
self::assertEquals([], Arrays::setKeysAsValues([]));
|
self::assertNull(Arrays::setKeysAsValues([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetKeysAsValuesSameKeysValues()
|
public function testSetKeysAsValuesSameKeysValues()
|
||||||
@@ -456,6 +515,7 @@ letsTest[2] = value_2;';
|
|||||||
/*
|
/*
|
||||||
* Negative cases
|
* Negative cases
|
||||||
*/
|
*/
|
||||||
|
self::assertFalse(Arrays::areKeysInArray([], []));
|
||||||
self::assertFalse(Arrays::areKeysInArray([null], $this->simpleArray));
|
self::assertFalse(Arrays::areKeysInArray([null], $this->simpleArray));
|
||||||
self::assertFalse(Arrays::areKeysInArray([''], $this->simpleArray));
|
self::assertFalse(Arrays::areKeysInArray([''], $this->simpleArray));
|
||||||
self::assertFalse(Arrays::areKeysInArray(['dolorrr'], $this->simpleArrayWithKeys));
|
self::assertFalse(Arrays::areKeysInArray(['dolorrr'], $this->simpleArrayWithKeys));
|
||||||
@@ -520,7 +580,7 @@ letsTest[2] = value_2;';
|
|||||||
|
|
||||||
public function testGetLastElementsPathsUsingEmptyArray()
|
public function testGetLastElementsPathsUsingEmptyArray()
|
||||||
{
|
{
|
||||||
self::assertSame([], Arrays::getLastElementsPaths([]));
|
self::assertNull(Arrays::getLastElementsPaths([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLastElementsPathsUsingDefaults()
|
public function testGetLastElementsPathsUsingDefaults()
|
||||||
@@ -585,9 +645,9 @@ letsTest[2] = value_2;';
|
|||||||
$pattern = '\d+';
|
$pattern = '\d+';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Complex array with strings and integers as keys
|
* Empty array
|
||||||
*/
|
*/
|
||||||
self::assertFalse(Arrays::areAllKeysMatchedByPattern($this->complexArray, $pattern));
|
self::assertFalse(Arrays::areAllKeysMatchedByPattern([], $pattern));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple array with integers as keys only
|
* Simple array with integers as keys only
|
||||||
@@ -595,9 +655,9 @@ letsTest[2] = value_2;';
|
|||||||
self::assertTrue(Arrays::areAllKeysMatchedByPattern($this->simpleArray, $pattern));
|
self::assertTrue(Arrays::areAllKeysMatchedByPattern($this->simpleArray, $pattern));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Empty array
|
* Complex array with strings and integers as keys
|
||||||
*/
|
*/
|
||||||
self::assertFalse(Arrays::areAllKeysMatchedByPattern([], $pattern));
|
self::assertFalse(Arrays::areAllKeysMatchedByPattern($this->complexArray, $pattern));
|
||||||
|
|
||||||
$array = [
|
$array = [
|
||||||
'a' => 'b',
|
'a' => 'b',
|
||||||
@@ -638,6 +698,7 @@ letsTest[2] = value_2;';
|
|||||||
|
|
||||||
public function testAreAllKeysIntegers()
|
public function testAreAllKeysIntegers()
|
||||||
{
|
{
|
||||||
|
self::assertFalse(Arrays::areAllKeysIntegers([]));
|
||||||
self::assertEquals(1, Arrays::areAllKeysIntegers($this->simpleArray));
|
self::assertEquals(1, Arrays::areAllKeysIntegers($this->simpleArray));
|
||||||
self::assertEquals(2, Arrays::areAllKeysIntegers($this->simpleArray));
|
self::assertEquals(2, Arrays::areAllKeysIntegers($this->simpleArray));
|
||||||
self::assertEquals('', Arrays::areAllKeysIntegers($this->complexArray));
|
self::assertEquals('', Arrays::areAllKeysIntegers($this->complexArray));
|
||||||
@@ -885,8 +946,7 @@ letsTest[2] = value_2;';
|
|||||||
/*
|
/*
|
||||||
* Negative cases
|
* Negative cases
|
||||||
*/
|
*/
|
||||||
self::assertEmpty(Arrays::setPositions([]));
|
self::assertNull(Arrays::setPositions([]));
|
||||||
self::assertEquals([], Arrays::setPositions([]));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Positive case - 1-dimension array
|
* Positive case - 1-dimension array
|
||||||
@@ -983,7 +1043,7 @@ letsTest[2] = value_2;';
|
|||||||
/*
|
/*
|
||||||
* Negative cases
|
* Negative cases
|
||||||
*/
|
*/
|
||||||
self::assertEquals([], Arrays::trimRecursive([]));
|
self::assertSame([], Arrays::trimRecursive([]));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Positive cases
|
* Positive cases
|
||||||
@@ -1125,7 +1185,7 @@ letsTest[2] = value_2;';
|
|||||||
/*
|
/*
|
||||||
* Empty array
|
* Empty array
|
||||||
*/
|
*/
|
||||||
self::assertEmpty(Arrays::implodeSmart([], $separator));
|
self::assertNull(Arrays::implodeSmart([], $separator));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple, one-dimension array
|
* Simple, one-dimension array
|
||||||
@@ -1214,7 +1274,7 @@ letsTest[2] = value_2;';
|
|||||||
/*
|
/*
|
||||||
* Negative cases
|
* Negative cases
|
||||||
*/
|
*/
|
||||||
self::assertEquals([], Arrays::incrementIndexes([]));
|
self::assertNull(Arrays::incrementIndexes([]));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Positive cases
|
* Positive cases
|
||||||
@@ -1454,7 +1514,7 @@ letsTest[2] = value_2;';
|
|||||||
/*
|
/*
|
||||||
* Basic cases
|
* Basic cases
|
||||||
*/
|
*/
|
||||||
self::assertEquals(1, Arrays::getDimensionsCount([]));
|
self::assertEquals(0, Arrays::getDimensionsCount([]));
|
||||||
self::assertEquals(1, Arrays::getDimensionsCount(['']));
|
self::assertEquals(1, Arrays::getDimensionsCount(['']));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1487,6 +1547,11 @@ letsTest[2] = value_2;';
|
|||||||
self::assertTrue(Arrays::isMultiDimensional($this->complexArray));
|
self::assertTrue(Arrays::isMultiDimensional($this->complexArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetNonEmptyValuesUsingEmptyArray()
|
||||||
|
{
|
||||||
|
self::assertNull(Arrays::getNonEmptyValues([]));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $description Description of test case
|
* @param string $description Description of test case
|
||||||
* @param array $values The values to filter
|
* @param array $values The values to filter
|
||||||
@@ -1854,12 +1919,6 @@ letsTest[2] = value_2;';
|
|||||||
{
|
{
|
||||||
$simpleObject = new SimpleToString('1234');
|
$simpleObject = new SimpleToString('1234');
|
||||||
|
|
||||||
yield[
|
|
||||||
'An empty array (no values to filter)',
|
|
||||||
[],
|
|
||||||
[],
|
|
||||||
];
|
|
||||||
|
|
||||||
yield[
|
yield[
|
||||||
'All values are empty',
|
'All values are empty',
|
||||||
[
|
[
|
||||||
@@ -1955,7 +2014,7 @@ letsTest[2] = value_2;';
|
|||||||
yield[
|
yield[
|
||||||
'An empty array (no values to filter)',
|
'An empty array (no values to filter)',
|
||||||
[],
|
[],
|
||||||
'',
|
null,
|
||||||
];
|
];
|
||||||
|
|
||||||
yield[
|
yield[
|
||||||
@@ -2032,7 +2091,7 @@ letsTest[2] = value_2;';
|
|||||||
'An empty array (no values to filter)',
|
'An empty array (no values to filter)',
|
||||||
[],
|
[],
|
||||||
' | ',
|
' | ',
|
||||||
'',
|
null,
|
||||||
];
|
];
|
||||||
|
|
||||||
yield[
|
yield[
|
||||||
@@ -2103,6 +2162,524 @@ letsTest[2] = value_2;';
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideArrayValuesKeysConverted2string()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'An empty array',
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Empty string and null as value',
|
||||||
|
'test_1=,test_2=,test_3=3',
|
||||||
|
[
|
||||||
|
'test_1' => null,
|
||||||
|
'test_2' => '',
|
||||||
|
'test_3' => '3',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Empty string and null as value (with custom separators)',
|
||||||
|
'test_1="" test_2="" test_3="3"',
|
||||||
|
[
|
||||||
|
'test_1' => null,
|
||||||
|
'test_2' => '',
|
||||||
|
'test_3' => '3',
|
||||||
|
],
|
||||||
|
' ',
|
||||||
|
'=',
|
||||||
|
'"',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Empty string as key',
|
||||||
|
'1=test_1,=test_2,3=test_3',
|
||||||
|
[
|
||||||
|
1 => 'test_1',
|
||||||
|
'' => 'test_2',
|
||||||
|
'3' => 'test_3',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Empty string as key (with custom separators)',
|
||||||
|
'1 => "test_1"; => "test_2"; 3 => "test_3"',
|
||||||
|
[
|
||||||
|
1 => 'test_1',
|
||||||
|
'' => 'test_2',
|
||||||
|
'3' => 'test_3',
|
||||||
|
],
|
||||||
|
'; ',
|
||||||
|
' => ',
|
||||||
|
'"',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Mixed types of keys and values',
|
||||||
|
'test_1=test test,test_2=2,test_3=3.45',
|
||||||
|
[
|
||||||
|
'test_1' => 'test test',
|
||||||
|
'test_2' => 2,
|
||||||
|
'test_3' => 3.45,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Mixed types of keys and values (with custom separators)',
|
||||||
|
'test_1 --> *test test* | test_2 --> *2* | test_3 --> *3.45*',
|
||||||
|
[
|
||||||
|
'test_1' => 'test test',
|
||||||
|
'test_2' => 2,
|
||||||
|
'test_3' => 3.45,
|
||||||
|
],
|
||||||
|
' | ',
|
||||||
|
' --> ',
|
||||||
|
'*',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideArrayValues2csv()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'An empty array',
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Empty string, and empty array and null as row',
|
||||||
|
"1,2,3\n5,6,",
|
||||||
|
[
|
||||||
|
'test_1' => '',
|
||||||
|
'test_2' => [],
|
||||||
|
'test_3' => null,
|
||||||
|
'test_4' => [
|
||||||
|
'aa' => 1,
|
||||||
|
'bb' => 2,
|
||||||
|
'cc' => 3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dd' => 5,
|
||||||
|
'ee' => 6,
|
||||||
|
'ff' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Empty string, and empty array and null as row (with custom separator)',
|
||||||
|
"1, 2, 3\n5, 6, ",
|
||||||
|
[
|
||||||
|
'test_1' => '',
|
||||||
|
'test_2' => [],
|
||||||
|
'test_3' => null,
|
||||||
|
'test_4' => [
|
||||||
|
'aa' => 1,
|
||||||
|
'bb' => 2,
|
||||||
|
'cc' => 3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dd' => 5,
|
||||||
|
'ee' => 6,
|
||||||
|
'ff' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
', ',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Empty string as key, non-array as value',
|
||||||
|
"1,2,3\n5,6,",
|
||||||
|
[
|
||||||
|
'' => 'test_1',
|
||||||
|
1 => 'test_2',
|
||||||
|
'3' => [
|
||||||
|
'aa' => 1,
|
||||||
|
'bb' => 2,
|
||||||
|
'cc' => 3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dd' => 5,
|
||||||
|
'ee' => 6,
|
||||||
|
'ff' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Empty string as key, non-array as value (with custom separator)',
|
||||||
|
"1 | 2 | 3\n5 | 6 | ",
|
||||||
|
[
|
||||||
|
'' => 'test_1',
|
||||||
|
1 => 'test_2',
|
||||||
|
'3' => [
|
||||||
|
'aa' => 1,
|
||||||
|
'bb' => 2,
|
||||||
|
'cc' => 3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dd' => 5,
|
||||||
|
'ee' => 6,
|
||||||
|
'ff' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
' | ',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Invalid structure, not like database table',
|
||||||
|
"1,2,3\n5,6\n7,8,9,10",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'aa' => 1,
|
||||||
|
'bb' => 2,
|
||||||
|
'cc' => 3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dd' => 5,
|
||||||
|
'ee' => 6,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Invalid structure, not like database table (with custom separator)',
|
||||||
|
"1 <-> 2 <-> 3\n5 <-> 6\n7 <-> 8 <-> 9 <-> 10",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'aa' => 1,
|
||||||
|
'bb' => 2,
|
||||||
|
'cc' => 3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dd' => 5,
|
||||||
|
'ee' => 6,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
' <-> ',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Mixed types of keys and values',
|
||||||
|
"1,2,3.45\n5,6,\n7,8,9,,10",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'aa' => 1,
|
||||||
|
'bb' => 2,
|
||||||
|
'cc' => 3.45,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dd' => 5,
|
||||||
|
'ee' => 6,
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
'qq' => 9,
|
||||||
|
'',
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Mixed types of keys and values (with custom separator)',
|
||||||
|
"1 // 2 // 3.45\n5 // 6 // \n7 // 8 // 9 // // 10",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'aa' => 1,
|
||||||
|
'bb' => 2,
|
||||||
|
'cc' => 3.45,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dd' => 5,
|
||||||
|
'ee' => 6,
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
'qq' => 9,
|
||||||
|
'',
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
' // ',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideArrayValues2string()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'An empty array',
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Simple array',
|
||||||
|
'Test 1,Test 2,Test 3',
|
||||||
|
[
|
||||||
|
1 => 'Test 1',
|
||||||
|
2 => 'Test 2',
|
||||||
|
3 => 'Test 3',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Simple array (with custom separator)',
|
||||||
|
'Test 1.Test 2.Test 3',
|
||||||
|
[
|
||||||
|
1 => 'Test 1',
|
||||||
|
2 => 'Test 2',
|
||||||
|
3 => 'Test 3',
|
||||||
|
],
|
||||||
|
'',
|
||||||
|
'.',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Simple array (concrete column)',
|
||||||
|
'Test 2',
|
||||||
|
[
|
||||||
|
1 => 'Test 1',
|
||||||
|
2 => 'Test 2',
|
||||||
|
3 => 'Test 3',
|
||||||
|
],
|
||||||
|
2,
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Simple array (concrete column with custom separator)',
|
||||||
|
'Test 2',
|
||||||
|
[
|
||||||
|
1 => 'Test 1',
|
||||||
|
2 => 'Test 2',
|
||||||
|
3 => 'Test 3',
|
||||||
|
],
|
||||||
|
2,
|
||||||
|
'.',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Complex array',
|
||||||
|
'1,2,3,test 1,test 2,test 3,,test 4,,bbb,3.45',
|
||||||
|
[
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'test 1',
|
||||||
|
'test 2',
|
||||||
|
[
|
||||||
|
'test 3',
|
||||||
|
'',
|
||||||
|
'test 4',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
'a' => '',
|
||||||
|
'b' => 'bbb',
|
||||||
|
[],
|
||||||
|
'c' => 3.45,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'1st complex array (concrete column)',
|
||||||
|
'2,test 2,',
|
||||||
|
[
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'test 1',
|
||||||
|
'test 2',
|
||||||
|
[
|
||||||
|
'test 3',
|
||||||
|
'',
|
||||||
|
'test 4',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
'a' => '',
|
||||||
|
'b' => 'bbb',
|
||||||
|
[],
|
||||||
|
'c' => 3.45,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
1,
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'2nd complex array (concrete column)',
|
||||||
|
'bb,1234,0xb',
|
||||||
|
[
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'a' => 'aa',
|
||||||
|
'b' => 'bb',
|
||||||
|
'c' => 'cc',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'a',
|
||||||
|
'b',
|
||||||
|
'c',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'a' => '',
|
||||||
|
'b' => 1234,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'c' => 5678,
|
||||||
|
'b' => '0xb',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'b',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'3rd complex array (concrete column with custom separator)',
|
||||||
|
'bb - 1234 - 3xb - bbb',
|
||||||
|
[
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'a' => 'aa',
|
||||||
|
'b' => 'bb',
|
||||||
|
'c' => 'cc',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'a',
|
||||||
|
'b' => [],
|
||||||
|
'c',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'a' => '',
|
||||||
|
'b' => 1234,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'c' => 5678,
|
||||||
|
'b' => [
|
||||||
|
'b1' => '0xb',
|
||||||
|
'b2' => '1xb',
|
||||||
|
'b' => '3xb',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
'a' => 'aaa',
|
||||||
|
'b' => 'bbb',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'b',
|
||||||
|
' - ',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideArrayToQuoteStrings()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'An empty array',
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Simple array',
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
'\'1\'',
|
||||||
|
'\'2\'',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
'1',
|
||||||
|
'2',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Complex array',
|
||||||
|
[
|
||||||
|
123,
|
||||||
|
'\'456\'',
|
||||||
|
[
|
||||||
|
'x' => [
|
||||||
|
0,
|
||||||
|
'\'0\'',
|
||||||
|
1 => '\'1\'',
|
||||||
|
2 => 2,
|
||||||
|
],
|
||||||
|
'\'y\'',
|
||||||
|
],
|
||||||
|
444 => '\'\'',
|
||||||
|
[
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'\'test\'',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
123,
|
||||||
|
'456',
|
||||||
|
[
|
||||||
|
'x' => [
|
||||||
|
0,
|
||||||
|
'0',
|
||||||
|
1 => '1',
|
||||||
|
2 => 2,
|
||||||
|
],
|
||||||
|
'y',
|
||||||
|
],
|
||||||
|
444 => '',
|
||||||
|
[
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'test',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\Bootstrap4CssSelector;
|
use Meritoo\Common\Utilities\Bootstrap4CssSelector;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Bundle\IncorrectBundleNameException;
|
use Meritoo\Common\Exception\Bundle\IncorrectBundleNameException;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\CssSelector;
|
use Meritoo\Common\Utilities\CssSelector;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
@@ -680,7 +680,8 @@ class DateTest extends BaseTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $period The period, type of period. One of DatePeriod class constants, e.g. DatePeriod::LAST_WEEK.
|
* @param int $period The period, type of period. One of DatePeriod class constants, e.g.
|
||||||
|
* DatePeriod::LAST_WEEK.
|
||||||
* @param DatePeriod $expected Expected start and end date for given period
|
* @param DatePeriod $expected Expected start and end date for given period
|
||||||
*
|
*
|
||||||
* @dataProvider provideCorrectPeriod
|
* @dataProvider provideCorrectPeriod
|
||||||
@@ -982,7 +983,9 @@ class DateTest extends BaseTestCase
|
|||||||
DatePeriod::NEXT_WEEK,
|
DatePeriod::NEXT_WEEK,
|
||||||
new DatePeriod(
|
new DatePeriod(
|
||||||
(new DateTime('this week'))->add(new DateInterval('P7D'))->setTime(0, 0, 0),
|
(new DateTime('this week'))->add(new DateInterval('P7D'))->setTime(0, 0, 0),
|
||||||
(new DateTime('this week'))->add(new DateInterval('P7D'))->add(new DateInterval('P6D'))->setTime(23, 59, 59)
|
(new DateTime('this week'))->add(new DateInterval('P7D'))
|
||||||
|
->add(new DateInterval('P6D'))
|
||||||
|
->setTime(23, 59, 59)
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\GeneratorUtility;
|
use Meritoo\Common\Utilities\GeneratorUtility;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
@@ -80,8 +80,8 @@ class LocaleTest extends BaseTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $category Named constant specifying the category of the functions affected by the locale setting.
|
* @param int $category Named constant specifying the category of the functions affected by the locale
|
||||||
* It's the same constant as required by setlocale() function.
|
* setting. It's the same constant as required by setlocale() function.
|
||||||
* @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
|
* @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
|
||||||
* @param string $countryCode Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
|
* @param string $countryCode Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
|
||||||
* @param string $expectedLocale Expected locale
|
* @param string $expectedLocale Expected locale
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;
|
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;
|
||||||
@@ -14,7 +14,6 @@ use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
|
|||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\Locale;
|
use Meritoo\Common\Utilities\Locale;
|
||||||
use Meritoo\Common\Utilities\Miscellaneous;
|
use Meritoo\Common\Utilities\Miscellaneous;
|
||||||
use ReflectionException;
|
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,9 +29,6 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
private $stringDotSeparated;
|
private $stringDotSeparated;
|
||||||
private $stringWithoutSpaces;
|
private $stringWithoutSpaces;
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
static::assertHasNoConstructor(Miscellaneous::class);
|
static::assertHasNoConstructor(Miscellaneous::class);
|
||||||
@@ -226,57 +222,68 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
self::assertEquals($this->stringSmall, Miscellaneous::replace($this->stringSmall, $search, $replacement3, true));
|
self::assertEquals($this->stringSmall, Miscellaneous::replace($this->stringSmall, $search, $replacement3, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReplace()
|
/**
|
||||||
|
* @param string $description Description of test
|
||||||
|
* @param string|array $subject The string or an array of strings to search and replace
|
||||||
|
* @param string|array $search String or pattern or array of patterns to find. It may be: string, an array
|
||||||
|
* of strings or an array of patterns.
|
||||||
|
* @param string|array $replacement The string or an array of strings to replace. It may be: string or an array
|
||||||
|
* of strings.
|
||||||
|
* @param mixed $result Result of replacing
|
||||||
|
*
|
||||||
|
* @dataProvider provideEmptyValuesToReplace
|
||||||
|
*/
|
||||||
|
public function testReplaceUsingEmptyValues($description, $subject, $search, $replacement, $result)
|
||||||
{
|
{
|
||||||
/*
|
static::assertSame($result, Miscellaneous::replace($subject, $search, $replacement), $description);
|
||||||
* Common variables
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $description Description of test
|
||||||
|
* @param string $subject The string or an array of strings to search and replace
|
||||||
|
* @param string $search String or pattern or array of patterns to find. It may be: string, an array of
|
||||||
|
* strings or an array of patterns.
|
||||||
|
* @param string $replacement The string or an array of strings to replace. It may be: string or an array of
|
||||||
|
* strings.
|
||||||
|
* @param mixed $result Result of replacing
|
||||||
|
*
|
||||||
|
* @dataProvider provideStringsToReplace
|
||||||
*/
|
*/
|
||||||
$quoteStrings = true;
|
public function testReplaceUsingStrings($description, $subject, $search, $replacement, $result)
|
||||||
|
{
|
||||||
|
static::assertSame($result, Miscellaneous::replace($subject, $search, $replacement), $description);
|
||||||
|
}
|
||||||
|
|
||||||
$subject = [
|
/**
|
||||||
$this->stringSmall,
|
* @param string $description Description of test
|
||||||
$this->stringDotSeparated,
|
* @param string $subject The string or an array of strings to search and replace
|
||||||
];
|
* @param string $search String or pattern or array of patterns to find. It may be: string, an array of
|
||||||
|
* strings or an array of patterns.
|
||||||
/*
|
* @param string $replacement The string or an array of strings to replace. It may be: string or an array of
|
||||||
* Testing replace with an array
|
* strings.
|
||||||
|
* @param mixed $result Result of replacing
|
||||||
|
*
|
||||||
|
* @dataProvider provideRegexToReplace
|
||||||
*/
|
*/
|
||||||
$search = [
|
public function testReplaceUsingRegex($description, $subject, $search, $replacement, $result)
|
||||||
'|ipsum|',
|
{
|
||||||
'|pellentesque|',
|
static::assertSame($result, Miscellaneous::replace($subject, $search, $replacement), $description);
|
||||||
];
|
}
|
||||||
|
|
||||||
$replacement = [
|
/**
|
||||||
'commodo',
|
* @param string $description Description of test
|
||||||
'interdum',
|
* @param string $subject The string or an array of strings to search and replace
|
||||||
];
|
* @param string $search String or pattern or array of patterns to find. It may be: string, an array of
|
||||||
|
* strings or an array of patterns.
|
||||||
$replaced1 = Miscellaneous::replace($subject, $search, $replacement);
|
* @param string $replacement The string or an array of strings to replace. It may be: string or an array of
|
||||||
$replaced2 = Miscellaneous::replace($subject, $search, $replacement, true);
|
* strings.
|
||||||
|
* @param mixed $result Result of replacing
|
||||||
self::assertEquals('Lorem commodo dolor sit amet.', $replaced1[0]);
|
*
|
||||||
self::assertEquals('Etiam ullamcorper. Suspendisse a interdum dui, non felis.', $replaced1[1]);
|
* @dataProvider provideDataToReplaceWithQuoteStrings
|
||||||
|
|
||||||
self::assertEquals('Lorem commodo dolor sit amet.', $replaced2[0]);
|
|
||||||
self::assertEquals('Etiam ullamcorper. Suspendisse a interdum dui, non felis.', $replaced2[1]);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Testing replace with string
|
|
||||||
*/
|
*/
|
||||||
$searchString = 'ipsum';
|
public function testReplaceWithQuoteStrings($description, $subject, $search, $replacement, $result)
|
||||||
$replacementString = 'commodo';
|
{
|
||||||
|
static::assertSame($result, Miscellaneous::replace($subject, $search, $replacement, true), $description);
|
||||||
$replaced = Miscellaneous::replace($subject, $searchString, $replacementString, $quoteStrings);
|
|
||||||
self::assertEquals('Lorem \'commodo\' dolor sit amet.', $replaced[0]);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Testing replace with mixed values:
|
|
||||||
* - subject: array
|
|
||||||
* - search: string
|
|
||||||
* - replacement: string
|
|
||||||
*/
|
|
||||||
$replacedMixed = Miscellaneous::replace($subject, $searchString, $replacement, $quoteStrings);
|
|
||||||
self::assertEquals('Lorem \'commodo\' dolor sit amet.', $replacedMixed[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUppercaseFirst()
|
public function testUppercaseFirst()
|
||||||
@@ -372,7 +379,7 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
mkdir($directory1Path, 0777, true);
|
mkdir($directory1Path, 0777, true);
|
||||||
mkdir($directory2Path, 0777, true);
|
mkdir($directory2Path, 0777, true);
|
||||||
|
|
||||||
self::assertTrue(Miscellaneous::removeDirectory(sys_get_temp_dir() . '/lorem', false));
|
self::assertTrue(Miscellaneous::removeDirectory(sys_get_temp_dir() . '/lorem'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -641,10 +648,6 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
self::assertEquals(255, Miscellaneous::getValidColorComponent(255, false));
|
self::assertEquals(255, Miscellaneous::getValidColorComponent(255, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws IncorrectColorHexLengthException
|
|
||||||
* @throws InvalidColorHexValueException
|
|
||||||
*/
|
|
||||||
public function testGetInvertedColorWithIncorrectLength()
|
public function testGetInvertedColorWithIncorrectLength()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(IncorrectColorHexLengthException::class);
|
$this->setExpectedException(IncorrectColorHexLengthException::class);
|
||||||
@@ -659,10 +662,6 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
Miscellaneous::getInvertedColor('1234567');
|
Miscellaneous::getInvertedColor('1234567');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws IncorrectColorHexLengthException
|
|
||||||
* @throws InvalidColorHexValueException
|
|
||||||
*/
|
|
||||||
public function testGetInvertedColorWithInvalidValue()
|
public function testGetInvertedColorWithInvalidValue()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(InvalidColorHexValueException::class);
|
$this->setExpectedException(InvalidColorHexValueException::class);
|
||||||
@@ -674,10 +673,6 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
Miscellaneous::getInvertedColor('00ppqq');
|
Miscellaneous::getInvertedColor('00ppqq');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws IncorrectColorHexLengthException
|
|
||||||
* @throws InvalidColorHexValueException
|
|
||||||
*/
|
|
||||||
public function testGetInvertedColor()
|
public function testGetInvertedColor()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -1156,6 +1151,322 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideEmptyValuesToReplace()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'An empty string as subject',
|
||||||
|
'',
|
||||||
|
'test',
|
||||||
|
'another test',
|
||||||
|
'',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty array as subject',
|
||||||
|
[],
|
||||||
|
'test',
|
||||||
|
'another test',
|
||||||
|
[],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Null as subject',
|
||||||
|
null,
|
||||||
|
'test',
|
||||||
|
'another test',
|
||||||
|
null,
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty string to search',
|
||||||
|
'test',
|
||||||
|
'',
|
||||||
|
'another test',
|
||||||
|
'test',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty array to search',
|
||||||
|
'test',
|
||||||
|
[],
|
||||||
|
'another test',
|
||||||
|
'test',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Null to search',
|
||||||
|
'test',
|
||||||
|
null,
|
||||||
|
'another test',
|
||||||
|
'test',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty string as replacement',
|
||||||
|
'test',
|
||||||
|
'another test',
|
||||||
|
'',
|
||||||
|
'test',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty array as replacement',
|
||||||
|
'test',
|
||||||
|
'another test',
|
||||||
|
[],
|
||||||
|
'test',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Null as replacement',
|
||||||
|
'test',
|
||||||
|
'another test',
|
||||||
|
null,
|
||||||
|
'test',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideStringsToReplace()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'Different count of strings to search and replace - 1st part',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
[
|
||||||
|
'ipsum',
|
||||||
|
],
|
||||||
|
'commodo',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Different count of strings to search and replace - 2nd part',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'ipsum',
|
||||||
|
[
|
||||||
|
'commodo',
|
||||||
|
],
|
||||||
|
'Lorem commodo dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Replace 1 not existing word in 1 sentence (nothing to replace)',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'plum',
|
||||||
|
'commodo',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Replace 1 word in 1 sentence',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'ipsum',
|
||||||
|
'commodo',
|
||||||
|
'Lorem commodo dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Replace 1 not existing word in 2 sentences (nothing to replace)',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit amet',
|
||||||
|
],
|
||||||
|
'plum',
|
||||||
|
'commodo',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit amet',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Replace 1 word in 2 sentences',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit amet',
|
||||||
|
],
|
||||||
|
'amet',
|
||||||
|
'commodo',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit commodo',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit commodo',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideRegexToReplace()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'Different count of strings to search and replace - 1st part',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
[
|
||||||
|
'|ipsum|',
|
||||||
|
],
|
||||||
|
'commodo',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Different count of strings to search and replace - 2nd part',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'|ipsum|',
|
||||||
|
[
|
||||||
|
'commodo',
|
||||||
|
],
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'1 pattern (word -> "")',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'|ipsum|',
|
||||||
|
'',
|
||||||
|
'Lorem dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'1 pattern (word -> word)',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'|ipsum|',
|
||||||
|
'commodo',
|
||||||
|
'Lorem commodo dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'2 patterns (word -> word)',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
[
|
||||||
|
'|ipsum|',
|
||||||
|
'|amet|',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'commodo',
|
||||||
|
'egestas',
|
||||||
|
],
|
||||||
|
'Lorem commodo dolor sit egestas',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'1 word in 2 sentences',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit amet',
|
||||||
|
],
|
||||||
|
'|amet|',
|
||||||
|
'commodo',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit commodo',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit commodo',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'2 words in 2 sentences',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit amet',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'|ipsum|',
|
||||||
|
'|amet|',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'commodo',
|
||||||
|
'egestas',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Lorem commodo dolor sit egestas',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit egestas',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideDataToReplaceWithQuoteStrings()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'An empty string as subject',
|
||||||
|
'',
|
||||||
|
'test',
|
||||||
|
'another test',
|
||||||
|
'',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty string to search',
|
||||||
|
'test',
|
||||||
|
'',
|
||||||
|
'another test',
|
||||||
|
'test',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'An empty string as replacement',
|
||||||
|
'test',
|
||||||
|
'another test',
|
||||||
|
'',
|
||||||
|
'test',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Replace 1 not existing word in 1 sentence (nothing to replace)',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'plum',
|
||||||
|
'commodo',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Replace 1 word in 1 sentence',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'ipsum',
|
||||||
|
'commodo',
|
||||||
|
'Lorem \'commodo\' dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'Replace 1 word in 2 sentences',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit amet',
|
||||||
|
],
|
||||||
|
'amet',
|
||||||
|
'commodo',
|
||||||
|
[
|
||||||
|
'Lorem ipsum dolor sit \'commodo\'',
|
||||||
|
'Maecenas sed diam eget risus varius blandit sit \'commodo\'',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'1 pattern (word -> "")',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'|ipsum|',
|
||||||
|
'',
|
||||||
|
'Lorem \'\' dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'1 pattern (word -> word)',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
'|ipsum|',
|
||||||
|
'commodo',
|
||||||
|
'Lorem \'commodo\' dolor sit amet',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'2 patterns (word -> word)',
|
||||||
|
'Lorem ipsum dolor sit amet',
|
||||||
|
[
|
||||||
|
'|ipsum|',
|
||||||
|
'|amet|',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'commodo',
|
||||||
|
'egestas',
|
||||||
|
],
|
||||||
|
'Lorem \'commodo\' dolor sit \'egestas\'',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -1175,10 +1486,6 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
unset($this->stringSmall, $this->stringCommaSeparated, $this->stringDotSeparated, $this->stringWithoutSpaces);
|
||||||
unset($this->stringSmall);
|
|
||||||
unset($this->stringCommaSeparated);
|
|
||||||
unset($this->stringDotSeparated);
|
|
||||||
unset($this->stringWithoutSpaces);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
@@ -260,7 +260,8 @@ class QueryBuilderUtilityTest extends BaseTestCase
|
|||||||
$entityManager
|
$entityManager
|
||||||
->expects(static::any())
|
->expects(static::any())
|
||||||
->method('getExpressionBuilder')
|
->method('getExpressionBuilder')
|
||||||
->willReturn(new Expr());
|
->willReturn(new Expr())
|
||||||
|
;
|
||||||
|
|
||||||
yield[
|
yield[
|
||||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The A class.
|
* The A class.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The B class.
|
* The B class.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The C class.
|
* The C class.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The D class.
|
* The D class.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The E trait.
|
* The E trait.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The F class.
|
* The F class.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The G class.
|
* The G class.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The H class.
|
* The H class.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Reflection;
|
namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The H interface.
|
* The H interface.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Generator;
|
use Generator;
|
||||||
@@ -16,16 +16,16 @@ use Meritoo\Common\Exception\Reflection\MissingChildClassesException;
|
|||||||
use Meritoo\Common\Exception\Reflection\NotExistingPropertyException;
|
use Meritoo\Common\Exception\Reflection\NotExistingPropertyException;
|
||||||
use Meritoo\Common\Exception\Reflection\TooManyChildClassesException;
|
use Meritoo\Common\Exception\Reflection\TooManyChildClassesException;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\A;
|
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\B;
|
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\C;
|
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\D;
|
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\E;
|
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\F;
|
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\G;
|
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\H;
|
|
||||||
use Meritoo\Common\Test\Utilities\Reflection\I;
|
|
||||||
use Meritoo\Common\Utilities\Reflection;
|
use Meritoo\Common\Utilities\Reflection;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\A;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\B;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\C;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\D;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\E;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\F;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\G;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\H;
|
||||||
|
use Meritoo\Test\Common\Utilities\Reflection\I;
|
||||||
use ReflectionProperty;
|
use ReflectionProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +107,7 @@ class ReflectionTest extends BaseTestCase
|
|||||||
/*
|
/*
|
||||||
* Existing class
|
* Existing class
|
||||||
*/
|
*/
|
||||||
self::assertEquals('Meritoo\Common\Test\Utilities', Reflection::getClassNamespace(self::class));
|
self::assertEquals('Meritoo\Test\Common\Utilities', Reflection::getClassNamespace(self::class));
|
||||||
self::assertEquals(DateTime::class, Reflection::getClassNamespace(new DateTime()));
|
self::assertEquals(DateTime::class, Reflection::getClassNamespace(new DateTime()));
|
||||||
|
|
||||||
self::assertEquals(DateTime::class, Reflection::getClassNamespace([
|
self::assertEquals(DateTime::class, Reflection::getClassNamespace([
|
||||||
@@ -410,7 +410,7 @@ class ReflectionTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testGetMaxNumberConstant()
|
public function testGetMaxNumberConstant()
|
||||||
{
|
{
|
||||||
static::assertEquals(5, Reflection::getMaxNumberConstant(H::class));
|
static::assertSame(5, Reflection::getMaxNumberConstant(H::class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHasMethodUsingClassWithoutMethod()
|
public function testHasMethodUsingClassWithoutMethod()
|
||||||
@@ -450,7 +450,7 @@ class ReflectionTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testGetConstantValue()
|
public function testGetConstantValue()
|
||||||
{
|
{
|
||||||
static::assertEquals(H::LOREM, Reflection::getConstantValue(H::class, 'LOREM'));
|
static::assertSame(H::LOREM, Reflection::getConstantValue(H::class, 'LOREM'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsInterfaceImplementedUsingClassWithoutInterface()
|
public function testIsInterfaceImplementedUsingClassWithoutInterface()
|
||||||
@@ -484,7 +484,7 @@ class ReflectionTest extends BaseTestCase
|
|||||||
|
|
||||||
static::assertInstanceOf(ReflectionProperty::class, $property);
|
static::assertInstanceOf(ReflectionProperty::class, $property);
|
||||||
static::assertTrue($property->isPrivate());
|
static::assertTrue($property->isPrivate());
|
||||||
static::assertEquals('count', $property->getName());
|
static::assertSame('count', $property->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPropertyUsingClassWithProtectedProperty()
|
public function testGetPropertyUsingClassWithProtectedProperty()
|
||||||
@@ -493,7 +493,7 @@ class ReflectionTest extends BaseTestCase
|
|||||||
|
|
||||||
static::assertInstanceOf(ReflectionProperty::class, $property);
|
static::assertInstanceOf(ReflectionProperty::class, $property);
|
||||||
static::assertTrue($property->isProtected());
|
static::assertTrue($property->isProtected());
|
||||||
static::assertEquals('name', $property->getName());
|
static::assertSame('name', $property->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities\Repository;
|
namespace Meritoo\Test\Common\Utilities\Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sortable object/entity.
|
* Sortable object/entity.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
@@ -14,8 +14,8 @@ use Doctrine\ORM\Query\Expr\OrderBy;
|
|||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Test\Utilities\Repository\Sortable;
|
|
||||||
use Meritoo\Common\Utilities\Repository;
|
use Meritoo\Common\Utilities\Repository;
|
||||||
|
use Meritoo\Test\Common\Utilities\Repository\Sortable;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +36,7 @@ class RepositoryTest extends BaseTestCase
|
|||||||
$items = [];
|
$items = [];
|
||||||
Repository::replenishPositions($items);
|
Repository::replenishPositions($items);
|
||||||
|
|
||||||
static::assertEquals([], $items);
|
static::assertSame([], $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReplenishPositionsUsingNotSortableObjects()
|
public function testReplenishPositionsUsingNotSortableObjects()
|
||||||
@@ -85,10 +85,10 @@ class RepositoryTest extends BaseTestCase
|
|||||||
public function testReplenishPositionsUsingArraysWithoutExtremePosition(array $items)
|
public function testReplenishPositionsUsingArraysWithoutExtremePosition(array $items)
|
||||||
{
|
{
|
||||||
Repository::replenishPositions($items);
|
Repository::replenishPositions($items);
|
||||||
static::assertEquals($items, $items);
|
static::assertSame($items, $items);
|
||||||
|
|
||||||
Repository::replenishPositions($items, false);
|
Repository::replenishPositions($items, false);
|
||||||
static::assertEquals($items, $items);
|
static::assertSame($items, $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,7 +101,7 @@ class RepositoryTest extends BaseTestCase
|
|||||||
public function testReplenishPositionsUsingArraysWithoutExtremePositionForce(array $items, $asLast, array $expected)
|
public function testReplenishPositionsUsingArraysWithoutExtremePositionForce(array $items, $asLast, array $expected)
|
||||||
{
|
{
|
||||||
Repository::replenishPositions($items, $asLast, true);
|
Repository::replenishPositions($items, $asLast, true);
|
||||||
static::assertEquals($expected, $items);
|
static::assertSame($expected, $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +114,7 @@ class RepositoryTest extends BaseTestCase
|
|||||||
public function testReplenishPositionsUsingArraysWithExtremePositionForce(array $items, $asLast, array $expected)
|
public function testReplenishPositionsUsingArraysWithExtremePositionForce(array $items, $asLast, array $expected)
|
||||||
{
|
{
|
||||||
Repository::replenishPositions($items, $asLast, true);
|
Repository::replenishPositions($items, $asLast, true);
|
||||||
static::assertEquals($expected, $items);
|
static::assertSame($expected, $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,10 +124,10 @@ class RepositoryTest extends BaseTestCase
|
|||||||
public function testReplenishPositionsUsingObjectsWithoutExtremePosition(array $items)
|
public function testReplenishPositionsUsingObjectsWithoutExtremePosition(array $items)
|
||||||
{
|
{
|
||||||
Repository::replenishPositions($items);
|
Repository::replenishPositions($items);
|
||||||
static::assertEquals($items, $items);
|
static::assertSame($items, $items);
|
||||||
|
|
||||||
Repository::replenishPositions($items, false);
|
Repository::replenishPositions($items, false);
|
||||||
static::assertEquals($items, $items);
|
static::assertSame($items, $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -171,7 +171,7 @@ class RepositoryTest extends BaseTestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetExtremePositionUsingArraysWithoutExtremePosition(array $items, $max, $expected)
|
public function testGetExtremePositionUsingArraysWithoutExtremePosition(array $items, $max, $expected)
|
||||||
{
|
{
|
||||||
static::assertEquals($expected, Repository::getExtremePosition($items, $max));
|
static::assertSame($expected, Repository::getExtremePosition($items, $max));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,7 +183,7 @@ class RepositoryTest extends BaseTestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetExtremePositionUsingArraysWithExtremePosition(array $items, $max, $expected)
|
public function testGetExtremePositionUsingArraysWithExtremePosition(array $items, $max, $expected)
|
||||||
{
|
{
|
||||||
static::assertEquals($expected, Repository::getExtremePosition($items, $max));
|
static::assertSame($expected, Repository::getExtremePosition($items, $max));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,7 +195,7 @@ class RepositoryTest extends BaseTestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetExtremePositionUsingObjectsWithoutExtremePosition(array $items, $max, $expected)
|
public function testGetExtremePositionUsingObjectsWithoutExtremePosition(array $items, $max, $expected)
|
||||||
{
|
{
|
||||||
static::assertEquals($expected, Repository::getExtremePosition($items, $max));
|
static::assertSame($expected, Repository::getExtremePosition($items, $max));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,7 +207,7 @@ class RepositoryTest extends BaseTestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetExtremePositionUsingObjectsWithExtremePosition(array $items, $max, $expected)
|
public function testGetExtremePositionUsingObjectsWithExtremePosition(array $items, $max, $expected)
|
||||||
{
|
{
|
||||||
static::assertEquals($expected, Repository::getExtremePosition($items, $max));
|
static::assertSame($expected, Repository::getExtremePosition($items, $max));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetEntityOrderedQueryBuilderUsingDefaults()
|
public function testGetEntityOrderedQueryBuilderUsingDefaults()
|
||||||
@@ -220,7 +220,8 @@ class RepositoryTest extends BaseTestCase
|
|||||||
->setMethods([
|
->setMethods([
|
||||||
'createQueryBuilder',
|
'createQueryBuilder',
|
||||||
])
|
])
|
||||||
->getMock();
|
->getMock()
|
||||||
|
;
|
||||||
|
|
||||||
$expectedQueryBuilder = new QueryBuilder($entityManager);
|
$expectedQueryBuilder = new QueryBuilder($entityManager);
|
||||||
$expectedQueryBuilder->from('any_table_name', 'qb');
|
$expectedQueryBuilder->from('any_table_name', 'qb');
|
||||||
@@ -228,7 +229,8 @@ class RepositoryTest extends BaseTestCase
|
|||||||
$entityRepository
|
$entityRepository
|
||||||
->expects(static::once())
|
->expects(static::once())
|
||||||
->method('createQueryBuilder')
|
->method('createQueryBuilder')
|
||||||
->willReturn($expectedQueryBuilder);
|
->willReturn($expectedQueryBuilder)
|
||||||
|
;
|
||||||
|
|
||||||
$queryBuilder = Repository::getEntityOrderedQueryBuilder($entityRepository);
|
$queryBuilder = Repository::getEntityOrderedQueryBuilder($entityRepository);
|
||||||
$selectDQLPart = $queryBuilder->getDQLPart('select');
|
$selectDQLPart = $queryBuilder->getDQLPart('select');
|
||||||
@@ -262,7 +264,8 @@ class RepositoryTest extends BaseTestCase
|
|||||||
->setMethods([
|
->setMethods([
|
||||||
'createQueryBuilder',
|
'createQueryBuilder',
|
||||||
])
|
])
|
||||||
->getMock();
|
->getMock()
|
||||||
|
;
|
||||||
|
|
||||||
$expectedQueryBuilder = new QueryBuilder($entityManager);
|
$expectedQueryBuilder = new QueryBuilder($entityManager);
|
||||||
$expectedQueryBuilder->from('any_table_name', 'qb');
|
$expectedQueryBuilder->from('any_table_name', 'qb');
|
||||||
@@ -270,7 +273,8 @@ class RepositoryTest extends BaseTestCase
|
|||||||
$entityRepository
|
$entityRepository
|
||||||
->expects(static::once())
|
->expects(static::once())
|
||||||
->method('createQueryBuilder')
|
->method('createQueryBuilder')
|
||||||
->willReturn($expectedQueryBuilder);
|
->willReturn($expectedQueryBuilder)
|
||||||
|
;
|
||||||
|
|
||||||
$queryBuilder = Repository::getEntityOrderedQueryBuilder($entityRepository, $property, $direction);
|
$queryBuilder = Repository::getEntityOrderedQueryBuilder($entityRepository, $property, $direction);
|
||||||
$selectDQLPart = $queryBuilder->getDQLPart('select');
|
$selectDQLPart = $queryBuilder->getDQLPart('select');
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Test\Common\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\Xml;
|
use Meritoo\Common\Utilities\Xml;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\ValueObject;
|
namespace Meritoo\Test\Common\ValueObject;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Type\OopVisibilityType;
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\ValueObject;
|
namespace Meritoo\Test\Common\ValueObject;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Type\OopVisibilityType;
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\ValueObject;
|
namespace Meritoo\Test\Common\ValueObject;
|
||||||
|
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Type\OopVisibilityType;
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
|||||||
116
tests/ValueObject/HumanTest.php
Normal file
116
tests/ValueObject/HumanTest.php
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Meritoo\Test\Common\ValueObject;
|
||||||
|
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
use Meritoo\Common\ValueObject\Human;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test case for the human
|
||||||
|
*
|
||||||
|
* @author Meritoo <github@meritoo.pl>
|
||||||
|
* @copyright Meritoo <http://www.meritoo.pl>
|
||||||
|
*/
|
||||||
|
class HumanTest extends BaseTestCase
|
||||||
|
{
|
||||||
|
public function testConstructor()
|
||||||
|
{
|
||||||
|
static::assertConstructorVisibilityAndArguments(
|
||||||
|
Human::class,
|
||||||
|
OopVisibilityType::IS_PUBLIC,
|
||||||
|
4,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $description Description of test
|
||||||
|
* @param Human $human Human to verify
|
||||||
|
* @param string $expected Expected string
|
||||||
|
*
|
||||||
|
* @dataProvider provideHuman
|
||||||
|
*/
|
||||||
|
public function testToString($description, Human $human, $expected)
|
||||||
|
{
|
||||||
|
static::assertSame($expected, (string)$human, $description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetFirstName()
|
||||||
|
{
|
||||||
|
$empty = new Human('', '');
|
||||||
|
static::assertSame('', $empty->getFirstName());
|
||||||
|
|
||||||
|
$human = new Human('John', 'Scott');
|
||||||
|
static::assertSame('John', $human->getFirstName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLastName()
|
||||||
|
{
|
||||||
|
$empty = new Human('', '');
|
||||||
|
static::assertSame('', $empty->getLastName());
|
||||||
|
|
||||||
|
$human = new Human('John', 'Scott');
|
||||||
|
static::assertSame('Scott', $human->getLastName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetBirthDate()
|
||||||
|
{
|
||||||
|
$empty = new Human('', '');
|
||||||
|
static::assertNull($empty->getBirthDate());
|
||||||
|
|
||||||
|
$human = new Human('John', 'Scott', '', new \DateTime('2001-01-01'));
|
||||||
|
static::assertEquals(new \DateTime('2001-01-01'), $human->getBirthDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetFullName()
|
||||||
|
{
|
||||||
|
$empty = new Human('', '');
|
||||||
|
static::assertSame('', $empty->getFullName());
|
||||||
|
|
||||||
|
$human = new Human('John', 'Scott', '', new \DateTime('2001-01-01'));
|
||||||
|
static::assertSame('John Scott', $human->getFullName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetEmail()
|
||||||
|
{
|
||||||
|
$empty = new Human('', '');
|
||||||
|
static::assertNull($empty->getEmail());
|
||||||
|
|
||||||
|
$human = new Human('John', 'Scott', 'john@scott.com');
|
||||||
|
static::assertSame('john@scott.com', $human->getEmail());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideHuman()
|
||||||
|
{
|
||||||
|
yield[
|
||||||
|
'Without any data (an empty human)',
|
||||||
|
new Human('', ''),
|
||||||
|
'',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'With first and last name only',
|
||||||
|
new Human('John', 'Scott'),
|
||||||
|
'John Scott',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'With first name, last name and email',
|
||||||
|
new Human('John', 'Scott', 'john@scott.com'),
|
||||||
|
'John Scott <john@scott.com>',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
'With whole/complete data',
|
||||||
|
new Human('John', 'Scott', 'john@scott.com', new \DateTime('2001-01-01')),
|
||||||
|
'John Scott <john@scott.com>',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Test\ValueObject;
|
namespace Meritoo\Test\Common\ValueObject;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
|||||||
Reference in New Issue
Block a user