Skip to content

Commit

Permalink
remove merge error
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Nov 5, 2021
1 parent e914305 commit c0cbe7f
Showing 1 changed file with 0 additions and 196 deletions.
196 changes: 0 additions & 196 deletions tests/Config/ConfigTest.php
Expand Up @@ -860,202 +860,6 @@ class MyMockClass {}
$this->analyzeFile($file_path, new Context());
}

public function testAllowedEchoFunction(): void
{
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm></psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
echo "hello";'
);

$this->analyzeFile($file_path, new Context());
}

public function testForbiddenEchoFunctionViaFunctions(): void
{
$this->expectExceptionMessage('ForbiddenCode');
$this->expectException(\Psalm\Exception\CodeException::class);
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm>
<forbiddenFunctions>
<function name="echo" />
</forbiddenFunctions>
</psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
echo "hello";'
);

$this->analyzeFile($file_path, new Context());
}

public function testForbiddenEchoFunctionViaFlag(): void
{
$this->expectExceptionMessage('ForbiddenEcho');
$this->expectException(\Psalm\Exception\CodeException::class);
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm forbidEcho="true"></psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
echo "hello";'
);

$this->analyzeFile($file_path, new Context());
}

public function testAllowedPrintFunction(): void
{
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm></psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
print "hello";'
);

$this->analyzeFile($file_path, new Context());
}

public function testForbiddenPrintFunction(): void
{
$this->expectExceptionMessage('ForbiddenCode');
$this->expectException(\Psalm\Exception\CodeException::class);
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm>
<forbiddenFunctions>
<function name="print" />
</forbiddenFunctions>
</psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
print "hello";'
);

$this->analyzeFile($file_path, new Context());
}

public function testAllowedVarExportFunction(): void
{
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm></psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
$a = [1, 2, 3];
var_export($a);'
);

$this->analyzeFile($file_path, new Context());
}

public function testForbiddenVarExportFunction(): void
{
$this->expectExceptionMessage('ForbiddenCode');
$this->expectException(\Psalm\Exception\CodeException::class);
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm>
<forbiddenFunctions>
<function name="var_export" />
</forbiddenFunctions>
</psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
$a = [1, 2, 3];
var_export($a);'
);

$this->analyzeFile($file_path, new Context());
}

public function testForbiddenEmptyFunction(): void
{
$this->expectExceptionMessage('ForbiddenCode');
$this->expectException(\Psalm\Exception\CodeException::class);
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm>
<forbiddenFunctions>
<function name="empty" />
</forbiddenFunctions>
</psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
empty(false);'
);

$this->analyzeFile($file_path, new Context());
}

public function testValidThrowInvalidCatch(): void
{
$this->expectExceptionMessage('InvalidCatch');
Expand Down

0 comments on commit c0cbe7f

Please sign in to comment.