Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Feb 2, 2025
1 parent cdc029a commit 4fe6e2c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/tests/infra/pathRulesSet_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ func pathRulesSetInit(t *testing.T) *linttest.Suite {
"undefinedFunction": true,
},
},
"star/*/tests": {
Enabled: map[string]bool{
"emptyStmt": true,
},
Disabled: map[string]bool{},
},
"mixed/*/tests": {
Enabled: map[string]bool{
"emptyStmt": true,
},
Disabled: map[string]bool{
"undefinedFunction": true,
},
},
})

var suite = linttest.NewSuite(t)
Expand Down Expand Up @@ -63,6 +77,50 @@ require_once 'foo.php';;
test.RunAndMatch()
}

func TestStarPath(t *testing.T) {
test := pathRulesSetInit(t)
code := `<?php
require_once 'foo.php';;
`
test.AddNamedFile("star/something/another/tests/foo.php", code)

test.Expect = []string{
`Semicolon (;) is not needed here, it can be safely removed at`,
}
test.RunAndMatch()
}

func TestMixedStarPath(t *testing.T) {
test := pathRulesSetInit(t)
code := `<?php
require_once 'foo.php';;
`

test.AddNamedFile("mixed/something/another/tests/foo.php", code)

code = `<?php
function function_exists($name) { return 1 == 2; }
function f($cond) {
if (!function_exists('\foo')) {
\foo();
}
if ($cond && !function_exists('bar')) {
bar("a", "b");
}
if ($cond || !function_exists('a\b\baz')) {
a\b\baz(1);
}
}
`
test.AddNamedFile("mixed/something/another/tests/foo2.php", code)

test.Expect = []string{
`Semicolon (;) is not needed here, it can be safely removed at`,
}
test.RunAndMatch()
}

func TestMixedRulesPath(t *testing.T) {
test := pathRulesSetInit(t)
mergedCode := `<?php
Expand Down

0 comments on commit 4fe6e2c

Please sign in to comment.