createEmptySut(); $commandTester = new CommandTester($sut); $commandTester->execute([]); $result = $commandTester->getDisplay(); $this->assertStringContainsStringIgnoringCase("Files: 0", $result); $this->assertStringContainsStringIgnoringCase("0 Classes, 0 Functions, 0 Constants", $result); $this->assertStringContainsStringIgnoringCase("Loaded Extensions: 0", $result); $this->assertStringContainsStringIgnoringCase("0 Used, 0 Unused", $result); } public function testExecuteWithResults(): void { $sut = $this->createSutWithResult(); $commandTester = new CommandTester($sut); $commandTester->execute([]); $result = $commandTester->getDisplay(); $this->assertStringContainsStringIgnoringCase("Files: 3", $result); $this->assertStringContainsStringIgnoringCase("3 Classes, 2 Functions, 1 Constants", $result); $this->assertStringContainsStringIgnoringCase("Loaded Extensions: 2", $result); $this->assertStringContainsStringIgnoringCase("1 Used, 1 Unused", $result); $this->assertStringContainsStringIgnoringCase("Used [Usage: class]", $result); } private function createEmptySut(): CheckCommand { $symfonyStyleFactory = new SymfonyStyleFactory(); $fileParserMock = $this->createMock(FileParser::class); $fileParserMock->method('parseFiles')->willReturn([ [], [], [], ]); $extensionCheckMock = $this->createMock(ExtensionCheck::class); $extensionCheckMock->method('checkUsages')->willReturn([]); return new CheckCommand($symfonyStyleFactory, $fileParserMock, $extensionCheckMock); } private function createSutWithResult(): CheckCommand { $symfonyStyleFactory = new SymfonyStyleFactory(); $fileParserMock = $this->createMock(FileParser::class); $fileParserMock->method('getFileCount')->willReturn(3); $fileParserMock->method('parseFiles')->willReturn([ ['A', 'B', 'C'], ['gotoA', 'gotoB'], ['CONST_C'], ]); $extensionCheckMock = $this->createMock(ExtensionCheck::class); $extensionCheckMock->method('getLoadedExtensionsCount')->willReturn(2); $extensionCheckMock->method('checkUsages')->willReturn(['Used' => ['class' => true]]); $extensionCheckMock->method('getUnused')->willReturn(['Unused']); return new CheckCommand($symfonyStyleFactory, $fileParserMock, $extensionCheckMock); } }