drop PHP 7 support
# Conflicts: # Tests/Unit/Production/IsMockableTest.php
Cette révision appartient à :
@ -18,6 +18,7 @@ namespace D3\TestingTools\Tests\Unit\Development;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use D3\TestingTools\Tests\Unit\Development\HelperClasses\CanAccessRestrictedClass;
|
||||
use Error;
|
||||
use Generator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionException;
|
||||
|
||||
@ -26,7 +27,7 @@ class CanAccessRestrictedTest extends TestCase
|
||||
use CanAccessRestricted;
|
||||
|
||||
/** @var CanAccessRestrictedClass */
|
||||
public $class;
|
||||
public CanAccessRestrictedClass $class;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
@ -81,17 +82,12 @@ class CanAccessRestrictedTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function canCallMethodDataProvider(): array
|
||||
public function canCallMethodDataProvider(): Generator
|
||||
{
|
||||
return [
|
||||
'public method' => ['publicMethod', true],
|
||||
'protected method' => ['protectedMethod', false],
|
||||
'private method' => ['privateMethod', false],
|
||||
'final public method' => ['finalPublicMethod', true],
|
||||
];
|
||||
yield 'public method' => ['publicMethod', true];
|
||||
yield 'protected method' => ['protectedMethod', false];
|
||||
yield 'private method' => ['privateMethod', false];
|
||||
yield 'final public method' => ['finalPublicMethod', true];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,16 +141,11 @@ class CanAccessRestrictedTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function canSetAndGetClassPropertiesDataProvider(): array
|
||||
public function canSetAndGetClassPropertiesDataProvider(): Generator
|
||||
{
|
||||
return [
|
||||
'public property' => ['publicProperty', true],
|
||||
'protected property' => ['protectedProperty', false],
|
||||
'private property' => ['privateProperty', false],
|
||||
];
|
||||
yield 'public property' => ['publicProperty', true];
|
||||
yield 'protected property' => ['protectedProperty', false];
|
||||
yield 'private property' => ['privateProperty', false];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,16 +207,11 @@ class CanAccessRestrictedTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function canSetAndGetMockedPropertiesDataProvider(): array
|
||||
public function canSetAndGetMockedPropertiesDataProvider(): Generator
|
||||
{
|
||||
return [
|
||||
'public property' => ['publicProperty', true],
|
||||
'protected property' => ['protectedProperty', false],
|
||||
'private property' => ['privateProperty', true], // because private properties not contained in mock
|
||||
];
|
||||
yield 'public property' => ['publicProperty', true];
|
||||
yield 'protected property' => ['protectedProperty', false];
|
||||
yield 'private property' => ['privateProperty', true]; // because private properties not contained in mock
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,13 +18,13 @@ namespace D3\TestingTools\Tests\Unit\Development\HelperClasses;
|
||||
class CanAccessRestrictedClass
|
||||
{
|
||||
/** @var string */
|
||||
public $publicProperty = 'publicProperty';
|
||||
public string $publicProperty = 'publicProperty';
|
||||
|
||||
/** @var string */
|
||||
protected $protectedProperty = 'protectedProperty';
|
||||
protected string $protectedProperty = 'protectedProperty';
|
||||
|
||||
/** @var string */
|
||||
private $privateProperty = 'privateProperty';
|
||||
private string $privateProperty = 'privateProperty';
|
||||
|
||||
/**
|
||||
* @param string $arg
|
||||
|
@ -31,6 +31,7 @@ class IsMockableClass extends IsMockableParent
|
||||
return 'currentClass::myMethod##'.$arg;
|
||||
}
|
||||
|
||||
public function fakeMethod()
|
||||
{}
|
||||
public function fakeMethod(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use D3\TestingTools\Production\IsMockable;
|
||||
use D3\TestingTools\Tests\Unit\Production\HelperClasses\IsMockableClass;
|
||||
use D3\TestingTools\Tests\Unit\Production\HelperClasses\IsMockableParent;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Article;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionException;
|
||||
use RuntimeException;
|
||||
|
||||
class IsMockableTest extends TestCase
|
||||
{
|
||||
@ -52,14 +52,15 @@ class IsMockableTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fqClassName
|
||||
* @param $expected
|
||||
* @test
|
||||
* @param string $fqClassName
|
||||
* @param string $expected
|
||||
*
|
||||
* @throws ReflectionException
|
||||
* @test
|
||||
* @dataProvider callMockableFunctionFromClassDataProvider
|
||||
* @covers \D3\TestingTools\Production\IsMockable::d3CallMockableFunction
|
||||
* @covers \D3\TestingTools\Production\IsMockable::d3CallMockableFunction
|
||||
*/
|
||||
public function callMockableFunctionFromClass($fqClassName, $expected): void
|
||||
public function callMockableFunctionFromClass(string $fqClassName, string $expected): void
|
||||
{
|
||||
$methodName = 'myMethod';
|
||||
$argument = $this->getRandomString();
|
||||
@ -81,16 +82,11 @@ class IsMockableTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
public function callMockableFunctionFromClassDataProvider()
|
||||
public function callMockableFunctionFromClassDataProvider(): Generator
|
||||
{
|
||||
return [
|
||||
'parent static method' => [IsMockableParent::class, 'ParentClass::myMethod##'],
|
||||
'current static method' => [IsMockableClass::class, 'currentClass::myMethod##'],
|
||||
'current object method' => ['mockObject', 'currentClass::myMethod##']
|
||||
];
|
||||
yield 'parent static method' => [IsMockableParent::class, 'ParentClass::myMethod##'];
|
||||
yield 'current static method' => [IsMockableClass::class, 'currentClass::myMethod##'];
|
||||
yield 'current object method' => ['mockObject', 'currentClass::myMethod##'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Référencer dans un nouveau ticket
Bloquer un utilisateur