mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5aa5ff4380 | ||
|
|
6483a8f5b7 | ||
|
|
5c0ef79b15 | ||
|
|
324f64f912 | ||
|
|
5940ebba9a | ||
|
|
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.5",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Meritoo.pl",
|
"name": "Meritoo.pl",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Meritoo\\Common\\": "src/Meritoo/Common/",
|
"Meritoo\\Common\\": "src/Meritoo/Common/",
|
||||||
"Meritoo\\Common\\Tests\\": "tests/Meritoo/Common/Tests/"
|
"Meritoo\\Common\\Test\\": "tests/Meritoo/Common/Test/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
bootstrap="./vendor/autoload.php"
|
bootstrap="./vendor/autoload.php"
|
||||||
>
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Meritoo's Common Library Test Suite">
|
<testsuite name="Meritoo Package - Main Test Suite">
|
||||||
<directory>./tests/</directory>
|
<directory>./tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|||||||
@@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
199
src/Meritoo/Common/Test/Base/BaseTestCase.php
Normal file
199
src/Meritoo/Common/Test/Base/BaseTestCase.php
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
<?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\Test\Base;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use Generator;
|
||||||
|
use Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException;
|
||||||
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
use ReflectionClass;
|
||||||
|
use ReflectionMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base test case with common methods and data providers
|
||||||
|
*
|
||||||
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
|
* @copyright Meritoo.pl
|
||||||
|
*/
|
||||||
|
abstract class BaseTestCase extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Provides an empty value
|
||||||
|
*
|
||||||
|
* @return Generator
|
||||||
|
*/
|
||||||
|
public function provideEmptyValue()
|
||||||
|
{
|
||||||
|
yield[''];
|
||||||
|
yield[' '];
|
||||||
|
yield[null];
|
||||||
|
yield[0];
|
||||||
|
yield[false];
|
||||||
|
yield[[]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides boolean value
|
||||||
|
*
|
||||||
|
* @return Generator
|
||||||
|
*/
|
||||||
|
public function provideBooleanValue()
|
||||||
|
{
|
||||||
|
yield[false];
|
||||||
|
yield[true];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides instance of DateTime class
|
||||||
|
*
|
||||||
|
* @return Generator
|
||||||
|
*/
|
||||||
|
public function provideDateTimeInstance()
|
||||||
|
{
|
||||||
|
yield[new DateTime()];
|
||||||
|
yield[new DateTime('yesterday')];
|
||||||
|
yield[new DateTime('now')];
|
||||||
|
yield[new DateTime('tomorrow')];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides relative / compound format of DateTime
|
||||||
|
*
|
||||||
|
* @return Generator
|
||||||
|
*/
|
||||||
|
public function provideDateTimeRelativeFormat()
|
||||||
|
{
|
||||||
|
yield['now'];
|
||||||
|
yield['yesterday'];
|
||||||
|
yield['tomorrow'];
|
||||||
|
yield['back of 10'];
|
||||||
|
yield['front of 10'];
|
||||||
|
yield['last day of February'];
|
||||||
|
yield['first day of next month'];
|
||||||
|
yield['last day of previous month'];
|
||||||
|
yield['last day of next month'];
|
||||||
|
yield['Y-m-d'];
|
||||||
|
yield['Y-m-d 10:00'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides path of not existing file, e.g. "lorem/ipsum.jpg"
|
||||||
|
*
|
||||||
|
* @return Generator
|
||||||
|
*/
|
||||||
|
public function provideNotExistingFilePath()
|
||||||
|
{
|
||||||
|
yield['lets-test.doc'];
|
||||||
|
yield['lorem/ipsum.jpg'];
|
||||||
|
yield['surprise/me/one/more/time.txt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns path of file used by tests.
|
||||||
|
* It should be placed in /data/tests directory of this project.
|
||||||
|
*
|
||||||
|
* @param string $fileName Name of file
|
||||||
|
* @param string $directoryPath (optional) Path of directory containing the file
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFilePathToTests($fileName, $directoryPath = '')
|
||||||
|
{
|
||||||
|
if (!empty($directoryPath)) {
|
||||||
|
$directoryPath = '/' . $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);
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/Meritoo/Common/Test/Base/BaseTypeTestCase.php
Normal file
60
src/Meritoo/Common/Test/Base/BaseTypeTestCase.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Meritoo\Common\Test\Base;
|
||||||
|
|
||||||
|
use Generator;
|
||||||
|
use Meritoo\Common\Type\Base\BaseType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base test case for the type of something
|
||||||
|
*
|
||||||
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
|
* @copyright Meritoo.pl
|
||||||
|
*/
|
||||||
|
abstract class BaseTypeTestCase extends BaseTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Verifies availability of all types
|
||||||
|
*/
|
||||||
|
public function testAvailabilityOfAllTypes()
|
||||||
|
{
|
||||||
|
$available = $this->getTestedTypeInstance()->getAll();
|
||||||
|
$all = $this->getAllExpectedTypes();
|
||||||
|
|
||||||
|
static::assertEquals($all, $available);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies whether given type is correct or not
|
||||||
|
*
|
||||||
|
* @param string $type Type to verify
|
||||||
|
* @param bool $expected Information if given type is correct or not
|
||||||
|
*
|
||||||
|
* @dataProvider provideTypeToVerify
|
||||||
|
*/
|
||||||
|
public function testIfGivenTypeIsCorrect($type, $expected)
|
||||||
|
{
|
||||||
|
static::assertEquals($expected, $this->getTestedTypeInstance()->isCorrectType($type));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides type to verify and information if it's correct
|
||||||
|
*
|
||||||
|
* @return Generator
|
||||||
|
*/
|
||||||
|
abstract public function provideTypeToVerify();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns instance of the tested type
|
||||||
|
*
|
||||||
|
* @return BaseType
|
||||||
|
*/
|
||||||
|
abstract protected function getTestedTypeInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all expected types of the tested type
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
abstract protected function getAllExpectedTypes();
|
||||||
|
}
|
||||||
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) {
|
||||||
|
|||||||
@@ -1,109 +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\Utilities;
|
|
||||||
|
|
||||||
use DateTime;
|
|
||||||
use Generator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test case with common methods and data providers
|
|
||||||
*
|
|
||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
|
||||||
* @copyright Meritoo.pl
|
|
||||||
*/
|
|
||||||
class TestCase extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Provides an empty value
|
|
||||||
*
|
|
||||||
* @return Generator
|
|
||||||
*/
|
|
||||||
public function provideEmptyValue()
|
|
||||||
{
|
|
||||||
yield[''];
|
|
||||||
yield[' '];
|
|
||||||
yield[null];
|
|
||||||
yield[0];
|
|
||||||
yield[false];
|
|
||||||
yield[[]];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides boolean value
|
|
||||||
*
|
|
||||||
* @return Generator
|
|
||||||
*/
|
|
||||||
public function provideBooleanValue()
|
|
||||||
{
|
|
||||||
yield[false];
|
|
||||||
yield[true];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides instance of DateTime class
|
|
||||||
*
|
|
||||||
* @return Generator
|
|
||||||
*/
|
|
||||||
public function provideDateTimeInstance()
|
|
||||||
{
|
|
||||||
yield[new DateTime()];
|
|
||||||
yield[new DateTime('yesterday')];
|
|
||||||
yield[new DateTime('now')];
|
|
||||||
yield[new DateTime('tomorrow')];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides relative / compound format of DateTime
|
|
||||||
*
|
|
||||||
* @return Generator
|
|
||||||
*/
|
|
||||||
public function provideDateTimeRelativeFormat()
|
|
||||||
{
|
|
||||||
yield['now'];
|
|
||||||
yield['yesterday'];
|
|
||||||
yield['tomorrow'];
|
|
||||||
yield['back of 10'];
|
|
||||||
yield['front of 10'];
|
|
||||||
yield['last day of February'];
|
|
||||||
yield['first day of next month'];
|
|
||||||
yield['last day of previous month'];
|
|
||||||
yield['last day of next month'];
|
|
||||||
yield['Y-m-d'];
|
|
||||||
yield['Y-m-d 10:00'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides path of not existing file, e.g. "lorem/ipsum.jpg"
|
|
||||||
*
|
|
||||||
* @return Generator
|
|
||||||
*/
|
|
||||||
public function provideNotExistingFilePath()
|
|
||||||
{
|
|
||||||
yield['lets-test.doc'];
|
|
||||||
yield['lorem/ipsum.jpg'];
|
|
||||||
yield['suprise/me/one/more/time.txt'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns path of file used by tests.
|
|
||||||
* It should be placed in /data/tests directory of this project.
|
|
||||||
*
|
|
||||||
* @param string $fileName Name of file
|
|
||||||
* @param string $directoryPath (optional) Path of directory containing the file
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getFilePathToTests($fileName, $directoryPath = '')
|
|
||||||
{
|
|
||||||
if (!empty($directoryPath)) {
|
|
||||||
$directoryPath = '/' . $directoryPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf('%s/../../../../data/tests/%s%s', __DIR__, $fileName, $directoryPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,12 +6,12 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Collection;
|
namespace Meritoo\Common\Test\Collection;
|
||||||
|
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Meritoo\Common\Collection\Collection;
|
use Meritoo\Common\Collection\Collection;
|
||||||
use PHPUnit_Framework_TestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use ReflectionClass;
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6,10 +6,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Exception\Base;
|
namespace Meritoo\Common\Test\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()
|
||||||
{
|
{
|
||||||
@@ -6,10 +6,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Type\Base;
|
namespace Meritoo\Common\Test\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
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Type;
|
namespace Meritoo\Common\Test\Type;
|
||||||
|
|
||||||
use Generator;
|
use Meritoo\Common\Test\Base\BaseTypeTestCase;
|
||||||
use Meritoo\Common\Type\DatePartType;
|
use Meritoo\Common\Type\DatePartType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,11 +17,14 @@ 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 BaseTypeTestCase
|
||||||
{
|
{
|
||||||
public function testGetAll()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function getAllExpectedTypes()
|
||||||
{
|
{
|
||||||
$expectedTypes = [
|
return [
|
||||||
'DAY' => DatePartType::DAY,
|
'DAY' => DatePartType::DAY,
|
||||||
'HOUR' => DatePartType::HOUR,
|
'HOUR' => DatePartType::HOUR,
|
||||||
'MINUTE' => DatePartType::MINUTE,
|
'MINUTE' => DatePartType::MINUTE,
|
||||||
@@ -29,29 +32,20 @@ class DatePartTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
'SECOND' => DatePartType::SECOND,
|
'SECOND' => DatePartType::SECOND,
|
||||||
'YEAR' => DatePartType::YEAR,
|
'YEAR' => DatePartType::YEAR,
|
||||||
];
|
];
|
||||||
|
|
||||||
$all = (new DatePartType())->getAll();
|
|
||||||
self::assertEquals($expectedTypes, $all);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $toVerifyType Concrete type to verify (of given instance of type)
|
* {@inheritdoc}
|
||||||
* @param bool $isCorrect Expected information if given type is correct
|
|
||||||
*
|
|
||||||
* @dataProvider provideConcreteType
|
|
||||||
*/
|
*/
|
||||||
public function testIsCorrectType($toVerifyType, $isCorrect)
|
protected function getTestedTypeInstance()
|
||||||
{
|
{
|
||||||
$type = new DatePartType();
|
return new DatePartType();
|
||||||
self::assertEquals($isCorrect, $type->isCorrectType($toVerifyType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides type of something for testing the isCorrectType() method
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return Generator
|
|
||||||
*/
|
*/
|
||||||
public function provideConcreteType()
|
public function provideTypeToVerify()
|
||||||
{
|
{
|
||||||
yield[
|
yield[
|
||||||
'',
|
'',
|
||||||
@@ -6,9 +6,10 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\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;
|
||||||
@@ -6,9 +6,10 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\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()
|
||||||
{
|
{
|
||||||
@@ -6,10 +6,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
|
use Generator;
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\Composer;
|
use Meritoo\Common\Utilities\Composer;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the useful Composer-related methods
|
* Tests of the useful Composer-related methods
|
||||||
@@ -17,7 +18,7 @@ use Meritoo\Common\Utilities\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class ComposerTest extends TestCase
|
class ComposerTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Path of existing composer.json used as source of data for tests
|
* Path of existing composer.json used as source of data for tests
|
||||||
@@ -60,7 +61,7 @@ class ComposerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Provides names and values of existing nodes
|
* Provides names and values of existing nodes
|
||||||
*
|
*
|
||||||
* @return \Generator
|
* @return Generator
|
||||||
*/
|
*/
|
||||||
public function getExistingNode()
|
public function getExistingNode()
|
||||||
{
|
{
|
||||||
@@ -6,13 +6,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Generator;
|
use Generator;
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
use Meritoo\Common\Type\OopVisibilityType;
|
||||||
use Meritoo\Common\Utilities\DatePeriod;
|
use Meritoo\Common\Utilities\DatePeriod;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
|
||||||
use ReflectionClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of date's period
|
* Tests of date's period
|
||||||
@@ -20,16 +20,11 @@ use ReflectionClass;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class DatePeriodTest extends TestCase
|
class DatePeriodTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6,14 +6,14 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\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\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\Date;
|
use Meritoo\Common\Utilities\Date;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the Date methods (only static functions)
|
* Tests of the Date methods (only static functions)
|
||||||
@@ -21,7 +21,7 @@ use Meritoo\Common\Utilities\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class DateTest extends TestCase
|
class DateTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param mixed $value Empty value, e.g. ""
|
* @param mixed $value Empty value, e.g. ""
|
||||||
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,10 +6,10 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\GeneratorUtility;
|
use Meritoo\Common\Utilities\GeneratorUtility;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the useful methods for the Generator class
|
* Tests of the useful methods for the Generator class
|
||||||
@@ -17,7 +17,7 @@ use Meritoo\Common\Utilities\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class GeneratorUtilityTest extends TestCase
|
class GeneratorUtilityTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
public function testGetGeneratorElements()
|
public function testGetGeneratorElements()
|
||||||
{
|
{
|
||||||
@@ -6,11 +6,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\Locale;
|
use Meritoo\Common\Utilities\Locale;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the useful locale methods
|
* Tests of the useful locale methods
|
||||||
@@ -18,7 +18,7 @@ use Meritoo\Common\Utilities\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class LocaleTest extends TestCase
|
class LocaleTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param mixed $languageCode Empty value, e.g. ""
|
* @param mixed $languageCode Empty value, e.g. ""
|
||||||
@@ -6,11 +6,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\MimeTypes;
|
use Meritoo\Common\Utilities\MimeTypes;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the useful methods for mime types of files
|
* Tests of the useful methods for mime types of files
|
||||||
@@ -18,7 +18,7 @@ use Meritoo\Common\Utilities\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class MimeTypesTest extends TestCase
|
class MimeTypesTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param mixed $mimeType Empty value, e.g. ""
|
* @param mixed $mimeType Empty value, e.g. ""
|
||||||
@@ -6,14 +6,14 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;
|
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;
|
||||||
use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
|
use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
|
||||||
|
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 Meritoo\Common\Utilities\TestCase;
|
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,7 +22,7 @@ use stdClass;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class MiscellaneousTest extends TestCase
|
class MiscellaneousTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
private $stringSmall;
|
private $stringSmall;
|
||||||
private $stringCommaSeparated;
|
private $stringCommaSeparated;
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities\Reflection;
|
namespace Meritoo\Common\Test\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\Tests\Utilities\Reflection;
|
namespace Meritoo\Common\Test\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\Tests\Utilities\Reflection;
|
namespace Meritoo\Common\Test\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\Tests\Utilities\Reflection;
|
namespace Meritoo\Common\Test\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\Tests\Utilities\Reflection;
|
namespace Meritoo\Common\Test\Utilities\Reflection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The E trait.
|
* The E trait.
|
||||||
@@ -6,20 +6,20 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Generator;
|
use Generator;
|
||||||
use Meritoo\Common\Exception\Reflection\CannotResolveClassNameException;
|
use Meritoo\Common\Exception\Reflection\CannotResolveClassNameException;
|
||||||
use Meritoo\Common\Exception\Reflection\MissingChildClassesException;
|
use Meritoo\Common\Exception\Reflection\MissingChildClassesException;
|
||||||
use Meritoo\Common\Exception\Reflection\TooManyChildClassesException;
|
use Meritoo\Common\Exception\Reflection\TooManyChildClassesException;
|
||||||
use Meritoo\Common\Tests\Utilities\Reflection\A;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Tests\Utilities\Reflection\B;
|
use Meritoo\Common\Test\Utilities\Reflection\A;
|
||||||
use Meritoo\Common\Tests\Utilities\Reflection\C;
|
use Meritoo\Common\Test\Utilities\Reflection\B;
|
||||||
use Meritoo\Common\Tests\Utilities\Reflection\D;
|
use Meritoo\Common\Test\Utilities\Reflection\C;
|
||||||
use Meritoo\Common\Tests\Utilities\Reflection\E;
|
use Meritoo\Common\Test\Utilities\Reflection\D;
|
||||||
|
use Meritoo\Common\Test\Utilities\Reflection\E;
|
||||||
use Meritoo\Common\Utilities\Reflection;
|
use Meritoo\Common\Utilities\Reflection;
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the useful reflection methods
|
* Tests of the useful reflection methods
|
||||||
@@ -27,7 +27,7 @@ use Meritoo\Common\Utilities\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class ReflectionTest extends TestCase
|
class ReflectionTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param mixed $invalidClass Empty value, e.g. ""
|
* @param mixed $invalidClass Empty value, e.g. ""
|
||||||
@@ -88,7 +88,7 @@ class ReflectionTest extends TestCase
|
|||||||
/*
|
/*
|
||||||
* Existing class
|
* Existing class
|
||||||
*/
|
*/
|
||||||
self::assertEquals('Meritoo\Common\Tests\Utilities', Reflection::getClassNamespace(self::class));
|
self::assertEquals('Meritoo\Common\Test\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([
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
use Meritoo\Common\Utilities\TestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\Uri;
|
use Meritoo\Common\Utilities\Uri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +17,7 @@ use Meritoo\Common\Utilities\Uri;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class UriTest extends TestCase
|
class UriTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
public function testAddProtocolToUrl()
|
public function testAddProtocolToUrl()
|
||||||
{
|
{
|
||||||
@@ -6,9 +6,10 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Meritoo\Common\Tests\Utilities;
|
namespace Meritoo\Common\Test\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