first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,342 @@
{
"sections": [
{
"id": 1,
"id_block": null,
"name": "Test sekce bez prekladu",
"figure": "Y",
"priority": 0,
"behaviour": "2",
"orderby": "title",
"orderdir": "ASC",
"date_updated": "2013-09-13 00:00:00",
"list_variations": "N",
"lead_figure": "N",
"lead_text": "",
"lead_products": "",
"producers_filter": "Y",
"template": "",
"virtual": "N",
"url": "test-sekce-bez-prekladu",
"filter_url": "test-sekce-bez-prekladu"
},
{
"id": 2,
"id_block": null,
"name": "Test sekce s prekladem",
"figure": "Y",
"priority": 0,
"behaviour": "2",
"orderby": "title",
"orderdir": "ASC",
"date_updated": "2013-09-13 00:00:00",
"list_variations": "N",
"lead_figure": "N",
"lead_text": "",
"lead_products": "",
"producers_filter": "Y",
"template": "",
"virtual": "N",
"url": "test-sekce-s-prekladem",
"filter_url": "test-sekce-s-prekladem"
},
{
"id": 3,
"id_block": null,
"name": "Test sekce skryta v prekladu",
"figure": "Y",
"priority": 0,
"behaviour": "2",
"orderby": "title",
"orderdir": "ASC",
"date_updated": "2013-09-13 00:00:00",
"list_variations": "N",
"lead_figure": "N",
"lead_text": "",
"lead_products": "",
"producers_filter": "Y",
"template": "",
"virtual": "N",
"url": "test-sekce-skryta-v-prekladu",
"filter_url": "test-sekce-skryta-v-prekladu"
},
{
"id": 4,
"id_block": null,
"name": "Test sekce s prekladem bez custom url",
"figure": "Y",
"priority": 0,
"behaviour": "2",
"orderby": "title",
"orderdir": "ASC",
"date_updated": "2013-09-13 00:00:00",
"list_variations": "N",
"lead_figure": "N",
"lead_text": "",
"lead_products": "",
"producers_filter": "Y",
"template": "",
"virtual": "N",
"url": null,
"filter_url": null
}
],
"sections_translations": [
{
"id": 1,
"id_section": 2,
"id_language": "sk",
"id_admin": null,
"created": "2023-01-10 15:52:43",
"updated": "2023-06-07 13:30:05",
"name": "Test sekce s SK prekladem",
"figure": null,
"url": "test-sekce-s-sk-prekladem",
"filter_url": "test-sekce-s-sk-prekladem"
},
{
"id": 2,
"id_section": 3,
"id_language": "sk",
"id_admin": null,
"created": "2023-01-10 15:52:43",
"updated": "2023-06-07 13:30:05",
"name": "Test sekce skryta v prekladu",
"figure": "N",
"url": null,
"filter_url": null
},
{
"id": 3,
"id_section": 4,
"id_language": "sk",
"id_admin": null,
"created": "2023-01-10 15:52:43",
"updated": "2023-06-07 13:30:05",
"name": "Test sekce s prekladem bez custom url SK",
"figure": null,
"url": null,
"filter_url": null
}
],
"parameters_sections":[
{
"id_parameter": 14,
"id_section": 2,
"filter": "Y",
"required": "Y",
"weight": 0,
"indexing": "Y",
"to_title": "Y"
}
],
"products": [
{
"id": 1,
"id_block": null,
"title": "iPhone wpj",
"code": "TEST01",
"ean": null,
"short_descr": "",
"long_descr": "",
"parameters": "",
"price": 1652.0660,
"price_for_discount": 1652.0660,
"price_common": 0.0000,
"vat": 1,
"discount": 80.04000092,
"producer": 17,
"guarantee": 36,
"in_store": 23,
"pieces_sold": 10,
"delivery_time": 0,
"campaign": "",
"updated": "2023-07-19 20:03:32",
"date_added": "2015-02-13 13:56:00",
"figure": "Y"
},
{
"id": 2,
"id_block": null,
"title": "produkt s prekladem",
"code": "TEST02",
"ean": null,
"short_descr": "",
"long_descr": "",
"parameters": "",
"price": 1652.0660,
"price_for_discount": 1652.0660,
"price_common": 0.0000,
"vat": 1,
"discount": 80.04000092,
"producer": 17,
"guarantee": 36,
"in_store": 23,
"pieces_sold": 10,
"delivery_time": 0,
"campaign": "",
"updated": "2023-07-19 20:03:32",
"date_added": "2015-02-13 13:56:00",
"figure": "Y"
},
{
"id": 3,
"id_block": null,
"title": "produkt skryty v prekladu",
"code": "TEST03",
"ean": null,
"short_descr": "",
"long_descr": "",
"parameters": "",
"price": 1652.0660,
"price_for_discount": 1652.0660,
"price_common": 0.0000,
"vat": 1,
"discount": 80.04000092,
"producer": 17,
"guarantee": 36,
"in_store": 23,
"pieces_sold": 10,
"delivery_time": 0,
"campaign": "",
"updated": "2023-07-19 20:03:32",
"date_added": "2015-02-13 13:56:00",
"figure": "Y"
}
],
"products_translations": [
{
"id": 1,
"id_product": 2,
"id_language": "sk",
"id_admin": null,
"created": "2023-06-06 16:44:17",
"updated": "2025-02-28 17:11:40",
"title": "produkt s sk prekladem",
"figure": null
},
{
"id": 2,
"id_product": 3,
"id_language": "sk",
"id_admin": null,
"created": "2023-06-06 16:44:17",
"updated": "2025-02-28 17:11:40",
"title": null,
"figure": "N"
}
],
"articles": [
{
"id": 1,
"id_block": null,
"title": "Lorem Ipsum",
"keywords": "",
"source": "",
"lead_in": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut tempus purus at lorem. Integer rutrum, orci vestibulum ullamcorper ultricies.",
"date": "2013-09-27 16:39:52",
"figure": "Y",
"show_in_search": "Y"
},
{
"id": 2,
"id_block": null,
"title": "Lorem Ipsum s prekladem",
"keywords": "",
"source": "",
"lead_in": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut tempus purus at lorem. Integer rutrum, orci vestibulum ullamcorper ultricies.",
"date": "2013-09-27 16:39:52",
"figure": "Y",
"show_in_search": "Y"
},
{
"id": 3,
"id_block": null,
"title": "Lorem Ipsum skryty v prekladu",
"keywords": "",
"source": "",
"lead_in": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut tempus purus at lorem. Integer rutrum, orci vestibulum ullamcorper ultricies.",
"date": "2013-09-27 16:39:52",
"figure": "Y",
"show_in_search": "Y"
}
],
"articles_translations": [
{
"id": 1,
"id_article": 2,
"id_language": "sk",
"id_admin": null,
"created": "2023-04-16 13:11:57",
"title": "Lorem Ipsum sk",
"figure": "Y"
},
{
"id": 2,
"id_article": 3,
"id_language": "sk",
"id_admin": null,
"created": "2023-04-16 13:11:57",
"title": null,
"figure": "N"
}
],
"menu_links": [
{
"id": 1,
"id_block": null,
"id_menu": 1,
"type": 1,
"parent": null,
"list_order": 1,
"name": "Kontakt",
"url": "kontakt/",
"link": null,
"figure": "Y"
},
{
"id": 2,
"id_block": null,
"id_menu": 2,
"type": 1,
"parent": null,
"list_order": 1,
"name": "Stranka s prekladem",
"url": "stranka-s-prekladem/",
"link": null,
"figure": "Y"
},
{
"id": 3,
"id_block": null,
"id_menu": 3,
"type": 1,
"parent": null,
"list_order": 1,
"name": "Stranka skryta v prekladu",
"url": "stranka-skryta-v-prekladu/",
"link": null,
"figure": "Y"
}
],
"menu_links_translations": [
{
"id": 1,
"id_menu_link": 2,
"id_language": "sk",
"id_admin": null,
"created": "2023-04-24 09:23:19",
"url": "sk-stranka-s-prekladem/",
"figure": null
},
{
"id": 2,
"id_menu_link": 3,
"id_language": "sk",
"id_admin": null,
"created": "2023-04-24 09:23:19",
"url": "sk-stranka-skryta-v-prekladu/",
"figure": "N"
}
]
}

