From 18b6fbc9079949397fc2526945788679061c8719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20S=C5=82owik?= Date: Fri, 12 Nov 2021 16:59:20 +0100 Subject: [PATCH] Add tests for UnresolvableInclude --- tests/UnresolvableIncludeTest.php | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tests/UnresolvableIncludeTest.php diff --git a/tests/UnresolvableIncludeTest.php b/tests/UnresolvableIncludeTest.php new file mode 100644 index 00000000000..169a7267e5b --- /dev/null +++ b/tests/UnresolvableIncludeTest.php @@ -0,0 +1,78 @@ +addFile('somefile.php', $phpCode); + $context = new Context(); + + $this->expectException(CodeException::class); + $this->expectExceptionMessage("UnresolvableInclude - somefile.php:$expectedExceptionLine:"); + + $this->analyzeFile('somefile.php', $context); + } + + /** + * @return array + */ + public function providerUnresolvableInclude(): array + { + return [ + 'basic' => [ + ' 3, + ], + ]; + } + + /** + * @dataProvider providerNoUnresolvableInclude + */ + public function testShouldNotThrowUnresolvableInclude(string $phpCode): void + { + $this->addFile('somefile.php', $phpCode); + + $context = new Context(); + + $this->analyzeFile('somefile.php', $context); + } + + /** + * @return array + */ + public function providerNoUnresolvableInclude(): array + { + return [ + 'github_issue_908_file_exists' => [ + ' [ + '