createStub(BackendConfigurationManager::class); $configurationManager->method('getConfiguration')->willReturn([]); $subject = new UrlFactory( $configurationManager ); self::assertInstanceOf( UrlFactory::class, $subject ); } #[DataProvider('possibleImports')] #[Test] public function createSearchResultUrl( Stub $import, array $settings, string $expectedResult ): void { $configurationManager = $this->createStub(BackendConfigurationManager::class); $configurationManager->method('getConfiguration')->willReturn(['settings' => ['destinationData' => $settings]]); $subject = new UrlFactory( $configurationManager ); $result = $subject->createSearchResultUrl($import); self::assertSame( $result, $expectedResult ); } public static function possibleImports(): array { return [ 'All provided' => [ 'import' => (function () { $import = self::createStub(Import::class); $import->method('getRestExperience')->willReturn('experience'); $import->method('getSearchQuery')->willReturn(''); return $import; })(), 'settings' => [ 'restUrl' => 'https://example.com/path', 'license' => 'licenseKey', 'restType' => 'restType', 'restMode' => 'restMode', 'restLimit' => 'restLimit', 'restTemplate' => 'restTemplate', ], 'expectedResult' => 'https://example.com/path?experience=experience&licensekey=licenseKey&type=restType&mode=restMode&limit=restLimit&template=restTemplate', ], 'All missing' => [ 'import' => (function () { $import = self::createStub(Import::class); $import->method('getRestExperience')->willReturn(''); $import->method('getSearchQuery')->willReturn(''); return $import; })(), 'settings' => [ 'restUrl' => 'https://example.com/path', ], 'expectedResult' => 'https://example.com/path', ], 'Some missing' => [ 'import' => (function () { $import = self::createStub(Import::class); $import->method('getRestExperience')->willReturn('experience'); $import->method('getSearchQuery')->willReturn(''); return $import; })(), 'settings' => [ 'restUrl' => 'https://example.com/path', 'license' => 'licenseKey', 'restLimit' => 'restLimit', 'restTemplate' => 'restTemplate', ], 'expectedResult' => 'https://example.com/path?experience=experience&licensekey=licenseKey&limit=restLimit&template=restTemplate', ], 'With search query' => [ 'import' => (function () { $import = self::createStub(Import::class); $import->method('getRestExperience')->willReturn('experience'); $import->method('getSearchQuery')->willReturn('name:"Test Something"'); return $import; })(), 'settings' => [ 'restUrl' => 'https://example.com/path', ], 'expectedResult' => 'https://example.com/path?experience=experience&q=name%3A%22Test+Something%22', ], ]; } }