View File

@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace KupShop\I18nBundle\Tests\Locale;
use KupShop\I18nBundle\Util\Locale\LanguageAwareUrlGenerator;
use KupShop\KupShopBundle\Context\LanguageContext;
use KupShop\KupShopBundle\Util\Contexts;
class LanguageAwareUrlGeneratorTest extends \DatabaseTestCase
{
private LanguageAwareUrlGenerator $urlGenerator;
protected function setUp(): void
{
parent::setUp();
$this->urlGenerator = $this->get(LanguageAwareUrlGenerator::class);
$this->initializeRequestStack();
}
/** @dataProvider data_testLocaleChange */
public function testLocaleChange(string $language, string $path, string $expectedPath): void
{
$this->assertEquals(
$expectedPath,
$this->urlGenerator->generateInLanguage($language, $path)
);
}
public function data_testLocaleChange(): iterable
{
// products
yield 'Locale change for product without translation' => ['sk', '/iphone-wpj_z1/', '/iphone-wpj_z1/'];
yield 'Locale change for product with translation' => ['sk', '/produkt-s-prekladem_z2/', '/produkt-s-sk-prekladem_z2/'];
yield 'Locale change for product hidden in translation' => ['sk', '/produkt-skryty-v-prekladu_z3/', '/'];
// sections
yield 'Locale change for section without translation with custom URL' => ['sk', '/test-sekce-bez-prekladu/', '/test-sekce-bez-prekladu/'];
yield 'Locale change for section with translation with custom URL' => ['sk', '/test-sekce-s-prekladem/', '/test-sekce-s-sk-prekladem/'];
yield 'Locale change for section hidden in translation with custom URL' => ['sk', '/test-sekce-skryta-v-prekladu/', '/'];
yield 'Locale change for section with translation' => ['sk', '/test-sekce-s-prekladem-bez-custom-url_k4/', '/test-sekce-s-prekladem-bez-custom-url-sk_k4/'];
yield 'Locale change for section with filter parameters' => ['sk', '/test-sekce-s-prekladem/f/cervena/', '/test-sekce-s-sk-prekladem/'];
// articles
yield 'Locale change for article without translation' => ['sk', '/clanek/1/lorem-ipsum/', '/clanok/1/lorem-ipsum/'];
yield 'Locale change for article with translation' => ['sk', '/clanek/2/lorem-ipsum-s-prekladem/', '/clanok/2/lorem-ipsum-sk/'];
yield 'Locale change for article hidden in translation' => ['sk', '/clanek/3/lorem-ipsum-skryty-v-prekladu/', '/'];
// dynamic pages (menu links)
yield 'Locale change for page without translation' => ['sk', '/kontakt/', '/kontakt/'];
yield 'Locale change for page with translation' => ['sk', '/stranka-s-prekladem/', '/sk-stranka-s-prekladem/'];
yield 'Locale change for page hidden in translation' => ['sk', '/stranka-skryta-v-prekladu/', '/'];
// static pages
yield 'Locale change for registration page' => ['sk', '/registrace/', '/registracia/'];
yield 'Locale change for login page' => ['sk', '/prihlaseni/', '/prihlasenie/'];
}
public function testPathAfterLocaleChange(): void
{
$languageContext = Contexts::get(LanguageContext::class);
$articlePath = path('kupshop_content_articles_article', ['IDa' => 1]);
$this->assertEquals('/clanek/1/', $articlePath, 'cs language active - URL should be in cs lang');
$languageContext->activate('sk');
$articlePath = path('kupshop_content_articles_article', ['IDa' => 1]);
$this->assertEquals('/clanok/1/', $articlePath, 'sk language active - URL should be in sk lang');
}
protected function getDataSet()
{
return $this->getJsonDataSetFromFile();
}
}