Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed May 3, 2024
1 parent 4833195 commit 039e7b0
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/tests/checkers/php_aliases_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package checkers

import (
"testing"

"github.com/VKCOM/noverify/src/linttest"
)

func TestPhpAliases(t *testing.T) {
test := linttest.NewSuite(t)
test.AddFile(`<?php
declare(strict_types = "1")
$_ = join("", []);
`)
test.Expect = []string{
`Call to undefined function join`,
`Use implode instead of 'join'`,
}
test.RunAndMatch()
}

func TestPhpAliasesFunctionCall(t *testing.T) {
test := linttest.NewSuite(t)
test.AddFile(`<?php
declare(strict_types = "1")
$_ = join("", []);
function test($d){
ocicollmax();
}
test(join("", []));
`)
test.Expect = []string{
`Use OCICollection::max instead of 'ocicollmax'`,
`Call to undefined function ocicollmax`,
`Use implode instead of 'join'`,
`Call to undefined function join`,
`Use implode instead of 'join'`,
`Call to undefined function join`,
}
test.RunAndMatch()
}
9 changes: 9 additions & 0 deletions src/tests/golden/testdata/quickfix/phpAliases.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
declare(strict_types = "1")
$_ = join("", []);

function test($d){
ocicollmax();
}

test(join("", []));
9 changes: 9 additions & 0 deletions src/tests/golden/testdata/quickfix/phpAliases.php.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
declare(strict_types = "1")
$_ = implode("", []);

function test($d){
OCICollection::max();
}

test(implode("", []));
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
declare(strict_types = "1")
$_ = implode("", []);

function test($d){
OCICollection::max();
}

test(implode("", []));

0 comments on commit 039e7b0

Please sign in to comment.