languageContext = $this->get(LanguageContext::class); $this->urlFinder = $this->get(UrlFinder::class); // Set CDN but do not activate \Settings::getDefault()->cdn = ['active' => 'N', 'url' => 'https://static.kupshop.local']; } /** * @dataProvider urls_dataProvider */ public function testCreateScriptURLInLanguage($page, $language, $expected) { $this->languageContext->activate($language); $url = createScriptURL([ 'URL' => 'launch.php', 's' => $page, 'ESCAPE' => 'NO', ]); $this->assertEquals($expected, $url); } public function urls_dataProvider() { return [ ['producers', 'cs', '/vyrobci/'], ['producers', 'sk', '/vyrobcovia/'], ['favourite', 'cs', '/oblibene/'], ['favourite', 'sk', '/oblubene/'], ]; } /** * @dataProvider data_testUrlFinderMedia */ public function testUrlFinderMedia($cdn, $file, $expected, $expectedAbsolute) { \Settings::getDefault()->cdn['active'] = $cdn; $this->assertEquals($expected, $this->urlFinder->staticUrl($file)); $this->assertEquals($expectedAbsolute, $this->urlFinder->staticUrlAbsolute($file)); } public function data_testUrlFinderMedia() { return [ ['N', '', '/', 'https://www.kupshop.local/'], ['N', '/', '/', 'https://www.kupshop.local/'], ['N', '/test/', '/test/', 'https://www.kupshop.local/test/'], ['N', '/pokus.html', '/pokus.html', 'https://www.kupshop.local/pokus.html'], ['Y', '', 'https://static.kupshop.local/', 'https://static.kupshop.local/'], ['Y', '/', 'https://static.kupshop.local/', 'https://static.kupshop.local/'], ['Y', '/test/', 'https://static.kupshop.local/test/', 'https://static.kupshop.local/test/'], ['Y', '/pokus.html', 'https://static.kupshop.local/pokus.html', 'https://static.kupshop.local/pokus.html'], ]; } /** * @dataProvider data_testUrlFinder */ public function testUrlFinder($file, $expected, $expectedAbsolute) { $this->assertEquals($expected, $this->urlFinder->shopUrl($file)); $this->assertEquals($expectedAbsolute, $this->urlFinder->shopUrlAbsolute($file)); $this->assertEquals($expected, createScriptURL([ 'URL' => $file, ])); $this->assertEquals($expectedAbsolute, createScriptURL([ 'URL' => $file, 'absolute' => true, ])); } public function data_testUrlFinder() { return [ ['', '/', 'https://www.kupshop.local/'], ['/', '/', 'https://www.kupshop.local/'], ]; } }