1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00
This commit is contained in:
Roland Franssen :) 2021-09-02 20:53:23 +02:00
parent 27faf9502e
commit 9a6ae5a27a

View File

@ -873,6 +873,33 @@ class ConfigTest extends \Psalm\Tests\TestCase
$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');