order
", $captured ?? ''); } + + public function testPhtmlHeaderExcludesDateWhenDisabled(): void + { + $this->scopeConfig + ->method('isSetFlag') + ->willReturnCallback(static fn(string $path): bool => match ($path) { + TemplateOverrideConfig::XML_PATH_ADD_HEADER, + TemplateOverrideConfig::XML_PATH_SOURCE_HEADER_ENABLE_PHTML, + TemplateOverrideConfig::XML_PATH_SOURCE_HEADER_INCLUDE_SOURCE_PATH, + TemplateOverrideConfig::XML_PATH_SOURCE_HEADER_INCLUDE_SOURCE_MODULE, + TemplateOverrideConfig::XML_PATH_SOURCE_HEADER_INCLUDE_MODULE_VERSION => true, + TemplateOverrideConfig::XML_PATH_SOURCE_HEADER_INCLUDE_DATE => false, + default => false, + }); + $this->registerModulePaths([ + 'Vendor_Module' => '/magento/vendor/module', + ]); + $this->packageInfo->method('getVersion')->with('Vendor_Module')->willReturn('1.2.3'); + $this->fileDriver->method('getParentDirectory')->willReturn('/theme/dir'); + $this->fileDriver->method('isDirectory')->willReturn(true); + $this->fileDriver->method('fileGetContents')->willReturn('order
'); + $captured = null; + $this->fileDriver + ->method('filePutContents') + ->willReturnCallback(static function (string $path, string $content) use (&$captured): bool { + $captured = $content; + return true; + }); + + $this->copier->copy('/source.html', '/theme/dir/target.html', 'Vendor_Module'); + + $this->assertStringContainsString('MageForge Template Override', $captured ?? ''); + $this->assertStringNotContainsString('Date:', $captured ?? ''); + } + + public function testPhpDocHeaderFallsBackToLogicalModuleWhenSourceNotResolvable(): void + { + $this->scopeConfig->method('isSetFlag')->willReturn(true); + $this->packageInfo->method('getVersion')->with('Vendor_Module')->willReturn('9.9.9'); + $this->fileDriver->method('getParentDirectory')->willReturn('/theme/dir'); + $this->fileDriver->method('isDirectory')->willReturn(true); + $this->fileDriver->method('fileGetContents')->willReturn('