Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
97ccbb0074 | |||
f419368b33 | |||
2706d0a596 | |||
b5a7571a95 | |||
5e1b4e2110 | |||
5882cb2efc | |||
9e0eec26ca |
@ -1,13 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__)
|
||||
;
|
||||
|
||||
$header = <<<EOF
|
||||
Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
|
||||
For the full copyright and license information, please view
|
||||
the LICENSE file that was distributed with this source code.
|
||||
|
||||
https://www.d3data.de
|
||||
|
||||
@copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
@author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
@link https://www.oxidmodule.com
|
||||
EOF;
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PHP71Migration' => true,
|
||||
'@PSR12' => true
|
||||
'@PSR12' => true,
|
||||
'header_comment' => [
|
||||
'comment_type' => 'PHPDoc',
|
||||
'header' => $header,
|
||||
'location' => 'after_open',
|
||||
'separate' => 'both',
|
||||
],
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This Software is the property of Data Development and is protected
|
||||
* by copyright law - it is NOT Freeware.
|
||||
* Any unauthorized use of this software without a valid license
|
||||
* is a violation of the license agreement and will be prosecuted by
|
||||
* civil and criminal law.
|
||||
* http://www.shopmodule.com
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\TestingTools\Tests\Unit\Production\HelperClasses;
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This Software is the property of Data Development and is protected
|
||||
* by copyright law - it is NOT Freeware.
|
||||
* Any unauthorized use of this software without a valid license
|
||||
* is a violation of the license agreement and will be prosecuted by
|
||||
* civil and criminal law.
|
||||
* http://www.shopmodule.com
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\TestingTools\Tests\Unit\Production\HelperClasses;
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
@ -19,10 +21,13 @@ 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 Exception;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Article;
|
||||
use OxidEsales\Eshop\Core\Config;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use ReflectionException;
|
||||
|
||||
class IsMockableTest extends TestCase
|
||||
@ -36,19 +41,25 @@ class IsMockableTest extends TestCase
|
||||
*/
|
||||
public function callMockableFunctionMissingFunction(): void
|
||||
{
|
||||
set_error_handler(static function (int $errno, string $errstr): void {
|
||||
throw new Exception($errstr, $errno);
|
||||
}, E_USER_WARNING);
|
||||
|
||||
$methodName = $this->getRandomString();
|
||||
$argument = $this->getRandomString();
|
||||
|
||||
$traitMock = $this->getObjectForTrait(IsMockable::class);
|
||||
|
||||
// argument #1 is not a valid callable
|
||||
$this->expectError();
|
||||
$this->expectExceptionMessage('must be of type callable, array given');
|
||||
|
||||
$this->callMethod(
|
||||
$traitMock,
|
||||
'd3CallMockableFunction',
|
||||
[[$traitMock, $methodName], [$argument]]
|
||||
);
|
||||
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,6 +121,48 @@ class IsMockableTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\TestingTools\Production\IsMockable::d3GetMockableRegistryObject
|
||||
*/
|
||||
public function canGetMockableRegistryObject(): void
|
||||
{
|
||||
/** @var MockObject $mock */
|
||||
$mock = new(IsMockableClass::class);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
Config::class,
|
||||
$this->callMethod(
|
||||
$mock,
|
||||
'd3GetMockableRegistryObject',
|
||||
[Config::class]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\TestingTools\Production\IsMockable::d3GetMockableLogger
|
||||
*/
|
||||
public function canGetMockableLogger()
|
||||
{
|
||||
/** @var MockObject $mock */
|
||||
$mock = new(IsMockableClass::class);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
LoggerInterface::class,
|
||||
$this->callMethod(
|
||||
$mock,
|
||||
'd3GetMockableLogger',
|
||||
[Config::class]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $length
|
||||
*
|
||||
|
@ -30,18 +30,29 @@
|
||||
"require-dev": {
|
||||
"phpunit/phpunit" : "^9.5",
|
||||
"friendsofphp/php-cs-fixer": "^3.9",
|
||||
"phpstan/phpstan": "^1.8"
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"infection/infection": "^0.29.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"D3\\TestingTools\\": "src",
|
||||
"D3\\TestingTools\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"D3\\TestingTools\\Tests\\": "Tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"runtests": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --bootstrap=source/bootstrap.php --config=vendor/d3/testingtools/",
|
||||
"php-cs-fixer_audit": "./vendor/bin/php-cs-fixer list-files --config=./vendor/d3/testingtools/.php-cs-fixer.php",
|
||||
"php-cs-fixer_fix": "./vendor/bin/php-cs-fixer fix --config=./vendor/d3/testingtools/.php-cs-fixer.php",
|
||||
"phpstan": "./vendor/bin/phpstan analyse -c./vendor/d3/testingtools/phpstan.neon"
|
||||
|
||||
"phpstan": "./vendor/bin/phpstan analyse -c./vendor/d3/testingtools/phpstan.neon",
|
||||
|
||||
"phpunit": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --config=vendor/d3/testingtools/ --no-coverage",
|
||||
"phpunit-line-coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --config=vendor/d3/testingtools/ --coverage-html=reports/phpunit/d3testingtools",
|
||||
"phpunit-path-coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --config=vendor/d3/testingtools/ --coverage-html=reports/phpunit/d3testingtools --path-coverage",
|
||||
|
||||
"infection": "./vendor/bin/infection --configuration=vendor/d3/testingtools/infection.json5"
|
||||
}
|
||||
}
|
35
infection.json5
Normal file
35
infection.json5
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"source": {
|
||||
"directories": [
|
||||
"vendor/d3/testingtools"
|
||||
],
|
||||
"excludes": [
|
||||
".php-cs-fixer.php",
|
||||
"rector.php",
|
||||
"Tests"
|
||||
]
|
||||
},
|
||||
"timeout": 60,
|
||||
"logs": {
|
||||
"text": "../../../reports/infection/d3testingtools/infection.log",
|
||||
"html": "../../../reports/infection/d3testingtools/infection.html",
|
||||
"summary": "../../../reports/infection/d3testingtools/summary.log",
|
||||
"json": "../../../reports/infection/d3testingtools/infection-log.json",
|
||||
"perMutator": "../../../reports/infection/d3testingtools/per-mutator.md",
|
||||
"summaryJson": "../../../reports/infection/d3testingtools/summary.json"
|
||||
},
|
||||
"tmpDir": "./infection/tmp",
|
||||
"phpUnit": {
|
||||
"configDir": "."
|
||||
},
|
||||
"mutators": {
|
||||
"@default": true,
|
||||
"@function_signature": false,
|
||||
"global-ignoreSourceCodeByRegex": [
|
||||
".*\\sstartProfile\\(.*",
|
||||
".*\\sstopProfile\\(.*"
|
||||
]
|
||||
},
|
||||
"testFramework":"phpunit",
|
||||
"bootstrap":"source/bootstrap.php"
|
||||
}
|
33
phpunit.xml
33
phpunit.xml
@ -1,20 +1,39 @@
|
||||
<?xml version="1.0"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
bootstrap="vendor/autoload.php"
|
||||
backupGlobals="true"
|
||||
bootstrap="../../../source/bootstrap.php"
|
||||
colors="false"
|
||||
backupStaticAttributes="false"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertNoticesToExceptions="false"
|
||||
convertWarningsToExceptions="true"
|
||||
forceCoversAnnotation="false"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
stopOnIncomplete="false"
|
||||
stopOnSkipped="false"
|
||||
beStrictAboutTestsThatDoNotTestAnything="false"
|
||||
verbose="false"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage>
|
||||
<testsuites>
|
||||
<testsuite name="testingTools">
|
||||
<directory>./Tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage includeUncoveredFiles="true" processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">src</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
<file>../.php-cs-fixer.php</file>
|
||||
<directory>../Tests/</directory>
|
||||
</exclude>
|
||||
<report>
|
||||
<clover outputFile="build/logs/clover.xml"/>
|
||||
</report>
|
||||
</coverage>
|
||||
<testsuite name="testingTools">
|
||||
<directory>./Tests</directory>
|
||||
</testsuite>
|
||||
<logging/>
|
||||
<php>
|
||||
<const name="OXID_PHP_UNIT" value="true"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user