1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
psalm/tests/ForbiddenCodeTest.php
2018-03-12 23:48:10 -04:00

56 lines
1.4 KiB
PHP

<?php
namespace Psalm\Tests;
class ForbiddenCodeTest extends TestCase
{
use Traits\FileCheckerInvalidCodeParseTestTrait;
use Traits\FileCheckerValidCodeParseTestTrait;
/**
* @return array
*/
public function providerFileCheckerInvalidCodeParse()
{
return [
'varDump' => [
'<?php
var_dump("hello");',
'error_message' => 'ForbiddenCode',
],
'execTicks' => [
'<?php
`rm -rf`;',
'error_message' => 'ForbiddenCode',
],
'exec' => [
'<?php
shell_exec("rm -rf");',
'error_message' => 'ForbiddenCode',
],
];
}
/**
* @return array
*/
public function providerFileCheckerValidCodeParse()
{
return [
'execWithSuppression' => [
'<?php
@exec("pwd 2>&1", $output, $returnValue);
if ($returnValue === 0) {
echo "success";
}',
],
'execWithoutSuppression' => [
'<?php
exec("pwd 2>&1", $output, $returnValue);
if ($returnValue === 0) {
echo "success";
}',
],
];
}
}