mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
787b8c697c | ||
|
|
96c02cdc3d | ||
|
|
87d7bff5f5 | ||
|
|
bd7c874e88 |
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project name="Meritoo Common Library" basedir="." default="build:main" phingVersion="2.14.0">
|
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
|
||||||
<!-- Properties -->
|
<!-- Properties -->
|
||||||
<if>
|
<if>
|
||||||
<available file="phing/properties" property="custom.properties.available"/>
|
<available file="phing/properties" property="custom.properties.available"/>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "meritoo/common-library",
|
"name": "meritoo/common-library",
|
||||||
"description": "Useful classes, methods, extensions etc.",
|
"description": "Useful classes, methods, extensions etc.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Meritoo.pl",
|
"name": "Meritoo.pl",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project name="Meritoo Common Library" basedir="." default="build:main" phingVersion="2.14.0">
|
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
|
||||||
<!-- Properties -->
|
<!-- Properties -->
|
||||||
<if>
|
<if>
|
||||||
<available file="phing/properties" property="custom.properties.available"/>
|
<available file="phing/properties" property="custom.properties.available"/>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project name="Meritoo Common Library" basedir="." default="build:main" phingVersion="2.14.0">
|
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
|
||||||
<!--
|
<!--
|
||||||
The AutoloaderTask is required to load binaries installed by Composer.
|
The AutoloaderTask is required to load binaries installed by Composer.
|
||||||
The "autoloaderpath" attribute of this task is not required, because it's default value is: vendor/autoload.php.
|
The "autoloaderpath" attribute of this task is not required, because it's default value is: vendor/autoload.php.
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?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\Exception\Date;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An exception used while given part of date is incorrect, e.g. value of year is incorrect
|
|
||||||
*
|
|
||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
|
||||||
* @copyright Meritoo.pl
|
|
||||||
*/
|
|
||||||
class IncorrectDatePartException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Class constructor
|
|
||||||
*
|
|
||||||
* @param string $value Incorrect value
|
|
||||||
* @param string $datePart Type of date part, e.g. "year". One of \Meritoo\Common\Type\DatePartType class constants.
|
|
||||||
*/
|
|
||||||
public function __construct($value, $datePart)
|
|
||||||
{
|
|
||||||
$message = sprintf('Value of %s \'%s\' is incorrect. Is there everything ok?', $datePart, $value);
|
|
||||||
parent::__construct($message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?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\Exception\Date;
|
||||||
|
|
||||||
|
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
||||||
|
use Meritoo\Common\Type\DatePartType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception used while type of date part, e.g. "year", is unknown
|
||||||
|
*
|
||||||
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
|
* @copyright Meritoo.pl
|
||||||
|
*/
|
||||||
|
class UnknownDatePartTypeException extends UnknownTypeException
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Class constructor
|
||||||
|
*
|
||||||
|
* @param string $unknownDatePart Type of date part, e.g. "year". One of DatePartType class constants.
|
||||||
|
* @param string $value Incorrect value
|
||||||
|
*/
|
||||||
|
public function __construct($unknownDatePart, $value)
|
||||||
|
{
|
||||||
|
parent::__construct($unknownDatePart, new DatePartType(), sprintf('date part (with value %s)', $value));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Meritoo\Common\Exception\Type;
|
||||||
|
|
||||||
|
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
||||||
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception used while the visibility of a property, a method or (as of PHP 7.1.0) a constant is unknown
|
||||||
|
*
|
||||||
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
|
* @copyright Meritoo.pl
|
||||||
|
*/
|
||||||
|
class UnknownOopVisibilityTypeException extends UnknownTypeException
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function __construct($unknownType)
|
||||||
|
{
|
||||||
|
parent::__construct($unknownType, new OopVisibilityType(), 'OOP-related visibility');
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/Meritoo/Common/Type/OopVisibilityType.php
Normal file
37
src/Meritoo/Common/Type/OopVisibilityType.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Meritoo\Common\Type;
|
||||||
|
|
||||||
|
use Meritoo\Common\Type\Base\BaseType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The visibility of a property, a method or (as of PHP 7.1.0) a constant
|
||||||
|
*
|
||||||
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
|
* @copyright Meritoo.pl
|
||||||
|
*
|
||||||
|
* @see http://php.net/manual/en/language.oop5.visibility.php
|
||||||
|
*/
|
||||||
|
class OopVisibilityType extends BaseType
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The "private" visibility of OOP
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
const IS_PRIVATE = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "protected" visibility of OOP
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
const IS_PROTECTED = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "public" visibility of OOP
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
const IS_PUBLIC = 1;
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ namespace Meritoo\Common\Utilities;
|
|||||||
|
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Meritoo\Common\Exception\Date\IncorrectDatePartException;
|
use Meritoo\Common\Exception\Date\UnknownDatePartTypeException;
|
||||||
use Meritoo\Common\Type\DatePartType;
|
use Meritoo\Common\Type\DatePartType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -231,7 +231,7 @@ class Date
|
|||||||
* @param int $day The day value
|
* @param int $day The day value
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
* @throws IncorrectDatePartException
|
* @throws UnknownDatePartTypeException
|
||||||
*/
|
*/
|
||||||
public static function getDayOfWeek($year, $month, $day)
|
public static function getDayOfWeek($year, $month, $day)
|
||||||
{
|
{
|
||||||
@@ -243,21 +243,21 @@ class Date
|
|||||||
* Oops, incorrect year
|
* Oops, incorrect year
|
||||||
*/
|
*/
|
||||||
if ($year <= 0) {
|
if ($year <= 0) {
|
||||||
throw new IncorrectDatePartException($year, DatePartType::YEAR);
|
throw new UnknownDatePartTypeException(DatePartType::YEAR, $year);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Oops, incorrect month
|
* Oops, incorrect month
|
||||||
*/
|
*/
|
||||||
if ($month < 1 || $month > 12) {
|
if ($month < 1 || $month > 12) {
|
||||||
throw new IncorrectDatePartException($month, DatePartType::MONTH);
|
throw new UnknownDatePartTypeException(DatePartType::MONTH, $month);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Oops, incorrect day
|
* Oops, incorrect day
|
||||||
*/
|
*/
|
||||||
if ($day < 1 || $day > 31) {
|
if ($day < 1 || $day > 31) {
|
||||||
throw new IncorrectDatePartException($day, DatePartType::DAY);
|
throw new UnknownDatePartTypeException(DatePartType::DAY, $day);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($month < 3) {
|
if ($month < 3) {
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ namespace Meritoo\Common\Utilities;
|
|||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Generator;
|
use Generator;
|
||||||
|
use Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException;
|
||||||
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
use ReflectionClass;
|
||||||
|
use ReflectionMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case with common methods and data providers
|
* Test case with common methods and data providers
|
||||||
@@ -17,7 +22,7 @@ use Generator;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class TestCase extends \PHPUnit_Framework_TestCase
|
class TestCase extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Provides an empty value
|
* Provides an empty value
|
||||||
@@ -106,4 +111,89 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
return sprintf('%s/../../../../data/tests/%s%s', __DIR__, $fileName, $directoryPath);
|
return sprintf('%s/../../../../data/tests/%s%s', __DIR__, $fileName, $directoryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies visibility and arguments of method
|
||||||
|
*
|
||||||
|
* @param string $classNamespace Namespace of class that contains method to verify
|
||||||
|
* @param string|ReflectionMethod $method Name of method or just the method to verify
|
||||||
|
* @param string $visibilityType Expected visibility of verified method. One of
|
||||||
|
* OopVisibilityType class constants.
|
||||||
|
* @param int $argumentsCount (optional) Expected count/amount of arguments of the
|
||||||
|
* verified method
|
||||||
|
* @param int $requiredArgumentsCount (optional) Expected count/amount of required arguments
|
||||||
|
* of the verified method
|
||||||
|
* @throws UnknownOopVisibilityTypeException
|
||||||
|
*
|
||||||
|
* Attention. 2nd argument, the $method, may be:
|
||||||
|
* - string - name of the method
|
||||||
|
* - instance of ReflectionMethod - just the method (provided by ReflectionClass::getMethod() method)
|
||||||
|
*/
|
||||||
|
protected function verifyMethodVisibilityAndArguments(
|
||||||
|
$classNamespace,
|
||||||
|
$method,
|
||||||
|
$visibilityType,
|
||||||
|
$argumentsCount = 0,
|
||||||
|
$requiredArgumentsCount = 0
|
||||||
|
) {
|
||||||
|
/*
|
||||||
|
* Type of visibility is correct?
|
||||||
|
*/
|
||||||
|
if (!(new OopVisibilityType())->isCorrectType($visibilityType)) {
|
||||||
|
throw new UnknownOopVisibilityTypeException($visibilityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
$reflection = new ReflectionClass($classNamespace);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name of method provided only?
|
||||||
|
* Let's find instance of the method (based on reflection)
|
||||||
|
*/
|
||||||
|
if (!$method instanceof ReflectionMethod) {
|
||||||
|
$method = $reflection->getMethod($method);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($visibilityType) {
|
||||||
|
case OopVisibilityType::IS_PUBLIC:
|
||||||
|
static::assertTrue($method->isPublic());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OopVisibilityType::IS_PROTECTED:
|
||||||
|
static::assertTrue($method->isProtected());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OopVisibilityType::IS_PRIVATE:
|
||||||
|
static::assertTrue($method->isPrivate());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
static::assertEquals($argumentsCount, $method->getNumberOfParameters());
|
||||||
|
static::assertEquals($requiredArgumentsCount, $method->getNumberOfRequiredParameters());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies visibility and arguments of class constructor
|
||||||
|
*
|
||||||
|
* @param string $classNamespace Namespace of class that contains method to verify
|
||||||
|
* @param string $visibilityType Expected visibility of verified method. One of OopVisibilityType class
|
||||||
|
* constants.
|
||||||
|
* @param int $argumentsCount (optional) Expected count/amount of arguments of the verified method
|
||||||
|
* @param int $requiredArgumentsCount (optional) Expected count/amount of required arguments of the verified
|
||||||
|
* method
|
||||||
|
* @throws UnknownOopVisibilityTypeException
|
||||||
|
*/
|
||||||
|
protected function verifyConstructorVisibilityAndArguments(
|
||||||
|
$classNamespace,
|
||||||
|
$visibilityType,
|
||||||
|
$argumentsCount = 0,
|
||||||
|
$requiredArgumentsCount = 0
|
||||||
|
) {
|
||||||
|
/*
|
||||||
|
* Let's grab the constructor
|
||||||
|
*/
|
||||||
|
$reflection = new ReflectionClass($classNamespace);
|
||||||
|
$method = $reflection->getConstructor();
|
||||||
|
|
||||||
|
return $this->verifyMethodVisibilityAndArguments($classNamespace, $method, $visibilityType, $argumentsCount, $requiredArgumentsCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ namespace Meritoo\Common\Tests\Collection;
|
|||||||
|
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Meritoo\Common\Collection\Collection;
|
use Meritoo\Common\Collection\Collection;
|
||||||
use PHPUnit_Framework_TestCase;
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
use ReflectionClass;
|
use Meritoo\Common\Utilities\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the collection of elements
|
* Tests of the collection of elements
|
||||||
@@ -19,7 +19,7 @@ use ReflectionClass;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class CollectionTest extends PHPUnit_Framework_TestCase
|
class CollectionTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* An empty collection
|
* An empty collection
|
||||||
@@ -306,12 +306,7 @@ class CollectionTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testExistsVisibilityAndArguments()
|
public function testExistsVisibilityAndArguments()
|
||||||
{
|
{
|
||||||
$reflection = new ReflectionClass(Collection::class);
|
$this->verifyMethodVisibilityAndArguments(Collection::class, 'exists', OopVisibilityType::IS_PRIVATE, 1, 1);
|
||||||
$method = $reflection->getMethod('exists');
|
|
||||||
|
|
||||||
self::assertTrue($method->isPrivate());
|
|
||||||
self::assertEquals(1, $method->getNumberOfParameters());
|
|
||||||
self::assertEquals(1, $method->getNumberOfRequiredParameters());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace Meritoo\Common\Tests\Exception\Base;
|
|||||||
|
|
||||||
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
||||||
use Meritoo\Common\Type\Base\BaseType;
|
use Meritoo\Common\Type\Base\BaseType;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the exception used while type of something is unknown
|
* Tests of the exception used while type of something is unknown
|
||||||
@@ -17,7 +18,7 @@ use Meritoo\Common\Type\Base\BaseType;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class UnknownTypeExceptionTest extends \PHPUnit_Framework_TestCase
|
class UnknownTypeExceptionTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testWithoutException()
|
public function testWithoutException()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace Meritoo\Common\Tests\Type\Base;
|
|||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Type\Base\BaseType;
|
use Meritoo\Common\Type\Base\BaseType;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the base / abstract type of something
|
* Tests of the base / abstract type of something
|
||||||
@@ -17,7 +18,7 @@ use Meritoo\Common\Type\Base\BaseType;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class BaseTypeTest extends \PHPUnit_Framework_TestCase
|
class BaseTypeTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param BaseType $type Type of something
|
* @param BaseType $type Type of something
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace Meritoo\Common\Tests\Type;
|
|||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Type\DatePartType;
|
use Meritoo\Common\Type\DatePartType;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the type of date part, e.g. "year"
|
* Tests of the type of date part, e.g. "year"
|
||||||
@@ -17,7 +18,7 @@ use Meritoo\Common\Type\DatePartType;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class DatePartTypeTest extends \PHPUnit_Framework_TestCase
|
class DatePartTypeTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testGetAll()
|
public function testGetAll()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Tests\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Utilities\Arrays;
|
use Meritoo\Common\Utilities\Arrays;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the useful arrays methods
|
* Tests of the useful arrays methods
|
||||||
@@ -16,7 +17,7 @@ use Meritoo\Common\Utilities\Arrays;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class ArraysTest extends \PHPUnit_Framework_TestCase
|
class ArraysTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
private $simpleArray;
|
private $simpleArray;
|
||||||
private $simpleArrayWithKeys;
|
private $simpleArrayWithKeys;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Tests\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Utilities\Bundle;
|
use Meritoo\Common\Utilities\Bundle;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the useful methods for bundle
|
* Tests of the useful methods for bundle
|
||||||
@@ -16,7 +17,7 @@ use Meritoo\Common\Utilities\Bundle;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class BundleTest extends \PHPUnit_Framework_TestCase
|
class BundleTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testGetBundleViewPathEmptyPathAndBundle()
|
public function testGetBundleViewPathEmptyPathAndBundle()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ namespace Meritoo\Common\Tests\Utilities;
|
|||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Generator;
|
use Generator;
|
||||||
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
use Meritoo\Common\Utilities\DatePeriod;
|
use Meritoo\Common\Utilities\DatePeriod;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
use Meritoo\Common\Utilities\TestCase;
|
||||||
use ReflectionClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of date's period
|
* Tests of date's period
|
||||||
@@ -24,12 +24,7 @@ class DatePeriodTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testConstructorVisibilityAndArguments()
|
public function testConstructorVisibilityAndArguments()
|
||||||
{
|
{
|
||||||
$reflection = new ReflectionClass(DatePeriod::class);
|
$this->verifyConstructorVisibilityAndArguments(DatePeriod::class, OopVisibilityType::IS_PUBLIC, 2, 0);
|
||||||
$constructor = $reflection->getConstructor();
|
|
||||||
|
|
||||||
self::assertTrue($constructor->isPublic());
|
|
||||||
self::assertEquals(2, $constructor->getNumberOfParameters());
|
|
||||||
self::assertEquals(0, $constructor->getNumberOfRequiredParameters());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Meritoo\Common\Tests\Utilities;
|
|||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Date\IncorrectDatePartException;
|
use Meritoo\Common\Exception\Date\UnknownDatePartTypeException;
|
||||||
use Meritoo\Common\Utilities\Date;
|
use Meritoo\Common\Utilities\Date;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
use Meritoo\Common\Utilities\TestCase;
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ class DateTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetDayOfWeekIncorrectValues($year, $month, $day)
|
public function testGetDayOfWeekIncorrectValues($year, $month, $day)
|
||||||
{
|
{
|
||||||
$this->expectException(IncorrectDatePartException::class);
|
$this->expectException(UnknownDatePartTypeException::class);
|
||||||
self::assertEmpty(Date::getDayOfWeek($year, $month, $day));
|
self::assertEmpty(Date::getDayOfWeek($year, $month, $day));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Tests\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Utilities\Xml;
|
use Meritoo\Common\Utilities\Xml;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
use SimpleXMLElement;
|
use SimpleXMLElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +18,7 @@ use SimpleXMLElement;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class XmlTest extends \PHPUnit_Framework_TestCase
|
class XmlTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
private $simpleXml;
|
private $simpleXml;
|
||||||
private $advancedXml;
|
private $advancedXml;
|
||||||
|
|||||||
Reference in New Issue
Block a user