Skip to content

Commit 4fdf926

Browse files
Improve tests
1 parent 596a6c6 commit 4fdf926

File tree

7 files changed

+89
-79
lines changed

7 files changed

+89
-79
lines changed
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

33
/**
4-
* test case
5-
*/
4+
* test case
5+
*/
66
namespace BarFail;
77

88
use A\B;
@@ -12,48 +12,48 @@ use Exception;
1212
use \DOMComment;
1313
use Closure as MyClosure;
1414
/**
15-
* Class Foo
16-
*/
15+
* Class Foo
16+
*/
1717
class Foo extends \DOMComment
1818
{
19-
private $a = \DOMDocument::TEST;
19+
private $a = \DOMDocument::TEST;
2020

21-
/**
22-
* method foo
23-
*
24-
* @param A\B $b b
25-
* @param \DOMDocument $d d
26-
* @param \DOMDocument|int|A\B $f f
27-
*
28-
* @throws \Exception
29-
*/
30-
public function foo(A\B $b, \DOMDocument $d, $f)
31-
{
32-
/** @var \Exception $e */
33-
$e = new \Exception('ups!');
34-
throw $e;
35-
}
21+
/**
22+
* method foo
23+
*
24+
* @param A\B $b b
25+
* @param \DOMDocument $d d
26+
* @param \DOMDocument|int|A\B $f f
27+
*
28+
* @throws \Exception
29+
*/
30+
public function foo(A\B $b, \DOMDocument $d, $f)
31+
{
32+
/** @var \Exception $e */
33+
$e = new \Exception('ups!');
34+
throw $e;
35+
}
3636

37-
/**
38-
* returns some awesome \DOMDocument
39-
*
40-
* @throws \BarFail\FooException
41-
*/
42-
public function bar()
43-
{
44-
/** @var A\Be $g */
45-
$g = new A\Be();
46-
throw new \BarFail\FooException();
47-
}
37+
/**
38+
* returns some awesome \DOMDocument
39+
*
40+
* @throws \BarFail\FooException
41+
*/
42+
public function bar()
43+
{
44+
/** @var A\Be $g */
45+
$g = new A\Be();
46+
throw new \BarFail\FooException();
47+
}
4848

49-
/**
50-
* foo
51-
*
52-
* @param \Closure $c
53-
*
54-
* @return void
55-
*/
56-
public function myClosureFoo(\Closure $c)
57-
{
58-
}
49+
/**
50+
* foo
51+
*
52+
* @param \Closure $c
53+
*
54+
* @return void
55+
*/
56+
public function myClosureFoo(\Closure $c)
57+
{
58+
}
5959
}

