Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 3968a1f

Browse files
committed
Initial commit
0 parents  commit 3968a1f

File tree

9 files changed

+208
-0
lines changed

9 files changed

+208
-0
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
root = true
2+
[*]
3+
end_of_line = lf
4+
insert_final_newline = true
5+
indent_style = space
6+
indent_size = 4
7+
trim_trailing_whitespace = true

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.editorconfig export-ignore
2+
.gitattributes export-ignore
3+
.gitignore export-ignore
4+
.travis.yml export-ignore
5+
phpunit.xml.dist export-ignore
6+
7+
* text=auto eol=lf
8+
*.php text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 diff=php
9+
*.json text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4
10+
*.yml text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4
11+
*.md text whitespace=blank-at-eol,blank-at-eof
12+
*.rst text whitespace=blank-at-eol,blank-at-eof

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.php_cs
2+
/.php_cs.cache
3+
/composer.lock
4+
/phpunit.xml
5+
/vendor/

.php_cs.dist

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of PHPUnit Good Practices.
5+
6+
(c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
7+
8+
This source file is subject to the MIT license that is bundled
9+
with this source code in the file LICENSE.
10+
EOF;
11+
12+
return PhpCsFixer\Config::create()
13+
->setRiskyAllowed(true)
14+
->setRules(array(
15+
'@Symfony' => true,
16+
'@Symfony:risky' => true,
17+
'array_syntax' => array('syntax' => 'short'),
18+
'combine_consecutive_unsets' => true,
19+
'header_comment' => array('header' => $header),
20+
'heredoc_to_nowdoc' => true,
21+
'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'),
22+
'no_short_echo_tag' => true,
23+
'no_unreachable_default_argument_value' => true,
24+
'no_useless_else' => true,
25+
'no_useless_return' => true,
26+
'ordered_class_elements' => true,
27+
'ordered_imports' => true,
28+
'phpdoc_add_missing_param_annotation' => true,
29+
'phpdoc_order' => true,
30+
'semicolon_after_instruction' => true,
31+
'strict_comparison' => true,
32+
'strict_param' => true,
33+
))
34+
->setFinder(
35+
PhpCsFixer\Finder::create()
36+
->in(__DIR__)
37+
)
38+
;

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "phpunitgoodpractices/polyfill",
3+
"type": "library",
4+
"description": "Lacking future-compat polyfills for PHPUnit.",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Dariusz Rumiński",
9+
"email": "dariusz.ruminski@gmail.com"
10+
}
11+
],
12+
"require": {
13+
"php": "^5.5 || ^7.0",
14+
"phpunit/phpunit": "^4.0 || ^5.3 || ^6.0 || ^7.0"
15+
},
16+
"require-dev": {
17+
"friendsofphp/php-cs-fixer": "^2.11"
18+
},
19+
"conflict": {
20+
"hhvm": "*"
21+
},
22+
"config": {
23+
"optimize-autoloader": true,
24+
"sort-packages": true
25+
},
26+
"autoload": {
27+
"files": [ "src/aliases.php" ],
28+
"psr-4": { "PHPUnitGoodPractices\\Polyfill\\": "src/" }
29+
}
30+
}

phpunit.xml.dist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
6+
backupGlobals="false"
7+
backupStaticAttributes="false"
8+
bootstrap="./tests/bootstrap.php"
9+
colors="true"
10+
columns="max"
11+
convertErrorsToExceptions="true"
12+
convertNoticesToExceptions="true"
13+
convertWarningsToExceptions="true"
14+
processIsolation="false"
15+
stopOnFailure="false"
16+
>
17+
<testsuites>
18+
<testsuite>
19+
<directory>./tests</directory>
20+
</testsuite>
21+
</testsuites>
22+
23+
<filter>
24+
<whitelist>
25+
<directory>./src</directory>>
26+
</whitelist>
27+
</filter>
28+
</phpunit>

src/PolyfillTrait.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHPUnit Good Practices.
5+
*
6+
* (c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace PHPUnitGoodPractices\Polyfill;
13+
14+
use PHPUnitGoodPractices\Traits\PHPUnitVersionRetriever;
15+
16+
if (version_compare(PHPUnitVersionRetriever::getVersion(), '7.0.0') < 0) {
17+
trait PolyfillTrait
18+
{
19+
public function expectException($exception)
20+
{
21+
if (is_callable(['parent', 'expectException'])) {
22+
parent::expectException($exception);
23+
} else {
24+
$this->setExpectedException($exception);
25+
}
26+
}
27+
}
28+
} else {
29+
trait PolyfillTrait
30+
{
31+
use PolyfillTrait7;
32+
}
33+
}

src/PolyfillTrait7.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of PHPUnit Good Practices.
7+
*
8+
* (c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
9+
*
10+
* This source file is subject to the MIT license that is bundled
11+
* with this source code in the file LICENSE.
12+
*/
13+
14+
namespace PHPUnitGoodPractices\Polyfill;
15+
16+
/*
17+
* @internal
18+
*/
19+
trait PolyfillTrait7
20+
{
21+
public function expectException(string $exception): void
22+
{
23+
if (is_callable(['parent', 'expectException'])) {
24+
parent::expectException($exception);
25+
} else {
26+
$this->setExpectedException($exception);
27+
}
28+
}
29+
}

src/aliases.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHPUnit Good Practices.
5+
*
6+
* (c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
if (!class_exists('PHPUnit\Framework\Error\Warning')) {
13+
class_alias('PHPUnit_Framework_Error_Warning', 'PHPUnit\Framework\Error\Warning');
14+
}
15+
16+
if (!class_exists('PHPUnit\Framework\ExpectationFailedException')) {
17+
class_alias('PHPUnit_Framework_ExpectationFailedException', 'PHPUnit\Framework\ExpectationFailedException');
18+
}
19+
20+
if (!class_exists('PHPUnit\Framework\TestCase')) {
21+
class_alias('PHPUnit_Framework_TestCase', 'PHPUnit\Framework\TestCase');
22+
}
23+
24+
if (!class_exists('PHPUnit\Runner\Version')) {
25+
class_alias('PHPUnit_Runner_Version', 'PHPUnit\Runner\Version');
26+
}

0 commit comments

Comments
 (0)