use testing tools
This commit is contained in:
parent
f5afd4617f
commit
8345a843c3
@ -26,6 +26,7 @@
|
|||||||
"beberlei/assert": "^3.3"
|
"beberlei/assert": "^3.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"d3/testingtools": "^1.0",
|
||||||
"phpunit/phpunit": "^9.6"
|
"phpunit/phpunit": "^9.6"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -15,16 +15,19 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace D3\DIContainerHandler\tests\autoload;
|
namespace D3\DIContainerHandler\tests\autoload;
|
||||||
|
|
||||||
|
use D3\TestingTools\Development\CanAccessRestricted;
|
||||||
|
use Exception;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use ReflectionClass;
|
|
||||||
use ReflectionException;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
class functions_oxDICTest extends TestCase
|
class functions_oxDICTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use CanAccessRestricted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function d3GetOxidDICTest(): void
|
public function d3GetOxidDICTest(): void
|
||||||
{
|
{
|
||||||
@ -33,92 +36,4 @@ class functions_oxDICTest extends TestCase
|
|||||||
d3GetOxidDIC()
|
d3GetOxidDIC()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls a private or protected object method.
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $methodName
|
|
||||||
* @param array $arguments
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function callMethod($object, $methodName, array $arguments = [])
|
|
||||||
{
|
|
||||||
$class = new ReflectionClass($object);
|
|
||||||
$method = $class->getMethod($methodName);
|
|
||||||
$method->setAccessible(true);
|
|
||||||
return $method->invokeArgs($object, $arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a private or protected property in defined class instance
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function setValue($object, $valueName, $value)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$property->setValue($object, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a private or protected property in mocked class instance based on original class
|
|
||||||
* (required for e.g. final properties, which aren't contained in mock, but in original class)
|
|
||||||
* @param $mockedClassName * FQNS of original class
|
|
||||||
* @param $object * mock object
|
|
||||||
* @param $valueName * property name
|
|
||||||
* @param $value * new property value
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function setMockedClassValue($mockedClassName, $object, $valueName, $value)
|
|
||||||
{
|
|
||||||
$property = new \ReflectionProperty($mockedClassName, $valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$property->setValue($object, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a private or protected property from defined class instance
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function getValue($object, $valueName)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a private or protected property from mocked class instance based on original class
|
|
||||||
* (required for e.g. final properties, which aren't contained in mock, but in original class)
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function getMockedClassValue($mockedClassName, $object, $valueName)
|
|
||||||
{
|
|
||||||
$property = new \ReflectionProperty($mockedClassName, $valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -16,12 +16,12 @@ declare(strict_types=1);
|
|||||||
namespace D3\DIContainerHandler\tests;
|
namespace D3\DIContainerHandler\tests;
|
||||||
|
|
||||||
use D3\DIContainerHandler\d3DicHandler;
|
use D3\DIContainerHandler\d3DicHandler;
|
||||||
|
use D3\TestingTools\Development\CanAccessRestricted;
|
||||||
use d3DIContainerCache;
|
use d3DIContainerCache;
|
||||||
use Generator;
|
use Generator;
|
||||||
use OxidEsales\Eshop\Core\Config;
|
use OxidEsales\Eshop\Core\Config;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use ReflectionClass;
|
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||||
@ -30,6 +30,8 @@ define('D3_MODCFG_TEST', true);
|
|||||||
|
|
||||||
class d3DicHandlerTest extends TestCase
|
class d3DicHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use CanAccessRestricted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @return void
|
* @return void
|
||||||
@ -368,92 +370,4 @@ class d3DicHandlerTest extends TestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls a private or protected object method.
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $methodName
|
|
||||||
* @param array $arguments
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function callMethod($object, $methodName, array $arguments = [])
|
|
||||||
{
|
|
||||||
$class = new ReflectionClass($object);
|
|
||||||
$method = $class->getMethod($methodName);
|
|
||||||
$method->setAccessible(true);
|
|
||||||
return $method->invokeArgs($object, $arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a private or protected property in defined class instance
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function setValue($object, $valueName, $value)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$property->setValue($object, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a private or protected property in mocked class instance based on original class
|
|
||||||
* (required for e.g. final properties, which aren't contained in mock, but in original class)
|
|
||||||
* @param $mockedClassName * FQNS of original class
|
|
||||||
* @param $object * mock object
|
|
||||||
* @param $valueName * property name
|
|
||||||
* @param $value * new property value
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function setMockedClassValue($mockedClassName, $object, $valueName, $value)
|
|
||||||
{
|
|
||||||
$property = new \ReflectionProperty($mockedClassName, $valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$property->setValue($object, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a private or protected property from defined class instance
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function getValue($object, $valueName)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a private or protected property from mocked class instance based on original class
|
|
||||||
* (required for e.g. final properties, which aren't contained in mock, but in original class)
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function getMockedClassValue($mockedClassName, $object, $valueName)
|
|
||||||
{
|
|
||||||
$property = new \ReflectionProperty($mockedClassName, $valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -17,13 +17,15 @@ namespace D3\DIContainerHandler\tests;
|
|||||||
|
|
||||||
use D3\DIContainerHandler\d3DicHandler;
|
use D3\DIContainerHandler\d3DicHandler;
|
||||||
use D3\DIContainerHandler\d3DicUtilities;
|
use D3\DIContainerHandler\d3DicUtilities;
|
||||||
|
use D3\TestingTools\Development\CanAccessRestricted;
|
||||||
use Generator;
|
use Generator;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use ReflectionClass;
|
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
class d3DicUtilitiesTest extends TestCase
|
class d3DicUtilitiesTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use CanAccessRestricted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @param string $className
|
* @param string $className
|
||||||
@ -103,92 +105,4 @@ class d3DicUtilitiesTest extends TestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls a private or protected object method.
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $methodName
|
|
||||||
* @param array $arguments
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function callMethod($object, $methodName, array $arguments = [])
|
|
||||||
{
|
|
||||||
$class = new ReflectionClass($object);
|
|
||||||
$method = $class->getMethod($methodName);
|
|
||||||
$method->setAccessible(true);
|
|
||||||
return $method->invokeArgs($object, $arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a private or protected property in defined class instance
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function setValue($object, $valueName, $value)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$property->setValue($object, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a private or protected property in mocked class instance based on original class
|
|
||||||
* (required for e.g. final properties, which aren't contained in mock, but in original class)
|
|
||||||
* @param $mockedClassName * FQNS of original class
|
|
||||||
* @param $object * mock object
|
|
||||||
* @param $valueName * property name
|
|
||||||
* @param $value * new property value
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function setMockedClassValue($mockedClassName, $object, $valueName, $value)
|
|
||||||
{
|
|
||||||
$property = new \ReflectionProperty($mockedClassName, $valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$property->setValue($object, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a private or protected property from defined class instance
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function getValue($object, $valueName)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a private or protected property from mocked class instance based on original class
|
|
||||||
* (required for e.g. final properties, which aren't contained in mock, but in original class)
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function getMockedClassValue($mockedClassName, $object, $valueName)
|
|
||||||
{
|
|
||||||
$property = new \ReflectionProperty($mockedClassName, $valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -17,13 +17,15 @@ namespace D3\DIContainerHandler\tests;
|
|||||||
|
|
||||||
use Assert\InvalidArgumentException;
|
use Assert\InvalidArgumentException;
|
||||||
use D3\DIContainerHandler\definitionFileContainer;
|
use D3\DIContainerHandler\definitionFileContainer;
|
||||||
|
use D3\TestingTools\Development\CanAccessRestricted;
|
||||||
use Generator;
|
use Generator;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use ReflectionClass;
|
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
class definitionFileContainerTest extends TestCase
|
class definitionFileContainerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use CanAccessRestricted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*
|
*
|
||||||
@ -192,93 +194,4 @@ class definitionFileContainerTest extends TestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls a private or protected object method.
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $methodName
|
|
||||||
* @param array $arguments
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function callMethod($object, $methodName, array $arguments = [])
|
|
||||||
{
|
|
||||||
$class = new ReflectionClass($object);
|
|
||||||
$method = $class->getMethod($methodName);
|
|
||||||
$method->setAccessible(true);
|
|
||||||
return $method->invokeArgs($object, $arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a private or protected property in defined class instance
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function setValue($object, $valueName, $value)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$property->setValue($object, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a private or protected property in mocked class instance based on original class
|
|
||||||
* (required for e.g. final properties, which aren't contained in mock, but in original class)
|
|
||||||
* @param $mockedClassName * FQNS of original class
|
|
||||||
* @param $object * mock object
|
|
||||||
* @param $valueName * property name
|
|
||||||
* @param $value * new property value
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function setMockedClassValue($mockedClassName, $object, $valueName, $value)
|
|
||||||
{
|
|
||||||
$property = new \ReflectionProperty($mockedClassName, $valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$property->setValue($object, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a private or protected property from defined class instance
|
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function getValue($object, $valueName)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a private or protected property from mocked class instance based on original class
|
|
||||||
* (required for e.g. final properties, which aren't contained in mock, but in original class)
|
|
||||||
* @param object $object
|
|
||||||
* @param string $valueName
|
|
||||||
* @param mixed $value
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function getMockedClassValue($mockedClassName, $object, $valueName)
|
|
||||||
{
|
|
||||||
$property = new \ReflectionProperty($mockedClassName, $valueName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user