Skip to content

Commit b4024a8

Browse files
Improve test imports and exception handling
1 parent ca39f5b commit b4024a8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/Unit/Business/Churn/Exporter/ChurnExporterFactoryCustomTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
use InvalidArgumentException;
88
use Phauthentic\CognitiveCodeAnalysis\Business\Churn\Report\ChurnReportFactory;
99
use Phauthentic\CognitiveCodeAnalysis\Business\Churn\Report\ReportGeneratorInterface;
10+
use Phauthentic\CognitiveCodeAnalysis\CognitiveAnalysisException;
1011
use Phauthentic\CognitiveCodeAnalysis\Config\ConfigService;
1112
use PHPUnit\Framework\Attributes\Test;
13+
use PHPUnit\Framework\MockObject\Exception;
1214
use PHPUnit\Framework\TestCase;
1315
use PHPUnit\Framework\MockObject\MockObject;
1416
use Phauthentic\CognitiveCodeAnalysis\Tests\Unit\Business\Churn\Exporter\TestCognitiveConfig;
@@ -18,6 +20,9 @@
1820
*/
1921
class ChurnExporterFactoryCustomTest extends TestCase
2022
{
23+
/**
24+
* @throws Exception
25+
*/
2126
private function createMockConfigService(array $customExporters = []): ConfigService&MockObject
2227
{
2328
// Create TestCognitiveConfig with the custom exporters
@@ -28,6 +33,7 @@ private function createMockConfigService(array $customExporters = []): ConfigSer
2833

2934
return $configService;
3035
}
36+
3137
#[Test]
3238
public function testCreateBuiltInExporter(): void
3339
{
@@ -197,7 +203,7 @@ public function export(array $classes, string $filename): void {
197203

198204
$factory = new ChurnReportFactory($this->createMockConfigService($customExporters));
199205

200-
$this->expectException(\Phauthentic\CognitiveCodeAnalysis\CognitiveAnalysisException::class);
206+
$this->expectException(CognitiveAnalysisException::class);
201207
$this->expectExceptionMessage('Exporter must implement Phauthentic\CognitiveCodeAnalysis\Business\Churn\Report\ReportGeneratorInterface');
202208

203209
$factory->create('invalid');
@@ -218,7 +224,7 @@ public function testCustomExporterWithNonExistentFile(): void
218224

219225
$factory = new ChurnReportFactory($this->createMockConfigService($customExporters));
220226

221-
$this->expectException(\Phauthentic\CognitiveCodeAnalysis\CognitiveAnalysisException::class);
227+
$this->expectException(CognitiveAnalysisException::class);
222228
$this->expectExceptionMessage('Exporter file not found: /non/existent/file.php');
223229

224230
$factory->create('missing');

0 commit comments

Comments
 (0)