mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0d28b326e | ||
|
|
318a635ffd |
@@ -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.10",
|
"version": "0.0.11",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Meritoo.pl",
|
"name": "Meritoo.pl",
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ abstract class BaseTestCase extends TestCase
|
|||||||
* - string - name of the method
|
* - string - name of the method
|
||||||
* - instance of ReflectionMethod - just the method (provided by ReflectionClass::getMethod() method)
|
* - instance of ReflectionMethod - just the method (provided by ReflectionClass::getMethod() method)
|
||||||
*/
|
*/
|
||||||
protected function verifyMethodVisibilityAndArguments(
|
protected static function assertMethodVisibilityAndArguments(
|
||||||
$classNamespace,
|
$classNamespace,
|
||||||
$method,
|
$method,
|
||||||
$visibilityType,
|
$visibilityType,
|
||||||
@@ -180,7 +180,7 @@ abstract class BaseTestCase extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Verifies visibility and arguments of class constructor
|
* Verifies visibility and arguments of class constructor
|
||||||
*
|
*
|
||||||
* @param string $classNamespace Namespace of class that contains method to verify
|
* @param string $classNamespace Namespace of class that contains constructor to verify
|
||||||
* @param string $visibilityType Expected visibility of verified method. One of OopVisibilityType class
|
* @param string $visibilityType Expected visibility of verified method. One of OopVisibilityType class
|
||||||
* constants.
|
* constants.
|
||||||
* @param int $argumentsCount (optional) Expected count/amount of arguments of the verified method
|
* @param int $argumentsCount (optional) Expected count/amount of arguments of the verified method
|
||||||
@@ -188,7 +188,7 @@ abstract class BaseTestCase extends TestCase
|
|||||||
* method
|
* method
|
||||||
* @throws UnknownOopVisibilityTypeException
|
* @throws UnknownOopVisibilityTypeException
|
||||||
*/
|
*/
|
||||||
protected function verifyConstructorVisibilityAndArguments(
|
protected static function assertConstructorVisibilityAndArguments(
|
||||||
$classNamespace,
|
$classNamespace,
|
||||||
$visibilityType,
|
$visibilityType,
|
||||||
$argumentsCount = 0,
|
$argumentsCount = 0,
|
||||||
@@ -200,6 +200,22 @@ abstract class BaseTestCase extends TestCase
|
|||||||
$reflection = new ReflectionClass($classNamespace);
|
$reflection = new ReflectionClass($classNamespace);
|
||||||
$method = $reflection->getConstructor();
|
$method = $reflection->getConstructor();
|
||||||
|
|
||||||
return $this->verifyMethodVisibilityAndArguments($classNamespace, $method, $visibilityType, $argumentsCount, $requiredArgumentsCount);
|
return static::assertMethodVisibilityAndArguments($classNamespace, $method, $visibilityType, $argumentsCount, $requiredArgumentsCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that class with given namespace has no constructor
|
||||||
|
*
|
||||||
|
* @param string $classNamespace Namespace of class that contains constructor to verify
|
||||||
|
*/
|
||||||
|
protected static function assertHasNoConstructor($classNamespace)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Let's grab the constructor
|
||||||
|
*/
|
||||||
|
$reflection = new ReflectionClass($classNamespace);
|
||||||
|
$constructor = $reflection->getConstructor();
|
||||||
|
|
||||||
|
static::assertNull($constructor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ class CollectionTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testExistsVisibilityAndArguments()
|
public function testExistsVisibilityAndArguments()
|
||||||
{
|
{
|
||||||
$this->verifyMethodVisibilityAndArguments(Collection::class, 'exists', OopVisibilityType::IS_PRIVATE, 1, 1);
|
static::assertMethodVisibilityAndArguments(Collection::class, 'exists', OopVisibilityType::IS_PRIVATE, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
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
|
||||||
@@ -17,7 +17,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class ArraysTest extends TestCase
|
class ArraysTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
private $simpleArray;
|
private $simpleArray;
|
||||||
private $simpleArrayWithKeys;
|
private $simpleArrayWithKeys;
|
||||||
@@ -25,6 +25,11 @@ class ArraysTest extends TestCase
|
|||||||
private $complexArray;
|
private $complexArray;
|
||||||
private $superComplexArray;
|
private $superComplexArray;
|
||||||
|
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Arrays::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testValues2string()
|
public function testValues2string()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
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
|
||||||
@@ -17,8 +17,13 @@ use PHPUnit\Framework\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class BundleTest extends TestCase
|
class BundleTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Bundle::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetBundleViewPathEmptyPathAndBundle()
|
public function testGetBundleViewPathEmptyPathAndBundle()
|
||||||
{
|
{
|
||||||
self::assertNull(Bundle::getBundleViewPath('', ''));
|
self::assertNull(Bundle::getBundleViewPath('', ''));
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ class ComposerTest extends BaseTestCase
|
|||||||
*/
|
*/
|
||||||
private $composerJsonPath;
|
private $composerJsonPath;
|
||||||
|
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Composer::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $composerJsonPath Empty value, e.g. ""
|
* @param string $composerJsonPath Empty value, e.g. ""
|
||||||
* @dataProvider provideEmptyValue
|
* @dataProvider provideEmptyValue
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class DatePeriodTest extends BaseTestCase
|
|||||||
{
|
{
|
||||||
public function testConstructorVisibilityAndArguments()
|
public function testConstructorVisibilityAndArguments()
|
||||||
{
|
{
|
||||||
$this->verifyConstructorVisibilityAndArguments(DatePeriod::class, OopVisibilityType::IS_PUBLIC, 2, 0);
|
static::assertConstructorVisibilityAndArguments(DatePeriod::class, OopVisibilityType::IS_PUBLIC, 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ use Meritoo\Common\Utilities\Date;
|
|||||||
*/
|
*/
|
||||||
class DateTest extends BaseTestCase
|
class DateTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Date::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $value Empty value, e.g. ""
|
* @param mixed $value Empty value, e.g. ""
|
||||||
* @dataProvider provideEmptyValue
|
* @dataProvider provideEmptyValue
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ use Meritoo\Common\Utilities\GeneratorUtility;
|
|||||||
*/
|
*/
|
||||||
class GeneratorUtilityTest extends BaseTestCase
|
class GeneratorUtilityTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(GeneratorUtility::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetGeneratorElements()
|
public function testGetGeneratorElements()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ use Meritoo\Common\Utilities\Locale;
|
|||||||
*/
|
*/
|
||||||
class LocaleTest extends BaseTestCase
|
class LocaleTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Locale::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $languageCode Empty value, e.g. ""
|
* @param mixed $languageCode Empty value, e.g. ""
|
||||||
* @dataProvider provideEmptyValue
|
* @dataProvider provideEmptyValue
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ use Meritoo\Common\Utilities\MimeTypes;
|
|||||||
*/
|
*/
|
||||||
class MimeTypesTest extends BaseTestCase
|
class MimeTypesTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(MimeTypes::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $mimeType Empty value, e.g. ""
|
* @param mixed $mimeType Empty value, e.g. ""
|
||||||
* @dataProvider provideEmptyValue
|
* @dataProvider provideEmptyValue
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
private $stringCommaSeparated;
|
private $stringCommaSeparated;
|
||||||
private $stringDotSeparated;
|
private $stringDotSeparated;
|
||||||
|
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Miscellaneous::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetDirectoryContent()
|
public function testGetDirectoryContent()
|
||||||
{
|
{
|
||||||
$directoryPath = __DIR__ . '/../';
|
$directoryPath = __DIR__ . '/../';
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ use Meritoo\Common\Utilities\Reflection;
|
|||||||
*/
|
*/
|
||||||
class ReflectionTest extends BaseTestCase
|
class ReflectionTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Reflection::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $invalidClass Empty value, e.g. ""
|
* @param mixed $invalidClass Empty value, e.g. ""
|
||||||
* @dataProvider provideEmptyValue
|
* @dataProvider provideEmptyValue
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace Meritoo\Common\Utilities;
|
namespace Meritoo\Common\Utilities;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the useful regular expressions methods
|
* Tests of the useful regular expressions methods
|
||||||
@@ -16,11 +16,16 @@ use PHPUnit\Framework\TestCase;
|
|||||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||||
* @copyright Meritoo.pl
|
* @copyright Meritoo.pl
|
||||||
*/
|
*/
|
||||||
class RegexTest extends TestCase
|
class RegexTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
private $simpleText;
|
private $simpleText;
|
||||||
private $camelCaseText;
|
private $camelCaseText;
|
||||||
|
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Regex::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetCamelCaseParts()
|
public function testGetCamelCaseParts()
|
||||||
{
|
{
|
||||||
$parts = [];
|
$parts = [];
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ use Meritoo\Common\Utilities\Uri;
|
|||||||
*/
|
*/
|
||||||
class UriTest extends BaseTestCase
|
class UriTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Uri::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAddProtocolToUrl()
|
public function testAddProtocolToUrl()
|
||||||
{
|
{
|
||||||
$http = 'http';
|
$http = 'http';
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
namespace Meritoo\Common\Test\Utilities;
|
namespace Meritoo\Common\Test\Utilities;
|
||||||
|
|
||||||
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||||
use Meritoo\Common\Utilities\Xml;
|
use Meritoo\Common\Utilities\Xml;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use SimpleXMLElement;
|
use SimpleXMLElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,11 +18,16 @@ 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 TestCase
|
class XmlTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
private $simpleXml;
|
private $simpleXml;
|
||||||
private $advancedXml;
|
private $advancedXml;
|
||||||
|
|
||||||
|
public function verifyConstructor()
|
||||||
|
{
|
||||||
|
static::assertHasNoConstructor(Xml::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testMergeNodes()
|
public function testMergeNodes()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user