Brianvarskonst/Tests/Formatting/UnnecessaryNamespaceUsageUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class UnnecessaryNamespaceUsageUnitTest extends AbstractBrianvarskonstSniffUnitTest
1616
{
17-
protected array $expectedErrorList = [
17+
protected array $expectedWarningList = [
1818
'UnnecessaryNamespaceUsageUnitTest.pass.1.inc' => [],
1919
'UnnecessaryNamespaceUsageUnitTest.pass.2.inc' => [],
2020
'UnnecessaryNamespaceUsageUnitTest.pass.3.inc' => [],

Brianvarskonst/Tests/Whitespace/MultipleEmptyLinesUnitTest.fail.inc.fixed

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@
99
* @return void
1010
*/
1111
function wfFailedExamples() {
12-
$a = 1;
12+
$a = 1;
1313

14-
$b = 2;
14+
$b = 2;
1515

16-
// Comment
16+
// Comment
1717

18-
// Comment 2
18+
// Comment 2
1919

20-
// Comment 3
20+
// Comment 3
2121

22-
/* Comment 4 */
22+
/* Comment 4 */
2323

24-
# Comment 5
24+
# Comment 5
2525

26-
$c = 3;
26+
$c = 3;
2727
}
2828

2929
/**
3030
* Passed examples.
3131
* @return void
3232
*/
3333
function wfPassedExamples() {
34-
$a = 1;
34+
$a = 1;
3535

36-
$b = 2;
36+
$b = 2;
3737
}

Brianvarskonst/ruleset.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,6 @@
433433
<!-- forbid static:: in final class -->
434434
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" />
435435

436-
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces">
437-
<type>warning</type>
438-
<properties>
439-
<property name="ignoreSpacesInComment" value="yes" />
440-
</properties>
441-
</rule>
442-
443436
<!-- Rules for recent language features -->
444437
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat" />
445438
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch" />

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
"cs": "./vendor/bin/phpcs -q --parallel=$(nproc) -s",
5454
"cs:analyze": "./vendor/bin/phpstan --no-progress",
5555
"cs:bf": "php -d error_reporting=24575 vendor/bin/phpcbf;exit 0",
56-
"test:all": "@php ./vendor/bin/phpunit"
56+
"test": [
57+
"@test:unit",
58+
"@test:integration"
59+
],
60+
"test:unit": "@php ./vendor/bin/phpunit",
61+
"test:integration": "@php vendor/bin/phpcs -s --standard=Brianvarskonst integrationtests/testfile.php"
5762
}
5863
}

integrationtests/testfile.php

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
11
<?php
22

3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Symfony package.
7+
*
8+
* Taken from symfony-docs: contributing/code/standards.rst
9+
*
10+
* (c) Fabien Potencier <fabien@symfony.com>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
14+
*/
15+
316
namespace Acme;
417

518
const BAM = 1;
619

720
/**
821
* Coding standards demonstration.
922
*/
23+
// phpcs:ignore Brianvarskonst.Namespace.Psr4.InvalidPSR4, Squiz.Classes.ClassFileName.NoMatch
1024
class FooBar
1125
{
1226
public const SOME_CONST = 42;
1327
public const STR_CONST = '43';
1428
protected const PROTECT = 0;
1529
public const LALA = 'lala';
1630

17-
/**
18-
* @var string
19-
*/
20-
private $fooBar;
31+
private string $fooBar;
2132

22-
/**
23-
* @param string $dummy Some argument description
24-
*/
33+
/** @param string $dummy Some argument description */
2534
public function __construct(string $dummy)
2635
{
2736
$this->fooBar = $this->transformText($dummy);
2837
}
2938

30-
/**
31-
* @return string
32-
*
33-
* @deprecated
34-
*/
39+
/** @deprecated */
3540
public function someDeprecatedMethod(): string
3641
{
37-
@\trigger_error(\sprintf('The %s() method is deprecated since version 2.8 and will be removed in 3.0. Use Acme\Baz::someMethod() instead.', __METHOD__), E_USER_DEPRECATED);
42+
@\trigger_error(
43+
\sprintf(
44+
'The %s() method is deprecated since version 2.8 and will be removed in 3.0. Use %s instead.',
45+
__METHOD__,
46+
'Acme\Baz::someMethod()',
47+
),
48+
E_USER_DEPRECATED,
49+
);
3850

3951
return Baz::someMethod();
4052
}
@@ -49,7 +61,7 @@ public function someDeprecatedMethod(): string
4961
*
5062
* @throws \RuntimeException When an invalid option is provided
5163
*/
52-
private function transformText($dummy, array $options = []): ?string
64+
private function transformText(bool| string $dummy, array $options = []): ?string
5365
{
5466
/** @var array<string, string> $defaultOptions */
5567
$defaultOptions = [
@@ -67,15 +79,15 @@ private function transformText($dummy, array $options = []): ?string
6779

6880
$mergedOptions = \array_merge(
6981
$defaultOptions,
70-
$options
82+
$options,
7183
);
7284

73-
if (true === $dummy) {
85+
if ($dummy === true) {
7486
return null;
7587
}
7688

77-
if ('string' === $dummy) {
78-
if ('values' === $mergedOptions['some_default']) {
89+
if ($dummy === 'string') {
90+
if ($mergedOptions['some_default'] === 'values') {
7991
return \substr($dummy, 0, 5);
8092
}
8193

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
backupGlobals="true"
4-
beStrictAboutTestsThatDoNotTestAnything="true"
4+
beStrictAboutTestsThatDoNotTestAnything="false"
55
bootstrap="tests/bootstrap.php"
66
cacheResult="false"
77
>

0 commit comments

Comments
 (0)