mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Do not require name of class by BaseTestCaseTrait::assertMethodVisibilityAndArguments() method
This commit is contained in:
@@ -7,6 +7,7 @@ Common and useful classes, methods, exceptions etc.
|
|||||||
1. Use `.env` instead of `.env.dist`
|
1. Use `.env` instead of `.env.dist`
|
||||||
2. Docker > use images (instead of Dockerfiles)
|
2. Docker > use images (instead of Dockerfiles)
|
||||||
3. composer > squizlabs/php_codesniffer package > use ^3.4 (instead of ^2.9)
|
3. composer > squizlabs/php_codesniffer package > use ^3.4 (instead of ^2.9)
|
||||||
|
4. Do not require name of class by BaseTestCaseTrait::assertMethodVisibilityAndArguments() method
|
||||||
|
|
||||||
# 1.0.5
|
# 1.0.5
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ trait BaseTestCaseTrait
|
|||||||
/**
|
/**
|
||||||
* Verifies visibility and arguments of method
|
* Verifies visibility and arguments of method
|
||||||
*
|
*
|
||||||
* @param string $className Fully-qualified name of class that contains method to verify
|
|
||||||
* @param ReflectionMethod $method Name of method or just the method to verify
|
* @param ReflectionMethod $method Name of method or just the method to verify
|
||||||
* @param string $visibilityType Expected visibility of verified method. One of OopVisibilityType
|
* @param string $visibilityType Expected visibility of verified method. One of OopVisibilityType
|
||||||
* class constants.
|
* class constants.
|
||||||
@@ -180,7 +179,6 @@ trait BaseTestCaseTrait
|
|||||||
* - instance of ReflectionMethod - just the method (provided by ReflectionClass::getMethod() method)
|
* - instance of ReflectionMethod - just the method (provided by ReflectionClass::getMethod() method)
|
||||||
*/
|
*/
|
||||||
protected static function assertMethodVisibilityAndArguments(
|
protected static function assertMethodVisibilityAndArguments(
|
||||||
string $className,
|
|
||||||
ReflectionMethod $method,
|
ReflectionMethod $method,
|
||||||
string $visibilityType,
|
string $visibilityType,
|
||||||
int $argumentsCount = 0,
|
int $argumentsCount = 0,
|
||||||
@@ -191,14 +189,6 @@ trait BaseTestCaseTrait
|
|||||||
throw UnknownOopVisibilityTypeException::createException($visibilityType);
|
throw UnknownOopVisibilityTypeException::createException($visibilityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
$reflection = new ReflectionClass($className);
|
|
||||||
|
|
||||||
// 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) {
|
switch ($visibilityType) {
|
||||||
case OopVisibilityType::IS_PUBLIC:
|
case OopVisibilityType::IS_PUBLIC:
|
||||||
static::assertTrue($method->isPublic());
|
static::assertTrue($method->isPublic());
|
||||||
@@ -243,7 +233,6 @@ trait BaseTestCaseTrait
|
|||||||
}
|
}
|
||||||
|
|
||||||
static::assertMethodVisibilityAndArguments(
|
static::assertMethodVisibilityAndArguments(
|
||||||
$className,
|
|
||||||
$method,
|
$method,
|
||||||
$visibilityType,
|
$visibilityType,
|
||||||
$argumentsCount,
|
$argumentsCount,
|
||||||
|
|||||||
@@ -332,7 +332,6 @@ class CollectionTest extends BaseTestCase
|
|||||||
$method = $reflectionClass->getMethod('exists');
|
$method = $reflectionClass->getMethod('exists');
|
||||||
|
|
||||||
static::assertMethodVisibilityAndArguments(
|
static::assertMethodVisibilityAndArguments(
|
||||||
Collection::class,
|
|
||||||
$method,
|
$method,
|
||||||
OopVisibilityType::IS_PRIVATE,
|
OopVisibilityType::IS_PRIVATE,
|
||||||
1,
|
1,
|
||||||
|
|||||||
Reference in New Issue
Block a user