Skip to content

Commit 65cad3e

Browse files
authored
Merge pull request #16 from wmde/phpcs
Update PHP code sniffer
2 parents 5a1ace4 + a4af3b5 commit 65cad3e

File tree

8 files changed

+71
-185
lines changed

8 files changed

+71
-185
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "^4.8.35",
21-
"wikibase/wikibase-codesniffer": "^0.4.1",
21+
"wikibase/wikibase-codesniffer": "^1.1.0",
2222
"wmde/hamcrest-html-matchers": "^0.1.0"
2323
},
2424
"autoload-dev": {

src/FilterExpressionParsing/FilterParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class FilterParser {
66

7-
const VALID_DIVISION_CHAR_REGEX = '/[\w).+\-_$\]]/';
7+
private const VALID_DIVISION_CHAR_REGEX = '/[\w).+\-_$\]]/';
88

99
private $filters = [];
1010

tests/integration/FixtureTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
use RuntimeException;
1010
use WMDE\VueJsTemplating\Templating;
1111

12+
/**
13+
* @coversNothing
14+
*/
1215
class FixtureTest extends TestCase {
1316

1417
/**
15-
* @test
1618
* @dataProvider provideFixtures
1719
*/
18-
public function phpRenderingEqualsVueJsRendering( $template, array $data, $expectedResult ) {
20+
public function testPhpRenderingEqualsVueJsRendering( $template, array $data, $expectedResult ) {
1921
$templating = new Templating();
2022
$filters = [
2123
'message' => 'strval',

tests/php/FilterExpressionParsing/FilterParserTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
use WMDE\VueJsTemplating\FilterExpressionParsing\FilterParser;
88
use WMDE\VueJsTemplating\FilterExpressionParsing\ParseResult;
99

10+
/**
11+
* @covers \WMDE\VueJsTemplating\FilterExpressionParsing\FilterParser
12+
*/
1013
class FilterParserTest extends TestCase {
1114

1215
/**
13-
* @test
1416
* @dataProvider provideParseCases
1517
*/
16-
public function parseTest( $expression, $expectedResult ) {
18+
public function testParse( $expression, $expectedResult ) {
1719
$filterParser = new FilterParser();
1820

1921
$result = $filterParser->parse( $expression );

tests/php/FilterExpressionParsing/ParseResultTest.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
use WMDE\VueJsTemplating\FilterExpressionParsing\ParseResult;
88
use WMDE\VueJsTemplating\JsParsing\BasicJsExpressionParser;
99

10+
/**
11+
* @covers \WMDE\VueJsTemplating\FilterExpressionParsing\ParseResult
12+
*/
1013
class ParseResultTest extends TestCase {
1114

1215
private $defaultFilters;
1316

14-
protected function setUp() {
17+
protected function setUp(): void {
1518
$this->defaultFilters = [
1619
'duplicate' => function ( $str ) {
1720
return $str . $str;
@@ -28,10 +31,7 @@ protected function setUp() {
2831
parent::setUp();
2932
}
3033

31-
/**
32-
* @test
33-
*/
34-
public function toExpression_SingleExpressionWithoutFilters_CreatesThisExpression() {
34+
public function testToExpression_SingleExpressionWithoutFilters_CreatesThisExpression() {
3535
$expressionParser = new BasicJsExpressionParser();
3636
$parseResult = new ParseResult( [ "'a'" ], [] );
3737

@@ -40,10 +40,7 @@ public function toExpression_SingleExpressionWithoutFilters_CreatesThisExpressio
4040
$this->assertEquals( 'a', $result );
4141
}
4242

43-
/**
44-
* @test
45-
*/
46-
public function toExpression_SingleExpressionWithFilter_CreatesThisExpression() {
43+
public function testToExpression_SingleExpressionWithFilter_CreatesThisExpression() {
4744
$expressionParser = new BasicJsExpressionParser();
4845
$parseResult = new ParseResult( [ "'a'" ], [ new FilterCall( 'duplicate', [] ) ] );
4946

@@ -52,10 +49,7 @@ public function toExpression_SingleExpressionWithFilter_CreatesThisExpression()
5249
$this->assertEquals( 'aa', $result );
5350
}
5451

55-
/**
56-
* @test
57-
*/
58-
public function toExpression_SingleExpressionWithTwoFilters_CreatesThisExpression() {
52+
public function testToExpression_SingleExpressionWithTwoFilters_CreatesThisExpression() {
5953
$expressionParser = new BasicJsExpressionParser();
6054
$parseResult = new ParseResult(
6155
[ "'a'" ],
@@ -70,10 +64,7 @@ public function toExpression_SingleExpressionWithTwoFilters_CreatesThisExpressio
7064
$this->assertEquals( 'aaaa', $result );
7165
}
7266

73-
/**
74-
* @test
75-
*/
76-
public function toExpression_SingleExpressionWithFiltersHavingArguments_CreatesThisExpression() {
67+
public function testToExpression_SingleExpressionWithFiltersHavingArgs_CreatesThisExpression() {
7768
$expressionParser = new BasicJsExpressionParser();
7869
$parseResult = new ParseResult(
7970
[ "'a'" ],
@@ -88,10 +79,7 @@ public function toExpression_SingleExpressionWithFiltersHavingArguments_CreatesT
8879
$this->assertEquals( 'abc', $result );
8980
}
9081

91-
/**
92-
* @test
93-
*/
94-
public function toExpression_TwoExpressionWithFilter_CreatesThisExpression() {
82+
public function testToExpression_TwoExpressionWithFilter_CreatesThisExpression() {
9583
$expressionParser = new BasicJsExpressionParser();
9684
$parseResult = new ParseResult(
9785
[ "'a'", "'b'" ],

tests/php/JsParsing/BasicJsExpressionParserTest.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use PHPUnit\Framework\TestCase;
66
use WMDE\VueJsTemplating\JsParsing\BasicJsExpressionParser;
77

8+
/**
9+
* @covers \WMDE\VueJsTemplating\JsParsing\BasicJsExpressionParser
10+
*/
811
class BasicJsExpressionParserTest extends TestCase {
912

10-
/**
11-
* @test
12-
*/
13-
public function canParseString() {
13+
public function testCanParseString() {
1414
$jsExpressionEvaluator = new BasicJsExpressionParser();
1515

1616
$parsedExpression = $jsExpressionEvaluator->parse( "'some string'" );
@@ -19,10 +19,7 @@ public function canParseString() {
1919
$this->assertEquals( 'some string', $result );
2020
}
2121

22-
/**
23-
* @test
24-
*/
25-
public function canParsePropertyAccess() {
22+
public function testCanParsePropertyAccess() {
2623
$jsExpressionEvaluator = new BasicJsExpressionParser();
2724

2825
$parsedExpression = $jsExpressionEvaluator->parse( "variable.property" );
@@ -31,22 +28,16 @@ public function canParsePropertyAccess() {
3128
$this->assertEquals( 'some value', $result );
3229
}
3330

34-
/**
35-
* @test
36-
*/
37-
public function canParseNegationOperator() {
31+
public function testCanParseNegationOperator() {
3832
$jsExpressionEvaluator = new BasicJsExpressionParser();
3933

4034
$negation = $jsExpressionEvaluator->parse( "!variable" );
4135

42-
$this->assertEquals( true, $negation->evaluate( [ 'variable' => false ] ) );
43-
$this->assertEquals( false, $negation->evaluate( [ 'variable' => true ] ) );
36+
$this->assertTrue( $negation->evaluate( [ 'variable' => false ] ) );
37+
$this->assertFalse( $negation->evaluate( [ 'variable' => true ] ) );
4438
}
4539

46-
/**
47-
* @test
48-
*/
49-
public function ignoresTrailingAndLeadingSpaces() {
40+
public function testIgnoresTrailingAndLeadingSpaces() {
5041
$jsExpressionEvaluator = new BasicJsExpressionParser();
5142

5243
$parsedExpression = $jsExpressionEvaluator->parse( " 'some string' " );

tests/php/JsParsing/CachingExpressionParserTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
use WMDE\VueJsTemplating\JsParsing\JsExpressionParser;
99
use WMDE\VueJsTemplating\JsParsing\StringLiteral;
1010

11+
/**
12+
* @covers \WMDE\VueJsTemplating\JsParsing\CachingExpressionParser
13+
*/
1114
class CachingExpressionParserTest extends TestCase {
1215

13-
/**
14-
* @test
15-
*/
16-
public function parse_CallsInternalParserAndReturnsItsResult() {
16+
public function testParse_CallsInternalParserAndReturnsItsResult() {
1717
$expectedExpression = new StringLiteral( 'some string' );
1818

1919
$internalParser = $this->prophesize( JsExpressionParser::class );
@@ -26,10 +26,7 @@ public function parse_CallsInternalParserAndReturnsItsResult() {
2626
$this->assertSame( $expectedExpression, $result );
2727
}
2828

29-
/**
30-
* @test
31-
*/
32-
public function parse_SameExpression_GetExactlySameObject() {
29+
public function testParse_SameExpression_GetExactlySameObject() {
3330
$cachingExpressionParser = new CachingExpressionParser( new BasicJsExpressionParser() );
3431

3532
$expression1 = $cachingExpressionParser->parse( "'some string'" );
@@ -38,10 +35,7 @@ public function parse_SameExpression_GetExactlySameObject() {
3835
$this->assertSame( $expression1, $expression2 );
3936
}
4037

41-
/**
42-
* @test
43-
*/
44-
public function parse_IgnoresSurroundingSpaces_GetExactlySameObject() {
38+
public function testParse_IgnoresSurroundingSpaces_GetExactlySameObject() {
4539
$cachingExpressionParser = new CachingExpressionParser( new BasicJsExpressionParser() );
4640

4741
$expression1 = $cachingExpressionParser->parse( "'some string'" );

0 commit comments

Comments
 (0)