From 2b7a1948428e9e77e7c8668f318129c5831633c9 Mon Sep 17 00:00:00 2001 From: whitelacoste Date: Fri, 16 Dec 2022 15:58:35 +0300 Subject: [PATCH 01/32] =?UTF-8?q?[IVEDU-17]=20=D1=83=D1=80=D0=BE=D0=BA=201?= =?UTF-8?q?.2=20=D0=BA=D1=83=D1=80=D1=81=202=20=D0=B7=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/include.php | 23 +++++- lib/filestree/componenttemplate.php | 1 + lib/locator/io/mainheadertemplate.php | 21 ++++++ lib/locator/io/sliderstocktemplate.php | 23 ++++++ lib/tester.php | 6 ++ .../course2/lesson1/testcomponentinclude.php | 27 +++++++ lib/tests/course2/lesson1/testslider.php | 73 +++++++++++++++++++ 7 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 lib/locator/io/mainheadertemplate.php create mode 100644 lib/locator/io/sliderstocktemplate.php create mode 100644 lib/tests/course2/lesson1/testcomponentinclude.php create mode 100644 lib/tests/course2/lesson1/testslider.php diff --git a/lang/ru/include.php b/lang/ru/include.php index 3ef489eb..f0895b75 100644 --- a/lang/ru/include.php +++ b/lang/ru/include.php @@ -13,6 +13,7 @@ $MESS['INTERVOLGA_EDU.COURSE1_LESSON8'] = '8. Комплексные компоненты'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON10'] = '10. Поиск'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11'] = '11. Полезные возможности'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1'] = '1. Получение связанных элементов'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON1'] = '1. Создание модуля'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON4'] = '4. Пользовательские поля и типы'; @@ -67,6 +68,14 @@ $MESS['INTERVOLGA_EDU.COURSE1_LESSON42_EMAIL_DESCRIPTION'] = 'Ссылка в почтовом шаблоне «Запрос на смену пароля» (USER_PASS_REQUEST) должна вести на корректную страницу'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON10_SEARCHACTION'] = 'Проверка формы поиска'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON10_SEARCHACTION_DESCRIPTION'] = 'Должна быть настроена на раздел, а не на index.php-страницу'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_CATALOGBINDINGPROPERTY'] = 'Проверка свойства "Привязка к каталогу"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_CATALOGBINDINGPROPERTY_DESCRIPTION'] = 'Свойство должно существовать, должно быть заполненно хотя бы у 3 элементов и иметь тип "привязка к инфоблокам"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_PROPERTYPRICE'] = 'Проверка свойства "Цена"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_PROPERTYPRICE_DESCRIPTION'] = 'Свойство должно существовать, иметь тип "строка"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_COMPONENTINCLUDE'] = 'Проверка подключения "Слайдера"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_COMPONENTINCLUDE_DESCRIPTION'] = 'В header.php главной страницы должен подключаться компонент списка новостей с шаблоном слайдера'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_SLIDER'] = 'Проверка содержимого шаблона Слайдера'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_SLIDER_DESCRIPTION'] = 'Должны быть правильно заполнены ссылки, getList не должен быть в цикле, js-скрипты подключаются в правильном файле'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON1_MODULE'] = 'Проверка собственного модуля'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON4_UF'] = 'Проверка собственного UF-свойства'; @@ -94,6 +103,7 @@ $MESS['INTERVOLGA_EDU.PRICE_PROPERTY'] = 'Цена'; $MESS['INTERVOLGA_EDU.POST_PROPERTY'] = 'Должность'; $MESS['INTERVOLGA_EDU.COMPANY_PROPERTY'] = 'Компания'; +$MESS['INTERVOLGA_EDU.CATALOGBINDING_PROPERTY'] = 'Привязка к каталогу'; $MESS['INTERVOLGA_EDU.AVAILABLE_PROPERTY'] = 'В наличии'; $MESS['INTERVOLGA_EDU.IBLOCK_REVIEWS'] = 'Отзывы'; $MESS['INTERVOLGA_EDU.IBLOCK_PROMO'] = 'Акции'; @@ -123,6 +133,9 @@ $MESS['INTERVOLGA_EDU.CUSTOM_MODULE_TIP'] = 'intervolga.? в #MODULES#'; $MESS['INTERVOLGA_EDU.INCLUDEAREA_PARTNERS'] = 'Включаемая область в разделе Партнерам'; $MESS['INTERVOLGA_EDU.INCLUDEAREA_PARTNERS_TIPS'] = 'в названии должно быть: #PARTS#'; +$MESS['INTERVOLGA_EDU.MAIN_HEADER_TEMPLATE'] = 'Шаблон header главной страницы'; +$MESS['INTERVOLGA_EDU.MAIN_HEADER_TEMPLATE_INCLUDE_COMPONENT'] = 'подключение шаблона слайдера компонента списка новостей'; +$MESS['INTERVOLGA_EDU.SLIDER_STOCK_TEMPLATE'] = 'Шаблон слайдера'; $MESS['INTERVOLGA_EDU.TOP_MENU_TEMPLATE'] = 'Шаблон верхнего меню'; $MESS['INTERVOLGA_EDU.LEFT_MENU_TEMPLATE'] = 'Шаблон левого меню'; $MESS['INTERVOLGA_EDU.BOTTOM_MENU_TEMPLATE'] = 'Шаблон меню О магазине'; @@ -131,4 +144,12 @@ $MESS['INTERVOLGA_EDU.PROMO_NEWS_TEMPLATE_DIRECTORY'] = 'Шаблон акций'; $MESS['INTERVOLGA_EDU.TEST_IBLOCK_NAME'] = 'Проверка Инфоблока #IBLOCK#'; $MESS['INTERVOLGA_EDU.TEST_IBLOCK_DESCRIPTION'] = 'Проверка типа, прав, количества элементов, свойств по заданию, формы редактирования в админке'; -$MESS['INTERVOLGA_EDU.SEARCH_FORM_TEMPLATE'] = 'Шаблон формы поиска'; \ No newline at end of file +$MESS['INTERVOLGA_EDU.SEARCH_FORM_TEMPLATE'] = 'Шаблон формы поиска'; +$MESS['INTERVOLGA_EDU.GET_LIST_IN_FOREACH'] = 'GetList помещен в foreach'; +$MESS['INTERVOLGA_EDU.NOT_FOUND_RESIZE'] = 'ресайз детального изображения'; +$MESS['INTERVOLGA_EDU.LINK_SET_NOT_BINDING_VALUE'] = 'заполнение ссылки вручную'; +$MESS['INTERVOLGA_EDU.LINK_SET_NOT_BINDING_VALUE_IMG'] = 'заполнение ссылки вручную в '; +$MESS['INTERVOLGA_EDU.NOT_BINDING_ARRAY'] = 'Массив связанного элемента не заполнен'; +$MESS['INTERVOLGA_EDU.JS_NOT_FOUND_IN_COMPONENT_EPILOG'] = 'подключение js-скриптов карусели или подключение не соответствует ядру D7'; +$MESS['INTERVOLGA_EDU.NOT_TITLE_IN_LINK'] = 'title в ссылке на связанный элемент'; +$MESS['INTERVOLGA_EDU.NOT_TITLE_IN_LINK_IMG'] = 'title в ссылке на связанный элемент в '; \ No newline at end of file diff --git a/lib/filestree/componenttemplate.php b/lib/filestree/componenttemplate.php index 6517d936..b632a115 100644 --- a/lib/filestree/componenttemplate.php +++ b/lib/filestree/componenttemplate.php @@ -109,6 +109,7 @@ public function getKnownFiles(): array { $result = [ $this->getComponentEpilogFile(), + $this->getResultModifier(), $this->getParametersFile(), $this->getDescriptionFile(), ]; diff --git a/lib/locator/io/mainheadertemplate.php b/lib/locator/io/mainheadertemplate.php new file mode 100644 index 00000000..1816ea58 --- /dev/null +++ b/lib/locator/io/mainheadertemplate.php @@ -0,0 +1,21 @@ +IncludeComponent\(\s*(\'|")bitrix\:news\.list(\'|")\,\s*(\'|")slider(\'|")/i', Loc::getMessage('MAIN_HEADER_TEMPLATE_INCLUDE_COMPONENT'))); + } + + /** + * @return string|FileLocator + */ + protected static function getLocator(){ + return MainHeaderTemplate::class; + } + +} \ No newline at end of file diff --git a/lib/tests/course2/lesson1/testslider.php b/lib/tests/course2/lesson1/testslider.php new file mode 100644 index 00000000..3004cb73 --- /dev/null +++ b/lib/tests/course2/lesson1/testslider.php @@ -0,0 +1,73 @@ +getTemplateFile()); + static::testTemplate($templateDir); + Assert::fseExists($templateDir->getResultModifier()); + static::testResultModifier($templateDir); + Assert::fseExists($templateDir->getComponentEpilogFile()); + static::testComponentEpilogFile($templateDir); + + } + + /** + * @return string|DirectoryLocator + */ + protected static function getLocator() + { + return SliderStockTemplate::class; + } + + /** + * @return string|ComponentTemplate + */ + protected static function getComponentTemplateTree() + { + return SimpleComponentTemplate::class; + } + + protected static function testTemplate(ComponentTemplate $templateDir) + { + Assert::fseExists(static::getLocator()::find()); + + Assert::fileContentMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"\%\&\;\:\.\(\)]*title[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/>/is', Loc::getMessage('INTERVOLGA_EDU.NOT_TITLE_IN_LINK_IMG'))); + Assert::fileContentMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"\%\&\;\:\.\(\)]*title[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*>[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*(подробнее|Loc::getMessage)[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/a>/ius', Loc::getMessage('INTERVOLGA_EDU.NOT_TITLE_IN_LINK'))); + + Assert::fileContentNotMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"]*href\s*=\s*"[\/]+[\w\s<>?=$\[\]\'"\/]*"[\w\s<>?=$\[\]\'"\%\&\;\:]*>/is', Loc::getMessage('INTERVOLGA_EDU.LINK_SET_NOT_BINDING_VALUE_IMG'))); + Assert::fileContentNotMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"]*href\s*=\s*"[\/]+[\w\s<>?=$\[\]\'"\/]*"[\w\s<>?=$\[\]\'"\%\&\;\:]*>/is', Loc::getMessage('INTERVOLGA_EDU.LINK_SET_NOT_BINDING_VALUE'))); + + } + + protected static function testResultModifier(ComponentTemplate $templateDir) + { + Assert::fileContentMatches($templateDir->getResultModifier(), new Regex('/CFile::ResizeImageGet/i', Loc::getMessage('INTERVOLGA_EDU.NOT_FOUND_RESIZE'))); + Assert::fileContentNotMatches($templateDir->getResultModifier(), new Regex('/(foreach|while|for)[\w\s<>?=$\[\]\'"\%\&\;\:\(\)]*{[\w\s<>?=$\[\]\'"\%\&\;\:\(\)]*CIBlockElement::GetList/is', Loc::getMessage('INTERVOLGA_EDU.GET_LIST_IN_FOREACH'))); + + } + + protected static function testComponentEpilogFile(ComponentTemplate $templateDir) { + Assert::fileContentMatches($templateDir->getComponentEpilogFile(), new Regex('/->\s*addJs\s*\([\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/js\/slides\.min\.jquery\.js/is', Loc::getMessage('INTERVOLGA_EDU.JS_NOT_FOUND_IN_COMPONENT_EPILOG'))); + + } + +} \ No newline at end of file From e83f168a8c819931073fb74e67f64c6887c65e0f Mon Sep 17 00:00:00 2001 From: whitelacoste Date: Wed, 21 Dec 2022 12:04:15 +0300 Subject: [PATCH 02/32] =?UTF-8?q?[IVEDU-17]=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/include.php | 12 +++------ lang/ru/lib/asserts/assert.php | 2 ++ lib/locator/component/template/slider.php | 27 +++++++++++++++++++ lib/tester.php | 7 ++--- .../course2/lesson1/testcomponentinclude.php | 27 ------------------- .../lesson1_2/testcomponentinclude.php | 24 +++++++++++++++++ .../{lesson1 => lesson1_2}/testslider.php | 12 ++++----- 7 files changed, 64 insertions(+), 47 deletions(-) create mode 100644 lib/locator/component/template/slider.php delete mode 100644 lib/tests/course2/lesson1/testcomponentinclude.php create mode 100644 lib/tests/course2/lesson1_2/testcomponentinclude.php rename lib/tests/course2/{lesson1 => lesson1_2}/testslider.php (86%) diff --git a/lang/ru/include.php b/lang/ru/include.php index f0895b75..f69a3964 100644 --- a/lang/ru/include.php +++ b/lang/ru/include.php @@ -68,14 +68,10 @@ $MESS['INTERVOLGA_EDU.COURSE1_LESSON42_EMAIL_DESCRIPTION'] = 'Ссылка в почтовом шаблоне «Запрос на смену пароля» (USER_PASS_REQUEST) должна вести на корректную страницу'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON10_SEARCHACTION'] = 'Проверка формы поиска'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON10_SEARCHACTION_DESCRIPTION'] = 'Должна быть настроена на раздел, а не на index.php-страницу'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_CATALOGBINDINGPROPERTY'] = 'Проверка свойства "Привязка к каталогу"'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_CATALOGBINDINGPROPERTY_DESCRIPTION'] = 'Свойство должно существовать, должно быть заполненно хотя бы у 3 элементов и иметь тип "привязка к инфоблокам"'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_PROPERTYPRICE'] = 'Проверка свойства "Цена"'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_PROPERTYPRICE_DESCRIPTION'] = 'Свойство должно существовать, иметь тип "строка"'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_COMPONENTINCLUDE'] = 'Проверка подключения "Слайдера"'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_COMPONENTINCLUDE_DESCRIPTION'] = 'В header.php главной страницы должен подключаться компонент списка новостей с шаблоном слайдера'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_SLIDER'] = 'Проверка содержимого шаблона Слайдера'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_SLIDER_DESCRIPTION'] = 'Должны быть правильно заполнены ссылки, getList не должен быть в цикле, js-скрипты подключаются в правильном файле'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_COMPONENTINCLUDE'] = 'Проверка подключения "Слайдера"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_COMPONENTINCLUDE_DESCRIPTION'] = 'В header.php главной страницы должен подключаться компонент списка новостей с шаблоном слайдера'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDER'] = 'Проверка содержимого шаблона Слайдера'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDER_DESCRIPTION'] = 'Должны быть правильно заполнены ссылки, getList не должен быть в цикле, js-скрипты подключаются в правильном файле'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON1_MODULE'] = 'Проверка собственного модуля'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON4_UF'] = 'Проверка собственного UF-свойства'; diff --git a/lang/ru/lib/asserts/assert.php b/lang/ru/lib/asserts/assert.php index 1c13a64f..954cb6b5 100644 --- a/lang/ru/lib/asserts/assert.php +++ b/lang/ru/lib/asserts/assert.php @@ -25,6 +25,8 @@ $MESS['INTERVOLGA_EDU.ASSERT_IBLOCK_LOCATOR'] = 'Инфоблок #IBLOCK# не найден (#POSSIBLE#)'; $MESS['INTERVOLGA_EDU.ASSERT_PROPERTY_LOCATOR'] = 'Свойство #PROPERTY# не найдено (#POSSIBLE#)'; $MESS['INTERVOLGA_EDU.ASSERT_DIRECTORY_LOCATOR'] = 'Папка #DIRECTORY# не найдена (#POSSIBLE#)'; +$MESS['INTERVOLGA_EDU.ASSERT_COMPONENT_LOCATOR'] = 'Компонент #COMPONENT# не найден'; +$MESS['INTERVOLGA_EDU.ASSERT_TEMPLATE_LOCATOR'] = 'Шаблон #TEMPLATE# не найден'; $MESS['INTERVOLGA_EDU.ASSERT_FILE_LOCATOR'] = 'Файл #FILE# не найден (#POSSIBLE#)'; $MESS['INTERVOLGA_EDU.ASSERT_MENU_ITEM_NOT_EXISTS'] = 'Пункт #ITEM# в меню #MENU# должен быть удален'; $MESS['INTERVOLGA_EDU.ASSERT_MENU_ITEM_EXISTS'] = 'Пункт #ITEM# в меню #MENU# не найден, должен существовать'; \ No newline at end of file diff --git a/lib/locator/component/template/slider.php b/lib/locator/component/template/slider.php new file mode 100644 index 00000000..cc4198e1 --- /dev/null +++ b/lib/locator/component/template/slider.php @@ -0,0 +1,27 @@ + 'slider || slider_promo || slider_list || slider_stock']; + } + + public static function getNameLoc(): string + { + return 'slider || slider_promo || slider_list || slider_stock'; + } +} \ No newline at end of file diff --git a/lib/tester.php b/lib/tester.php index 45df3c03..9ae6ddce 100644 --- a/lib/tester.php +++ b/lib/tester.php @@ -3,7 +3,6 @@ use Intervolga\Edu\Exceptions\AssertException; use Intervolga\Edu\Tests\BaseTest; -use Intervolga\Edu\Tests\Course2\Lesson1\TestCatalogBindingProperty; class Tester { @@ -66,10 +65,8 @@ protected static function getTestClasses() \Intervolga\Edu\Tests\Course1\Lesson11\TestSmartFilterIsExist::class, \Intervolga\Edu\Tests\Course1\Lesson11\TestPropertyInFilter::class, - \Intervolga\Edu\Tests\Course2\Lesson1\TestCatalogBindingProperty::class, - \Intervolga\Edu\Tests\Course2\Lesson1\TestPropertyPrice::class, - \Intervolga\Edu\Tests\Course2\Lesson1\TestComponentInclude::class, - \Intervolga\Edu\Tests\Course2\Lesson1\TestSlider::class, + \Intervolga\Edu\Tests\Course2\Lesson1_2\TestComponentInclude::class, + \Intervolga\Edu\Tests\Course2\Lesson1_2\TestSlider::class, \Intervolga\Edu\Tests\Course3\Lesson1\TestModule::class, \Intervolga\Edu\Tests\Course3\Lesson4\TestUf::class, diff --git a/lib/tests/course2/lesson1/testcomponentinclude.php b/lib/tests/course2/lesson1/testcomponentinclude.php deleted file mode 100644 index b70cc791..00000000 --- a/lib/tests/course2/lesson1/testcomponentinclude.php +++ /dev/null @@ -1,27 +0,0 @@ -IncludeComponent\(\s*(\'|")bitrix\:news\.list(\'|")\,\s*(\'|")slider(\'|")/i', Loc::getMessage('MAIN_HEADER_TEMPLATE_INCLUDE_COMPONENT'))); - } - - /** - * @return string|FileLocator - */ - protected static function getLocator(){ - return MainHeaderTemplate::class; - } - -} \ No newline at end of file diff --git a/lib/tests/course2/lesson1_2/testcomponentinclude.php b/lib/tests/course2/lesson1_2/testcomponentinclude.php new file mode 100644 index 00000000..b821b3cb --- /dev/null +++ b/lib/tests/course2/lesson1_2/testcomponentinclude.php @@ -0,0 +1,24 @@ +getTemplateFile()); static::testTemplate($templateDir); @@ -48,7 +48,7 @@ protected static function getComponentTemplateTree() protected static function testTemplate(ComponentTemplate $templateDir) { - Assert::fseExists(static::getLocator()::find()); + Assert::directoryLocator(static::getLocator()); Assert::fileContentMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"\%\&\;\:\.\(\)]*title[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/>/is', Loc::getMessage('INTERVOLGA_EDU.NOT_TITLE_IN_LINK_IMG'))); Assert::fileContentMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"\%\&\;\:\.\(\)]*title[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*>[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*(подробнее|Loc::getMessage)[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/a>/ius', Loc::getMessage('INTERVOLGA_EDU.NOT_TITLE_IN_LINK'))); @@ -61,13 +61,11 @@ protected static function testTemplate(ComponentTemplate $templateDir) protected static function testResultModifier(ComponentTemplate $templateDir) { Assert::fileContentMatches($templateDir->getResultModifier(), new Regex('/CFile::ResizeImageGet/i', Loc::getMessage('INTERVOLGA_EDU.NOT_FOUND_RESIZE'))); - Assert::fileContentNotMatches($templateDir->getResultModifier(), new Regex('/(foreach|while|for)[\w\s<>?=$\[\]\'"\%\&\;\:\(\)]*{[\w\s<>?=$\[\]\'"\%\&\;\:\(\)]*CIBlockElement::GetList/is', Loc::getMessage('INTERVOLGA_EDU.GET_LIST_IN_FOREACH'))); - } - protected static function testComponentEpilogFile(ComponentTemplate $templateDir) { + protected static function testComponentEpilogFile(ComponentTemplate $templateDir) + { Assert::fileContentMatches($templateDir->getComponentEpilogFile(), new Regex('/->\s*addJs\s*\([\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/js\/slides\.min\.jquery\.js/is', Loc::getMessage('INTERVOLGA_EDU.JS_NOT_FOUND_IN_COMPONENT_EPILOG'))); - } } \ No newline at end of file From 756de6cf9c18d3a2a5dcd3db0aa268e74689da5e Mon Sep 17 00:00:00 2001 From: whitelacoste Date: Thu, 22 Dec 2022 13:20:02 +0300 Subject: [PATCH 03/32] =?UTF-8?q?[IVEDU-17]=20=D1=80=D0=B5=D0=B3=D1=83?= =?UTF-8?q?=D0=BB=D1=8F=D1=80=D0=BD=D0=B0=D1=8F=20=D0=B4=D0=BB=D1=8F=20js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tests/course2/lesson1_2/testslider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tests/course2/lesson1_2/testslider.php b/lib/tests/course2/lesson1_2/testslider.php index 2f1237ee..7242bec3 100644 --- a/lib/tests/course2/lesson1_2/testslider.php +++ b/lib/tests/course2/lesson1_2/testslider.php @@ -65,7 +65,7 @@ protected static function testResultModifier(ComponentTemplate $templateDir) protected static function testComponentEpilogFile(ComponentTemplate $templateDir) { - Assert::fileContentMatches($templateDir->getComponentEpilogFile(), new Regex('/->\s*addJs\s*\([\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/js\/slides\.min\.jquery\.js/is', Loc::getMessage('INTERVOLGA_EDU.JS_NOT_FOUND_IN_COMPONENT_EPILOG'))); + Assert::fileContentMatches($templateDir->getComponentEpilogFile(), new Regex('/slides\.min\.jquery\.js/is', Loc::getMessage('INTERVOLGA_EDU.JS_NOT_FOUND_IN_COMPONENT_EPILOG'))); } } \ No newline at end of file From 5534313f553d50037ad3869949c523b793bafdc5 Mon Sep 17 00:00:00 2001 From: whitelacoste Date: Mon, 9 Jan 2023 13:58:06 +0300 Subject: [PATCH 04/32] =?UTF-8?q?[IVEDU-32]=20=D1=84=D0=B8=D0=BA=D1=81=20?= =?UTF-8?q?=D0=B1=D0=B0=D0=B3=D0=B0=20=D1=81=20=D1=83=D1=81=D0=BF=D0=B5?= =?UTF-8?q?=D1=88=D0=BD=D0=BE=D0=B9=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=BE=D0=B9=20=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82=D1=81?= =?UTF-8?q?=D1=83=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2/=D0=B4=D0=B8=D1=80=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/lib/tests/basetestcode.php | 2 ++ lib/asserts/assert.php | 18 ++++++++++++++++++ lib/tests/basetestcode.php | 1 + lib/tests/course1/lesson3/testtemplates.php | 18 ++++++++++++++---- 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 lang/ru/lib/tests/basetestcode.php diff --git a/lang/ru/lib/tests/basetestcode.php b/lang/ru/lib/tests/basetestcode.php new file mode 100644 index 00000000..2cc1179d --- /dev/null +++ b/lang/ru/lib/tests/basetestcode.php @@ -0,0 +1,2 @@ +getChildren()){ + static::registerError(static::getCustomOrLocMessage( + 'директория пуста', + [ + '#VALUE#' => Loc::getMessage('INTERVOLGA_EDU.FSE', [ + '#NAME#' => $value->getName(), + '#PATH#' => FileSystem::getLocalPath($value), + '#FILEMAN_URL#' => Admin::getFileManUrl($value), + ]), + '#NAME#' => $value->getName(), + '#PATH#' => FileSystem::getLocalPath($value), + '#FILEMAN_URL#' => Admin::getFileManUrl($value), + ], + + )); + } + } public static function directoryExists(Directory $value, string $message = '') { if (!$value->isExists()) { diff --git a/lib/tests/basetestcode.php b/lib/tests/basetestcode.php index dfdc32cc..b0b2b115 100644 --- a/lib/tests/basetestcode.php +++ b/lib/tests/basetestcode.php @@ -43,6 +43,7 @@ static function getFilesLoc(): string protected static function run() { $files = static::getFilesToTestCode(); + Assert::notEmpty($files, Loc::getMessage('INTERVOLGA_EDU.TEST_CODE_EMPTY_FILES')); foreach ($files as $file) { Assert::fseExists($file); if ($file->isExists()) { diff --git a/lib/tests/course1/lesson3/testtemplates.php b/lib/tests/course1/lesson3/testtemplates.php index 86faa043..ccda1f02 100644 --- a/lib/tests/course1/lesson3/testtemplates.php +++ b/lib/tests/course1/lesson3/testtemplates.php @@ -3,8 +3,10 @@ use Bitrix\Main\Application; use Bitrix\Main\IO\Directory; +use Bitrix\Main\Localization\Loc; use Intervolga\Edu\Asserts\Assert; use Intervolga\Edu\Tests\BaseTest; +use Intervolga\Edu\Util\FileSystem; class TestTemplates extends BaseTest { @@ -18,12 +20,20 @@ protected static function run() $templatesDirectory = new Directory(Application::getDocumentRoot() . '/local/templates/'); Assert::directoryExists($templatesDirectory); - foreach ($templatesDirectory->getChildren() as $child) { - if ($child->isDirectory()) { - if (!in_array($child->getName(), $templatesAllowed)) { - Assert::directoryNotExists($child); + Assert::directoryNotEmpty($templatesDirectory); + if ($templatesDirectory->getChildren()) { + foreach ($templatesDirectory->getChildren() as $child) { + if ($child->isDirectory()) { + if (!in_array($child->getName(), $templatesAllowed)) { + Assert::directoryNotExists($child); + } + } elseif ($child->isFile()) { + Assert::fileNotExists($child); } } + foreach ($templatesAllowed as $template){ + Assert::directoryExists(FileSystem::getDirectory('/local/templates/'.$template.'/')); + } } } } \ No newline at end of file From 2d3cda89cbcc21a2b13847d17f185631d220543a Mon Sep 17 00:00:00 2001 From: whitelacoste Date: Mon, 9 Jan 2023 15:10:01 +0300 Subject: [PATCH 05/32] =?UTF-8?q?[IVEDU-32]=20=D1=8F=D0=B7=D1=8B=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/lib/asserts/assert.php | 1 + lib/asserts/assert.php | 13 +++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lang/ru/lib/asserts/assert.php b/lang/ru/lib/asserts/assert.php index e0af5375..40dc66b4 100644 --- a/lang/ru/lib/asserts/assert.php +++ b/lang/ru/lib/asserts/assert.php @@ -19,6 +19,7 @@ $MESS['INTERVOLGA_EDU.ASSERT_FILE_CONTENT_MATCH'] = 'Файл #VALUE# не содержит #EXPECT#'; $MESS['INTERVOLGA_EDU.ASSERT_DIRECTORY_EXISTS'] = 'Папка #VALUE# не найдена'; $MESS['INTERVOLGA_EDU.ASSERT_DIRECTORY_NOT_EXISTS'] = 'Папка #VALUE# существует, должна быть удалена'; +$MESS['INTERVOLGA_EDU.ASSERT_DIRECTORY_IS_EMPTY'] = 'Директория #PATH# не должна быть пустой'; $MESS['INTERVOLGA_EDU.ASSERT_FILE_NOT_EXISTS'] = 'Файл #VALUE# существует, должен быть удален'; $MESS['INTERVOLGA_EDU.FSE'] = '#NAME#'; $MESS['INTERVOLGA_EDU.ASSERT_MODULE_INSTALLED'] = 'Модуль #VALUE# должен быть установлен'; diff --git a/lib/asserts/assert.php b/lib/asserts/assert.php index 53e04471..cbae2bab 100644 --- a/lib/asserts/assert.php +++ b/lib/asserts/assert.php @@ -451,18 +451,11 @@ public static function fileContentMatches(File $value, Regex $regex, string $mes public static function directoryNotEmpty(Directory $value, string $message = ''){ if(!$value->getChildren()){ static::registerError(static::getCustomOrLocMessage( - 'директория пуста', + 'INTERVOLGA_EDU.ASSERT_DIRECTORY_IS_EMPTY', [ - '#VALUE#' => Loc::getMessage('INTERVOLGA_EDU.FSE', [ - '#NAME#' => $value->getName(), - '#PATH#' => FileSystem::getLocalPath($value), - '#FILEMAN_URL#' => Admin::getFileManUrl($value), - ]), - '#NAME#' => $value->getName(), - '#PATH#' => FileSystem::getLocalPath($value), - '#FILEMAN_URL#' => Admin::getFileManUrl($value), + '#PATH#' => FileSystem::getLocalPath($value) ], - + $message )); } } From a062c7bb7d2b7e28366c1f235749136a5df6ca7c Mon Sep 17 00:00:00 2001 From: chernikov Date: Fri, 13 Jan 2023 15:26:16 +0300 Subject: [PATCH 06/32] =?UTF-8?q?[IVEDU-35]=20-=20=D0=9F=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=8F=D1=82=D1=8C=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=20=D1=84=D1=80=D0=B0=D0=B7=20=D0=B2=20=D1=88=D0=B0?= =?UTF-8?q?=D0=BF=D0=BA=D0=B5=20=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=B2=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=20=D0=BD=D0=B0=20=D0=B0=D0=BD=D0=B3=D0=BB=D0=B8?= =?UTF-8?q?=D0=B9=D1=81=D0=BA=D0=B8=D0=B9:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/lib/asserts/assert.php | 5 +- lib/asserts/assert.php | 102 +++++++++++++++++++++++++ lib/tester.php | 1 + lib/tests/course1/lesson3/testlang.php | 22 ++++++ 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 lib/tests/course1/lesson3/testlang.php diff --git a/lang/ru/lib/asserts/assert.php b/lang/ru/lib/asserts/assert.php index e9843a4b..8762c1df 100644 --- a/lang/ru/lib/asserts/assert.php +++ b/lang/ru/lib/asserts/assert.php @@ -38,4 +38,7 @@ $MESS['INTERVOLGA_EDU.NOT_CORRECT_MODULE_OPTION'] = 'Настройка #OPTION# модуля #MODULE# равна #NOW_VALUE# (требуется #REQUIRED_VALUE#)'; $MESS['INTERVOLGA_EDU.ASSERT_AGENT_EXISTS'] = 'Агент #NAME# не найден (#POSSIBLE#)'; $MESS['INTERVOLGA_EDU.ASSERT_EVENT_MESSAGE_EXISTS'] = 'Почтовое событие #NAME# не найдено (#POSSIBLE#)'; -$MESS['INTERVOLGA_EDU.ASSERT_EVENT_TEMPLATE_EXISTS'] = 'Почтовый шаблон #NAME# не найден (#POSSIBLE#)'; \ No newline at end of file +$MESS['INTERVOLGA_EDU.ASSERT_EVENT_TEMPLATE_EXISTS'] = 'Почтовый шаблон #NAME# не найден (#POSSIBLE#)'; +$MESS['INTERVOLGA_EDU.LANG_STRING_NOT_FOUND'] = 'Строка \'#STRING#\' не найдена в языковом файле #FILE#'; +$MESS['INTERVOLGA_EDU.EN_LANG_CODE_NOT_FOUND'] = 'Код \'#CODE#\' не найден в /en/ языковом файле #FILE#'; +$MESS['INTERVOLGA_EDU.LOC_MESSAGE_NOT_FOUND'] = 'Код \'#CODE#\' не найден в файле #FILE#'; diff --git a/lib/asserts/assert.php b/lib/asserts/assert.php index adc72c7e..1fc3266d 100644 --- a/lib/asserts/assert.php +++ b/lib/asserts/assert.php @@ -4,6 +4,7 @@ use Bitrix\Main\Config\Option; use Bitrix\Main\IO\Directory; use Bitrix\Main\IO\File; +use Bitrix\Main\IO\FileNotFoundException; use Bitrix\Main\IO\FileSystemEntry; use Bitrix\Main\Loader; use Bitrix\Main\Localization\Loc; @@ -804,6 +805,68 @@ public static function menuItemNotExists(string $menuPath, string $item, string } } + /** + * @param string $dirPath + * @param string $fileName + * @param string $string + * @param string $message + * @throws AssertException + * @throws FileNotFoundException + */ + public static function langStringExists(string $dirPath, string $fileName, string $string, string $message = '') + { + $ruLang = FileSystem::getFile($dirPath . "/lang/ru/" . $fileName); + $code = static::getLangCodeByValue($ruLang, $string); + if (!$code) { + static::registerError( + static::getCustomOrLocMessage( + 'INTERVOLGA_EDU.LANG_STRING_NOT_FOUND', + [ + '#STRING#' => $string, + '#FILE#' => Loc::getMessage('INTERVOLGA_EDU.FSE', [ + '#NAME#' => $ruLang->getDirectoryName() . '/' . $fileName, + '#FILEMAN_URL#' => Admin::getFileManUrl($ruLang), + ]), + ], + $message + )); + + return; + } + $enLang = FileSystem::getFile($dirPath . "/lang/en/" . $fileName); + if (!static::langCodeExists($enLang, $code)) { + static::registerError( + static::getCustomOrLocMessage( + 'INTERVOLGA_EDU.EN_LANG_CODE_NOT_FOUND', + [ + '#CODE#' => $code, + '#FILE#' => Loc::getMessage('INTERVOLGA_EDU.FSE', [ + '#NAME#' => $enLang->getDirectoryName() . '/' . $fileName, + '#FILEMAN_URL#' => Admin::getFileManUrl($enLang), + ]), + ], + $message + )); + + return; + } + $file = FileSystem::getFile($dirPath . '/' . $fileName); + if (!static::codeInFileExists($file, $code)) { + static::registerError( + static::getCustomOrLocMessage( + 'INTERVOLGA_EDU.LOC_MESSAGE_NOT_FOUND', + [ + '#CODE#' => $code, + '#FILE#' => Loc::getMessage('INTERVOLGA_EDU.FSE', [ + '#NAME#' => $file->getDirectoryName() . '/' . $fileName, + '#FILEMAN_URL#' => Admin::getFileManUrl($file), + ]), + ], + $message + )); + } + } + /** * @param string $message * @throws AssertException @@ -847,6 +910,45 @@ protected static function getStringFromArray($separator, $array, $endString = "< return $result; } + /** + * @param File $file + * @param string $value + * @return string|null + * @throws FileNotFoundException + */ + protected static function getLangCodeByValue(File $file, string $value): ?string + { + $fileContent = $file->getContents(); + $regex = new Regex('/\$MESS\[[\'|\"](.*)[\'|\"]\]\s=\s[\'|\"]' . $value . '[\'|\"];/mui', + '$MESS["INTERVOLGA.CONTACT"] = "Contact information:";'); + $res = preg_match($regex->getRegex(), $fileContent, $output); + if ($res) { + return $output[1]; + } + + return null; + } + + /** + * @throws FileNotFoundException + */ + protected static function langCodeExists(File $file, string $code): bool + { + $fileContent = $file->getContents(); + + return preg_match('/\$MESS\[[\'|\"]' . $code . '[\'|\"]\]/m', $fileContent); + } + + /** + * @throws FileNotFoundException + */ + protected static function codeInFileExists(File $file, string $code): bool + { + $fileContent = $file->getContents(); + + return preg_match('/Loc::getMessage\([\'|\"]' . $code . '[\'|\"]\)/m', $fileContent); + } + /** * @param string|BaseLocator $parentLocatorClass * @param string|BaseLocator $locatorClass diff --git a/lib/tester.php b/lib/tester.php index cf2cfcc9..4165b81a 100644 --- a/lib/tester.php +++ b/lib/tester.php @@ -40,6 +40,7 @@ protected static function getTestClasses() \Intervolga\Edu\Tests\Course1\Lesson3\TestTemplates::class, \Intervolga\Edu\Tests\Course1\Lesson3\TestCode::class, \Intervolga\Edu\Tests\Course1\Lesson3\TestOption::class, + \Intervolga\Edu\Tests\Course1\Lesson3\TestLang::class, \Intervolga\Edu\Tests\Course1\Lesson3\TestScripts::class, \Intervolga\Edu\Tests\Course1\Lesson41\TestIncludeArea::class, diff --git a/lib/tests/course1/lesson3/testlang.php b/lib/tests/course1/lesson3/testlang.php new file mode 100644 index 00000000..52adaddd --- /dev/null +++ b/lib/tests/course1/lesson3/testlang.php @@ -0,0 +1,22 @@ + Date: Fri, 13 Jan 2023 15:29:56 +0300 Subject: [PATCH 07/32] =?UTF-8?q?[IVEDU-35]=20-=20=D0=9F=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=8F=D1=82=D1=8C=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=20=D1=84=D1=80=D0=B0=D0=B7=20=D0=B2=20=D1=88=D0=B0?= =?UTF-8?q?=D0=BF=D0=BA=D0=B5=20=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=B2=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=20=D0=BD=D0=B0=20=D0=B0=D0=BD=D0=B3=D0=BB=D0=B8?= =?UTF-8?q?=D0=B9=D1=81=D0=BA=D0=B8=D0=B9:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/include.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lang/ru/include.php b/lang/ru/include.php index fd7cbe86..ad54b6a0 100644 --- a/lang/ru/include.php +++ b/lang/ru/include.php @@ -58,6 +58,8 @@ $MESS['INTERVOLGA_EDU.COURSE1_LESSON3_SCRIPTS_DESCRIPTION'] = 'Плагины слайдера и карусели должны подключаться только в main-шаблоне'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON3_OPTION'] = 'Проверка настроек JS и CSS главного модуля'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON3_OPTION_DESCRIPTION'] = 'Требуется включить настройки Объединять CSS файлы, Объединять JS файлы, Создавать сжатую копию объединенных CSS и JS файлов'; +$MESS['INTERVOLGA_EDU.COURSE1_LESSON3_LANG'] = 'Проверка lang кодов'; +$MESS['INTERVOLGA_EDU.COURSE1_LESSON3_LANG_DESCRIPTION'] = 'Требуется использовать языковые коды для строк из задания'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_SMARTFILTERISEXIST'] = 'Проверка на наличие включенного фильтра'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_SMARTFILTERISEXIST_DESCRIPTION'] = 'В компоненте каталог должен быть включен фильтр'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_PROPERTYISEXIST'] = 'Проверка на наличие свойства'; From 644e59d6d3b6504c2aee22610a8c844bd7e4f0e2 Mon Sep 17 00:00:00 2001 From: liliya Date: Mon, 16 Jan 2023 00:29:31 +0300 Subject: [PATCH 08/32] =?UTF-8?q?[IVEDU-11]=20=D1=81=D0=BD=D0=B8=D1=84?= =?UTF-8?q?=D1=84=D0=B5=D1=80=20=D0=BF=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D1=8B=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/sniffer.php | 4 +- lib/sniffer/message.php | 8 +++ .../php/LangArrayFromTemplateDirSniff.php | 39 +++++++++++ .../langArrayFromTemplateDir/ruleset.xml | 6 ++ .../Sniffs/php/ArrayLangVariableSniff.php | 33 ++++++++++ lib/sniffer/standards/langFiles/ruleset.xml | 6 ++ lib/tests/basecomponenttemplatetest.php | 65 +++++++++++++++++++ 7 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php create mode 100644 lib/sniffer/standards/langArrayFromTemplateDir/ruleset.xml create mode 100644 lib/sniffer/standards/langFiles/Sniffs/php/ArrayLangVariableSniff.php create mode 100644 lib/sniffer/standards/langFiles/ruleset.xml diff --git a/lib/sniffer.php b/lib/sniffer.php index 4ae7b66d..9e6ef174 100644 --- a/lib/sniffer.php +++ b/lib/sniffer.php @@ -13,10 +13,10 @@ class Sniffer * @param string[] $paths * @return Message[] */ - public static function run(array $paths) + public static function run(array $paths, array $standartName) { $result = []; - $standards = StandardsTools::getStandardPathByNames(['general']); + $standards = StandardsTools::getStandardPathByNames($standartName); $config = ConfigTools::makeConfig($standards, $paths); $runner = new Runner($config); diff --git a/lib/sniffer/message.php b/lib/sniffer/message.php index 4cb7f915..c5dff633 100644 --- a/lib/sniffer/message.php +++ b/lib/sniffer/message.php @@ -21,4 +21,12 @@ public function __construct($file, $line, $column, $message, $code) $this->message = $message; $this->code = $code; } + + /** + * @return string + */ + public function getMessage(): string + { + return $this->message; + } } diff --git a/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php b/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php new file mode 100644 index 00000000..cf5b4d16 --- /dev/null +++ b/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php @@ -0,0 +1,39 @@ +getTokens(); + $token = $tokens[$stackPtr]; + + /*foreach ($tokens as $token){ + \Bitrix\Main\Diag\Debug::dump($token['type']); + \Bitrix\Main\Diag\Debug::dump($token['content']); + }*/ + + //Loc::getMessage("T_NEWS_DETAIL_BACK") + + if (strtolower($token['content']) === 'getmessage') { + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if($tokens[$nextToken]['type'] === 'T_OPEN_PARENTHESIS'){ + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true); + if($tokens[$nextToken]['type'] === 'T_CONSTANT_ENCAPSED_STRING'){ + $error = $tokens[$nextToken]['content']; + $phpcsFile->addError($error, $stackPtr, 'A1CheckArPrefix'); + } + + } + } + } +} \ No newline at end of file diff --git a/lib/sniffer/standards/langArrayFromTemplateDir/ruleset.xml b/lib/sniffer/standards/langArrayFromTemplateDir/ruleset.xml new file mode 100644 index 00000000..d6082b64 --- /dev/null +++ b/lib/sniffer/standards/langArrayFromTemplateDir/ruleset.xml @@ -0,0 +1,6 @@ + + + General custom coding standard. + diff --git a/lib/sniffer/standards/langFiles/Sniffs/php/ArrayLangVariableSniff.php b/lib/sniffer/standards/langFiles/Sniffs/php/ArrayLangVariableSniff.php new file mode 100644 index 00000000..2a5abc7d --- /dev/null +++ b/lib/sniffer/standards/langFiles/Sniffs/php/ArrayLangVariableSniff.php @@ -0,0 +1,33 @@ +getTokens(); + $token = $tokens[$stackPtr]; + + /*foreach ($tokens as $token){ + \Bitrix\Main\Diag\Debug::dump($token['type']); + \Bitrix\Main\Diag\Debug::dump($token['content']); + }*/ + + if ($token['type'] === 'T_OPEN_SQUARE_BRACKET') { + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if($tokens[$nextToken]['type'] === 'T_CONSTANT_ENCAPSED_STRING'){ + $error = $tokens[$nextToken]['content']; + $phpcsFile->addError($error, $stackPtr, 'A1CheckArPrefix'); + } + } + } +} \ No newline at end of file diff --git a/lib/sniffer/standards/langFiles/ruleset.xml b/lib/sniffer/standards/langFiles/ruleset.xml new file mode 100644 index 00000000..2b2a8812 --- /dev/null +++ b/lib/sniffer/standards/langFiles/ruleset.xml @@ -0,0 +1,6 @@ + + + General custom coding standard. + diff --git a/lib/tests/basecomponenttemplatetest.php b/lib/tests/basecomponenttemplatetest.php index 33826540..1bf99634 100644 --- a/lib/tests/basecomponenttemplatetest.php +++ b/lib/tests/basecomponenttemplatetest.php @@ -8,6 +8,8 @@ use Intervolga\Edu\FilesTree\NewsTemplate; use Intervolga\Edu\FilesTree\SimpleComponentTemplate; use Intervolga\Edu\Locator\IO\DirectoryLocator; +use Intervolga\Edu\Util\Regex; +use Intervolga\Edu\Sniffer as NewSniff; use Intervolga\Edu\Util\Sniffer; abstract class BaseComponentTemplateTest extends BaseTest @@ -94,9 +96,72 @@ protected static function testTemplateLangRuTrash(ComponentTemplate $templateDir $templateDir->getDetailFile()->getName() ])) { Assert::fseNotExists($child); + } else { + static::testTemplateLangRu($templateDir, $child); } } } } } + + /*protected static function testTemplateLangRuCode(ComponentTemplate $templateDir){ + if ($templateDir->getLangRuDir()->isExists()) { + foreach ($templateDir->getLangRuDir()->getChildren() as $child) { + if ($child->getName() == $templateDir->getDescriptionFile()->getName()) { + Assert::fseNotExists($child); + } elseif ($child->getName() == $templateDir->getParametersFile()->getName()) { + Assert::fseNotExists($child); + } elseif ($templateDir instanceof SimpleComponentTemplate) { + if ($child->getName() != $templateDir->getTemplateFile()) { + Assert::fseNotExists($child); + } + } elseif ($templateDir instanceof NewsTemplate) { + if (!in_array($child->getName(), [ + $templateDir->getNewsFile()->getName(), + $templateDir->getDetailFile()->getName() + ])) { + Assert::fseNotExists($child); + } else { + static::testTemplateLangRu($templateDir, $child); + } + } + } + } + }*/ + + protected static function getLangArrayTemplateDir(ComponentTemplate $templateDir) + { + foreach ($templateDir->getKnownFiles() as $template) { + + $result = NewSniff::run([$template->getPath()], ['langArrayFromTemplateDir']); + + foreach ($result as $message) { + $newTest[$template->getName()] = mb_strcut($message->getMessage(), 1, -1); + + } + } + + \Bitrix\Main\Diag\Debug::dump($newTest); + return $newTest; + } + + protected static function testTemplateLangRu(ComponentTemplate $templateDir, $child) + { + + $result = NewSniff::run([$child->getPath()], ['langFiles']); + + $test = static::getLangArrayTemplateDir($templateDir); + + foreach ($result as $message) { + + $langNames[$child->getName()][] = $message->getMessage(); + $tester = mb_strcut($message->getMessage(), 1, -1); + + if (!in_array($tester, $test)) { + \Bitrix\Main\Diag\Debug::dump($tester); + //\Bitrix\Main\Diag\Debug::dump($test); + } + } + + } } \ No newline at end of file From e271a7ff274c1624c202e96fb8499cebec3012c8 Mon Sep 17 00:00:00 2001 From: liliya Date: Mon, 16 Jan 2023 11:16:22 +0300 Subject: [PATCH 09/32] =?UTF-8?q?[IVEDU-11]=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B0=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D1=85?= =?UTF-8?q?=20=D1=8F=D0=B7=D1=8B=D0=BA=D0=BE=D0=B2=D1=8B=D1=85=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20=D1=87?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B7=20=D1=81=D0=BD=D0=B8=D1=84=D1=84=D0=B5?= =?UTF-8?q?=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/tests/basecomponenttemplatetest.php | 2 + lib/sniffer.php | 2 +- .../Sniffs/php/LangArrayFromLangDirSniff.php} | 17 ++++---- .../ruleset.xml | 2 +- .../php/LangArrayFromTemplateDirSniff.php | 21 +++++----- lib/tests/basecomponenttemplatetest.php | 42 ++++++------------- 6 files changed, 34 insertions(+), 52 deletions(-) create mode 100644 lang/ru/lib/tests/basecomponenttemplatetest.php rename lib/sniffer/standards/{langFiles/Sniffs/php/ArrayLangVariableSniff.php => langArrayFromLangDir/Sniffs/php/LangArrayFromLangDirSniff.php} (66%) rename lib/sniffer/standards/{langFiles => langArrayFromLangDir}/ruleset.xml (87%) diff --git a/lang/ru/lib/tests/basecomponenttemplatetest.php b/lang/ru/lib/tests/basecomponenttemplatetest.php new file mode 100644 index 00000000..898d8584 --- /dev/null +++ b/lang/ru/lib/tests/basecomponenttemplatetest.php @@ -0,0 +1,2 @@ +#VALUE#'; \ No newline at end of file diff --git a/lib/sniffer.php b/lib/sniffer.php index 9e6ef174..db7671d2 100644 --- a/lib/sniffer.php +++ b/lib/sniffer.php @@ -13,7 +13,7 @@ class Sniffer * @param string[] $paths * @return Message[] */ - public static function run(array $paths, array $standartName) + public static function run(array $paths, array $standartName = ['general']) { $result = []; $standards = StandardsTools::getStandardPathByNames($standartName); diff --git a/lib/sniffer/standards/langFiles/Sniffs/php/ArrayLangVariableSniff.php b/lib/sniffer/standards/langArrayFromLangDir/Sniffs/php/LangArrayFromLangDirSniff.php similarity index 66% rename from lib/sniffer/standards/langFiles/Sniffs/php/ArrayLangVariableSniff.php rename to lib/sniffer/standards/langArrayFromLangDir/Sniffs/php/LangArrayFromLangDirSniff.php index 2a5abc7d..efc55208 100644 --- a/lib/sniffer/standards/langFiles/Sniffs/php/ArrayLangVariableSniff.php +++ b/lib/sniffer/standards/langArrayFromLangDir/Sniffs/php/LangArrayFromLangDirSniff.php @@ -1,15 +1,19 @@ getTokens(); $token = $tokens[$stackPtr]; - /*foreach ($tokens as $token){ - \Bitrix\Main\Diag\Debug::dump($token['type']); - \Bitrix\Main\Diag\Debug::dump($token['content']); - }*/ - if ($token['type'] === 'T_OPEN_SQUARE_BRACKET') { $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if($tokens[$nextToken]['type'] === 'T_CONSTANT_ENCAPSED_STRING'){ + if ($tokens[$nextToken]['type'] === 'T_CONSTANT_ENCAPSED_STRING') { $error = $tokens[$nextToken]['content']; $phpcsFile->addError($error, $stackPtr, 'A1CheckArPrefix'); } diff --git a/lib/sniffer/standards/langFiles/ruleset.xml b/lib/sniffer/standards/langArrayFromLangDir/ruleset.xml similarity index 87% rename from lib/sniffer/standards/langFiles/ruleset.xml rename to lib/sniffer/standards/langArrayFromLangDir/ruleset.xml index 2b2a8812..2063931d 100644 --- a/lib/sniffer/standards/langFiles/ruleset.xml +++ b/lib/sniffer/standards/langArrayFromLangDir/ruleset.xml @@ -1,6 +1,6 @@ General custom coding standard. diff --git a/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php b/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php index cf5b4d16..364b824e 100644 --- a/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php +++ b/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php @@ -1,15 +1,21 @@ getTokens(); $token = $tokens[$stackPtr]; - /*foreach ($tokens as $token){ - \Bitrix\Main\Diag\Debug::dump($token['type']); - \Bitrix\Main\Diag\Debug::dump($token['content']); - }*/ - - //Loc::getMessage("T_NEWS_DETAIL_BACK") - if (strtolower($token['content']) === 'getmessage') { $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if($tokens[$nextToken]['type'] === 'T_OPEN_PARENTHESIS'){ + if ($tokens[$nextToken]['type'] === 'T_OPEN_PARENTHESIS') { $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true); - if($tokens[$nextToken]['type'] === 'T_CONSTANT_ENCAPSED_STRING'){ + if ($tokens[$nextToken]['type'] === 'T_CONSTANT_ENCAPSED_STRING') { $error = $tokens[$nextToken]['content']; $phpcsFile->addError($error, $stackPtr, 'A1CheckArPrefix'); } diff --git a/lib/tests/basecomponenttemplatetest.php b/lib/tests/basecomponenttemplatetest.php index 1bf99634..27774a67 100644 --- a/lib/tests/basecomponenttemplatetest.php +++ b/lib/tests/basecomponenttemplatetest.php @@ -8,6 +8,8 @@ use Intervolga\Edu\FilesTree\NewsTemplate; use Intervolga\Edu\FilesTree\SimpleComponentTemplate; use Intervolga\Edu\Locator\IO\DirectoryLocator; +use Intervolga\Edu\Util\Admin; +use Intervolga\Edu\Util\FileSystem; use Intervolga\Edu\Util\Regex; use Intervolga\Edu\Sniffer as NewSniff; use Intervolga\Edu\Util\Sniffer; @@ -104,31 +106,6 @@ protected static function testTemplateLangRuTrash(ComponentTemplate $templateDir } } - /*protected static function testTemplateLangRuCode(ComponentTemplate $templateDir){ - if ($templateDir->getLangRuDir()->isExists()) { - foreach ($templateDir->getLangRuDir()->getChildren() as $child) { - if ($child->getName() == $templateDir->getDescriptionFile()->getName()) { - Assert::fseNotExists($child); - } elseif ($child->getName() == $templateDir->getParametersFile()->getName()) { - Assert::fseNotExists($child); - } elseif ($templateDir instanceof SimpleComponentTemplate) { - if ($child->getName() != $templateDir->getTemplateFile()) { - Assert::fseNotExists($child); - } - } elseif ($templateDir instanceof NewsTemplate) { - if (!in_array($child->getName(), [ - $templateDir->getNewsFile()->getName(), - $templateDir->getDetailFile()->getName() - ])) { - Assert::fseNotExists($child); - } else { - static::testTemplateLangRu($templateDir, $child); - } - } - } - } - }*/ - protected static function getLangArrayTemplateDir(ComponentTemplate $templateDir) { foreach ($templateDir->getKnownFiles() as $template) { @@ -136,19 +113,18 @@ protected static function getLangArrayTemplateDir(ComponentTemplate $templateDir $result = NewSniff::run([$template->getPath()], ['langArrayFromTemplateDir']); foreach ($result as $message) { - $newTest[$template->getName()] = mb_strcut($message->getMessage(), 1, -1); + $newTest[] = mb_strcut($message->getMessage(), 1, -1); } } - \Bitrix\Main\Diag\Debug::dump($newTest); return $newTest; } protected static function testTemplateLangRu(ComponentTemplate $templateDir, $child) { - $result = NewSniff::run([$child->getPath()], ['langFiles']); + $result = NewSniff::run([$child->getPath()], ['langArrayFromLangDir']); $test = static::getLangArrayTemplateDir($templateDir); @@ -158,8 +134,14 @@ protected static function testTemplateLangRu(ComponentTemplate $templateDir, $ch $tester = mb_strcut($message->getMessage(), 1, -1); if (!in_array($tester, $test)) { - \Bitrix\Main\Diag\Debug::dump($tester); - //\Bitrix\Main\Diag\Debug::dump($test); + Assert::empty($tester, Loc::getMessage('INTERVOLGA_EDU.SNIFFER_CHECK_LANG_CODE', [ + '#FILE#' => Loc::getMessage('INTERVOLGA_EDU.FSE', [ + '#NAME#' => $child->getName(), + '#PATH#' => FileSystem::getLocalPath($child), + '#FILEMAN_URL#' => Admin::getFileManUrl($child), + ]), + '#VALUE#' => $tester + ])); } } From 3b6806d4604a2f88e01bd46b45d2074bd86333fb Mon Sep 17 00:00:00 2001 From: liliya Date: Sun, 29 Jan 2023 20:25:09 +0300 Subject: [PATCH 10/32] =?UTF-8?q?[IVEDU-11]=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D0=BC=D1=80-?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/tests/basecomponenttemplatetest.php | 2 +- .../Sniffs/php/LangDefinitionSniff.php} | 5 ++--- .../ruleset.xml | 2 +- .../Sniffs/php/LangUsageSniff.php} | 7 ++----- .../ruleset.xml | 2 +- lib/tests/basecomponenttemplatetest.php | 21 ++++++------------- 6 files changed, 13 insertions(+), 26 deletions(-) rename lib/sniffer/standards/{langArrayFromLangDir/Sniffs/php/LangArrayFromLangDirSniff.php => langDefinition/Sniffs/php/LangDefinitionSniff.php} (84%) rename lib/sniffer/standards/{langArrayFromLangDir => langDefinition}/ruleset.xml (87%) rename lib/sniffer/standards/{langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php => langUsage/Sniffs/php/LangUsageSniff.php} (81%) rename lib/sniffer/standards/{langArrayFromTemplateDir => langUsage}/ruleset.xml (86%) diff --git a/lang/ru/lib/tests/basecomponenttemplatetest.php b/lang/ru/lib/tests/basecomponenttemplatetest.php index 898d8584..4b8d2125 100644 --- a/lang/ru/lib/tests/basecomponenttemplatetest.php +++ b/lang/ru/lib/tests/basecomponenttemplatetest.php @@ -1,2 +1,2 @@ #VALUE#'; \ No newline at end of file +$MESS['INTERVOLGA_EDU.SNIFFER_CHECK_LANG_CODE'] = 'В файле #FILE# присутствует лишняя языковая переменная #VALUE# '; \ No newline at end of file diff --git a/lib/sniffer/standards/langArrayFromLangDir/Sniffs/php/LangArrayFromLangDirSniff.php b/lib/sniffer/standards/langDefinition/Sniffs/php/LangDefinitionSniff.php similarity index 84% rename from lib/sniffer/standards/langArrayFromLangDir/Sniffs/php/LangArrayFromLangDirSniff.php rename to lib/sniffer/standards/langDefinition/Sniffs/php/LangDefinitionSniff.php index efc55208..5c090a90 100644 --- a/lib/sniffer/standards/langArrayFromLangDir/Sniffs/php/LangArrayFromLangDirSniff.php +++ b/lib/sniffer/standards/langDefinition/Sniffs/php/LangDefinitionSniff.php @@ -6,13 +6,12 @@ Loc::loadMessages(__FILE__); -class LangArrayFromLangDirSniff implements Sniff +class LangDefinitionSniff implements Sniff { public function register() { return [ T_OPEN_SQUARE_BRACKET, - T_STRING ]; } @@ -25,7 +24,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr) $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($tokens[$nextToken]['type'] === 'T_CONSTANT_ENCAPSED_STRING') { $error = $tokens[$nextToken]['content']; - $phpcsFile->addError($error, $stackPtr, 'A1CheckArPrefix'); + $phpcsFile->addError($error, $stackPtr, 'langDefinition'); } } } diff --git a/lib/sniffer/standards/langArrayFromLangDir/ruleset.xml b/lib/sniffer/standards/langDefinition/ruleset.xml similarity index 87% rename from lib/sniffer/standards/langArrayFromLangDir/ruleset.xml rename to lib/sniffer/standards/langDefinition/ruleset.xml index 2063931d..e58a1f7a 100644 --- a/lib/sniffer/standards/langArrayFromLangDir/ruleset.xml +++ b/lib/sniffer/standards/langDefinition/ruleset.xml @@ -1,6 +1,6 @@ General custom coding standard. diff --git a/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php b/lib/sniffer/standards/langUsage/Sniffs/php/LangUsageSniff.php similarity index 81% rename from lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php rename to lib/sniffer/standards/langUsage/Sniffs/php/LangUsageSniff.php index 364b824e..edb20f73 100644 --- a/lib/sniffer/standards/langArrayFromTemplateDir/Sniffs/php/LangArrayFromTemplateDirSniff.php +++ b/lib/sniffer/standards/langUsage/Sniffs/php/LangUsageSniff.php @@ -6,15 +6,12 @@ Loc::loadMessages(__FILE__); -class LangArrayFromTemplateDirSniff implements Sniff +class LangUsageSniff implements Sniff { public function register() { return [ - T_DOUBLE_COLON, T_STRING, - T_OPEN_PARENTHESIS, - T_CONSTANT_ENCAPSED_STRING ]; } @@ -29,7 +26,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr) $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true); if ($tokens[$nextToken]['type'] === 'T_CONSTANT_ENCAPSED_STRING') { $error = $tokens[$nextToken]['content']; - $phpcsFile->addError($error, $stackPtr, 'A1CheckArPrefix'); + $phpcsFile->addError($error, $stackPtr, 'LangUsageSniff'); } } diff --git a/lib/sniffer/standards/langArrayFromTemplateDir/ruleset.xml b/lib/sniffer/standards/langUsage/ruleset.xml similarity index 86% rename from lib/sniffer/standards/langArrayFromTemplateDir/ruleset.xml rename to lib/sniffer/standards/langUsage/ruleset.xml index d6082b64..b311080b 100644 --- a/lib/sniffer/standards/langArrayFromTemplateDir/ruleset.xml +++ b/lib/sniffer/standards/langUsage/ruleset.xml @@ -1,6 +1,6 @@ General custom coding standard. diff --git a/lib/tests/basecomponenttemplatetest.php b/lib/tests/basecomponenttemplatetest.php index 27774a67..46c5a187 100644 --- a/lib/tests/basecomponenttemplatetest.php +++ b/lib/tests/basecomponenttemplatetest.php @@ -10,9 +10,8 @@ use Intervolga\Edu\Locator\IO\DirectoryLocator; use Intervolga\Edu\Util\Admin; use Intervolga\Edu\Util\FileSystem; -use Intervolga\Edu\Util\Regex; -use Intervolga\Edu\Sniffer as NewSniff; -use Intervolga\Edu\Util\Sniffer; +use Intervolga\Edu\Sniffer; +use Intervolga\Edu\Util\Sniffer as OldSniffer; abstract class BaseComponentTemplateTest extends BaseTest { @@ -61,7 +60,7 @@ protected static function testTemplateCode(ComponentTemplate $templateDir) foreach ($templateDir->getKnownPhpFiles() as $knownPhpFile) { if ($knownPhpFile->isExists()) { AssertPhp::goodCode($knownPhpFile); - Sniffer::testTemplateFile($knownPhpFile); + OldSniffer::testTemplateFile($knownPhpFile); } } } @@ -109,12 +108,9 @@ protected static function testTemplateLangRuTrash(ComponentTemplate $templateDir protected static function getLangArrayTemplateDir(ComponentTemplate $templateDir) { foreach ($templateDir->getKnownFiles() as $template) { - - $result = NewSniff::run([$template->getPath()], ['langArrayFromTemplateDir']); - + $result = Sniffer::run([$template->getPath()], ['langUsage']); foreach ($result as $message) { $newTest[] = mb_strcut($message->getMessage(), 1, -1); - } } @@ -123,18 +119,13 @@ protected static function getLangArrayTemplateDir(ComponentTemplate $templateDir protected static function testTemplateLangRu(ComponentTemplate $templateDir, $child) { - - $result = NewSniff::run([$child->getPath()], ['langArrayFromLangDir']); - + $result = Sniffer::run([$child->getPath()], ['langDefinition']); $test = static::getLangArrayTemplateDir($templateDir); - foreach ($result as $message) { - $langNames[$child->getName()][] = $message->getMessage(); $tester = mb_strcut($message->getMessage(), 1, -1); - if (!in_array($tester, $test)) { - Assert::empty($tester, Loc::getMessage('INTERVOLGA_EDU.SNIFFER_CHECK_LANG_CODE', [ + Assert::true($tester, Loc::getMessage('INTERVOLGA_EDU.SNIFFER_CHECK_LANG_CODE', [ '#FILE#' => Loc::getMessage('INTERVOLGA_EDU.FSE', [ '#NAME#' => $child->getName(), '#PATH#' => FileSystem::getLocalPath($child), From 3fafb0c5146428b100e11f31a89e62929c6f83a0 Mon Sep 17 00:00:00 2001 From: liliya Date: Sun, 29 Jan 2023 20:40:29 +0300 Subject: [PATCH 11/32] =?UTF-8?q?[IVEDU-11]=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B0=20=D0=BD=D0=B0=20=D1=81=D1=83=D1=89?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B2=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=B4=D0=B0=D1=80=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/sniffer/runner.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sniffer/runner.php b/lib/sniffer/runner.php index 6e6af64e..1670c85d 100644 --- a/lib/sniffer/runner.php +++ b/lib/sniffer/runner.php @@ -1,7 +1,7 @@ config->standards as $standard) { if (Standards::isInstalledStandard($standard) === false) { - $error = 'ERROR: the "' . $standard . '" coding standard is not installed. '; - throw new DeepExitException($error, 3); + $error = 'Ошибка модуля : стандарт "' . $standard . '" не найден.'; + throw new AssertException($error); } } From 3e992c122739c97e2856e3bf66721396a4fdeff7 Mon Sep 17 00:00:00 2001 From: liliya Date: Sun, 19 Feb 2023 12:59:27 +0300 Subject: [PATCH 12/32] =?UTF-8?q?[IVEDU-24]=20=D0=9F=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B0=20robots.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/include.php | 4 ++++ .../courseintervolga/lesson1/robotschecker.php | 3 +++ lib/tester.php | 2 ++ .../courseintervolga/lesson1/robotschecker.php | 18 ++++++++++++++++++ options.php | 5 ++--- 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php create mode 100644 lib/tests/courseintervolga/lesson1/robotschecker.php diff --git a/lang/ru/include.php b/lang/ru/include.php index 0f12085c..09b8e304 100644 --- a/lang/ru/include.php +++ b/lang/ru/include.php @@ -3,6 +3,7 @@ $MESS['INTERVOLGA_EDU.COURSE2'] = '2. Основные технологии и расширение типовых возможностей системы'; $MESS['INTERVOLGA_EDU.COURSE3'] = '3. Расширенные технологии и производительность'; $MESS['INTERVOLGA_EDU.COURSE4'] = '4. Разработка на D7. Введение'; +$MESS['INTERVOLGA_EDU.COURSEINTERVOLGA'] = '5. Проверки ИНТЕРВОЛГИ'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON1'] = '1. Установка платформы'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON2'] = '2. Структура Bitrix Framework'; @@ -27,6 +28,7 @@ $MESS['INTERVOLGA_EDU.COURSE3_LESSON4'] = '4. Пользовательские поля и типы'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON5'] = '5. JS'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON8'] = '8. Монитор качества'; +$MESS['INTERVOLGA_EDU.COURSEINTERVOLGA_LESSON1'] = '1. Поисковая оптимизация'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON1_SITECORPORATEMODULE'] = 'Проверка установки модуля «Корпоративный сайт производственной компании»'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON1_SITECORPORATEMODULE_DESCRIPTION'] = 'Модуль должен быть зарегистрирован в системе и установлен'; @@ -179,6 +181,8 @@ $MESS['INTERVOLGA_EDU.COURSE3_LESSON8_USERTESTEXISTS'] = 'Проверка 2-ух собственных тестов в мониторе качества'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON8_USERTESTEXISTS_DESCRIPTION'] = 'Должно быть создано 2 пользовательских теста и они должны быть выполнены в Мониторе качества'; +$MESS['INTERVOLGA_EDU.COURSEINTERVOLGA_LESSON1_ROBOTSCHECKER'] = 'Проверка robots.txt'; +$MESS['INTERVOLGA_EDU.COURSEINTERVOLGA_LESSON1_ROBOTSCHECKER_DESCRIPTION'] = 'Файл robots.txt должен существовать, быть заполнен'; $MESS['INTERVOLGA_EDU.TEST_CODE_NAME'] = 'Проверка кода #FILES#'; $MESS['INTERVOLGA_EDU.TEST_CODE_DESCRIPTION'] = 'Современная проверка ядра Битрикса, использование длинных php-тегов, запрет на устаревшие функции'; diff --git a/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php b/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php new file mode 100644 index 00000000..37b21a32 --- /dev/null +++ b/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php @@ -0,0 +1,3 @@ +Создать'; +$MESS['INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_MATCH'] = 'Фвйл robots.txt должен содержать:
User-agent: *
Disallow: /'; \ No newline at end of file diff --git a/lib/tester.php b/lib/tester.php index f0d1828a..2f70ba79 100644 --- a/lib/tester.php +++ b/lib/tester.php @@ -130,6 +130,8 @@ protected static function getTestClasses() \Intervolga\Edu\Tests\Course3\Lesson8\TestAcceptedTests::class, \Intervolga\Edu\Tests\Course3\Lesson8\TestThisSiteSupport::class, \Intervolga\Edu\Tests\Course3\Lesson8\TestUserTestExists::class, + + \Intervolga\Edu\Tests\CourseIntervolga\Lesson1\RobotsChecker::class, ]; } diff --git a/lib/tests/courseintervolga/lesson1/robotschecker.php b/lib/tests/courseintervolga/lesson1/robotschecker.php new file mode 100644 index 00000000..aa59f3d3 --- /dev/null +++ b/lib/tests/courseintervolga/lesson1/robotschecker.php @@ -0,0 +1,18 @@ +isExists(), Loc::getMessage('INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_FOUND')); + Assert::fileContentMatches($robotsFile, new Regex ('/User-agent:\s\*\s*Disallow:\s\//i', ''), Loc::getMessage('INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_MATCH')); + } +} \ No newline at end of file diff --git a/options.php b/options.php index 3c76319e..b5abb770 100644 --- a/options.php +++ b/options.php @@ -92,12 +92,12 @@ } } $tabs = []; -$courseNum = 1; + foreach ($testsTree as $courseCode => $course) { $tabs[] = [ 'DIV' => $courseCode, 'TAB' => Loc::getMessage('INTERVOLGA_EDU.COURSE_TAB_HEADER', [ - '#NUM#' => $courseNum, + '#NUM#' => str_replace('course', '', $courseCode), '#DONE#' => $stat[$courseCode]['DONE'], '#TOTAL#' => count($course['LESSONS']), ] @@ -110,7 +110,6 @@ ), 'ONSELECT' => 'intervolgaEduOnTabChanged("' . $courseCode . '");', ]; - $courseNum++; } $tabs[] = [ 'DIV' => 'info', From 8e35ceae93daf68243fc99bd121c78243f4d35f1 Mon Sep 17 00:00:00 2001 From: liliya Date: Sun, 19 Feb 2023 13:48:35 +0300 Subject: [PATCH 13/32] =?UTF-8?q?[IVEDU-23]=20=D0=9F=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B0=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include.php | 12 +++++ lang/ru/include.php | 3 ++ .../courseintervolga/lesson2/modulescheck.php | 3 ++ lib/tester.php | 2 + .../courseintervolga/lesson2/modulescheck.php | 53 +++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 lang/ru/lib/tests/courseintervolga/lesson2/modulescheck.php create mode 100644 lib/tests/courseintervolga/lesson2/modulescheck.php diff --git a/include.php b/include.php index 43c70a32..150582e0 100644 --- a/include.php +++ b/include.php @@ -32,4 +32,16 @@ 'random_reviews', ], ], + 'MODULES' => [ + 'main', + 'fileman', + 'iblock', + 'form', + 'perfmon', + 'translate', + 'search', + 'seo', + 'security', + 'photogallery', + ] ]; \ No newline at end of file diff --git a/lang/ru/include.php b/lang/ru/include.php index 0f12085c..d53828e3 100644 --- a/lang/ru/include.php +++ b/lang/ru/include.php @@ -27,6 +27,7 @@ $MESS['INTERVOLGA_EDU.COURSE3_LESSON4'] = '4. Пользовательские поля и типы'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON5'] = '5. JS'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON8'] = '8. Монитор качества'; +$MESS['INTERVOLGA_EDU.COURSEINTERVOLGA_LESSON2'] = '2. Проверка используемых модулей'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON1_SITECORPORATEMODULE'] = 'Проверка установки модуля «Корпоративный сайт производственной компании»'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON1_SITECORPORATEMODULE_DESCRIPTION'] = 'Модуль должен быть зарегистрирован в системе и установлен'; @@ -179,6 +180,8 @@ $MESS['INTERVOLGA_EDU.COURSE3_LESSON8_USERTESTEXISTS'] = 'Проверка 2-ух собственных тестов в мониторе качества'; $MESS['INTERVOLGA_EDU.COURSE3_LESSON8_USERTESTEXISTS_DESCRIPTION'] = 'Должно быть создано 2 пользовательских теста и они должны быть выполнены в Мониторе качества'; +$MESS['INTERVOLGA_EDU.COURSEINTERVOLGA_LESSON2_MODULESCHECK'] = 'Проверка списка модулей'; +$MESS['INTERVOLGA_EDU.COURSEINTERVOLGA_LESSON2_MODULESCHECK_DESCRIPTION'] = 'Неиспользуемые модули должны быть удалены, проверка списка нужных модулей'; $MESS['INTERVOLGA_EDU.TEST_CODE_NAME'] = 'Проверка кода #FILES#'; $MESS['INTERVOLGA_EDU.TEST_CODE_DESCRIPTION'] = 'Современная проверка ядра Битрикса, использование длинных php-тегов, запрет на устаревшие функции'; diff --git a/lang/ru/lib/tests/courseintervolga/lesson2/modulescheck.php b/lang/ru/lib/tests/courseintervolga/lesson2/modulescheck.php new file mode 100644 index 00000000..775aa867 --- /dev/null +++ b/lang/ru/lib/tests/courseintervolga/lesson2/modulescheck.php @@ -0,0 +1,3 @@ +Fetch()) { + if (!preg_match('/intervolga\./i', $row['ID'])) { + $modules[] = $row['ID']; + } + } + + return $modules; + } +} \ No newline at end of file From 6406e6553d2837684b7a6c94620fb6b69448684f Mon Sep 17 00:00:00 2001 From: liliya Date: Tue, 21 Feb 2023 17:59:09 +0300 Subject: [PATCH 14/32] =?UTF-8?q?[IVEDU-32]=20=D0=BF=D0=BE=D0=B4=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0=20BaseTestCode::run()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tests/basetestcode.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tests/basetestcode.php b/lib/tests/basetestcode.php index d8210a44..fe311f75 100644 --- a/lib/tests/basetestcode.php +++ b/lib/tests/basetestcode.php @@ -1,6 +1,7 @@ isExists()) { - Assert::phpSniffer($file); + Assert::phpSniffer([$file->getPath()]); } } } From 475e80d5c4d036db3fd19e4df038cb2a1835d428 Mon Sep 17 00:00:00 2001 From: liliya Date: Tue, 21 Feb 2023 18:01:14 +0300 Subject: [PATCH 15/32] =?UTF-8?q?[IVEDU-32]=20=D0=BF=D0=BE=D0=B4=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/lib/tests/basetestcode.php | 2 +- lib/tests/course1/lesson3/testtemplates.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lang/ru/lib/tests/basetestcode.php b/lang/ru/lib/tests/basetestcode.php index 2cc1179d..4a589419 100644 --- a/lang/ru/lib/tests/basetestcode.php +++ b/lang/ru/lib/tests/basetestcode.php @@ -1,2 +1,2 @@ Date: Wed, 22 Feb 2023 15:25:13 +0300 Subject: [PATCH 16/32] =?UTF-8?q?[IVEDU-35]=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B0=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B2=20ru+en,=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D0=B2=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tests/course1/lesson3/testlang.php | 85 ++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 5 deletions(-) diff --git a/lib/tests/course1/lesson3/testlang.php b/lib/tests/course1/lesson3/testlang.php index 52adaddd..0e42d52d 100644 --- a/lib/tests/course1/lesson3/testlang.php +++ b/lib/tests/course1/lesson3/testlang.php @@ -1,22 +1,97 @@ FileMessage::get( + new File(Application::getDocumentRoot() . static::LANG_DIR . 'en/' . $fileName) + ), + '#VALUE#' => $ru + ] + ) + ); + } + } + + protected static function getMessageLang(string $fileName, string $lang, string $standart) + { + $result = []; + $path = Application::getDocumentRoot() . static::LANG_DIR . $lang . '/' . $fileName; + $messages = Sniffer::run([$path], [$standart]); + foreach ($messages as $message) { + $result[] = mb_strcut($message->getMessage(), 1, -1); + } + + return $result; + } + protected static function run() { - Assert::langStringExists('/local/templates/.default/include', 'header.php', 'Время работы'); - Assert::langStringExists('/local/templates/.default/include', 'footer.php', 'Время работы'); - Assert::langStringExists('/local/templates/.default/include', 'footer.php', 'Контактная информация'); - // TODO: изменить regex, чтобы не хавал кавычки, иначе не робит - // Assert::langStringExists('/local/templates/.default/include', 'footer.php', '© 2000 - 2012 "Мебельный магазин"'); + + static::checkLangFileDiscrepancy(static::HEADER); + static::checkLangFileDiscrepancy(static::FOOTER); + } + + protected static function usageCheck($fileName) + { + $usage = static::getMessageLang($fileName, static::RU, static::LANG_USAGE); + $strings = static::getMessageLang($fileName, static::RU, static::LANG_DEFINITION); + foreach ($strings as $message) { + Assert::true(in_array($message, $usage), + Loc::getMessage('INTERVOLGA_EDU.COURSE_1_LESSON_3_NOT_FOUND_USAGE_STRING',//в файле ** не используется ** + [ + '#FILE#' => FileMessage::get( + new File(Application::getDocumentRoot() . static::LANG_DIR . 'en/' . $fileName) + ), + '#VALUE#' => $message + ] + ) + ); + } + } + + protected static function getLangArrayTemplateDir(ComponentTemplate $templateDir) + { + foreach ($templateDir->getKnownFiles() as $template) { + $result = Sniffer::run([$template->getPath()], ['langUsage']); + foreach ($result as $message) { + $newTest[] = mb_strcut($message->getMessage(), 1, -1); + } + } + + return $newTest; } } \ No newline at end of file From e73dfafcc0f954833bf07067fbe9ebfea348fda2 Mon Sep 17 00:00:00 2001 From: liliya Date: Mon, 27 Feb 2023 15:47:01 +0300 Subject: [PATCH 17/32] =?UTF-8?q?[IVEDU-35]=20=D0=9F=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B0=20=D1=8F=D0=B7=D1=8B=D0=BA=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D1=85=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/lib/tests/course1/lesson3/testlang.php | 4 + lib/tests/course1/lesson3/testlang.php | 82 ++++++++++++------- 2 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 lang/ru/lib/tests/course1/lesson3/testlang.php diff --git a/lang/ru/lib/tests/course1/lesson3/testlang.php b/lang/ru/lib/tests/course1/lesson3/testlang.php new file mode 100644 index 00000000..8d2facdf --- /dev/null +++ b/lang/ru/lib/tests/course1/lesson3/testlang.php @@ -0,0 +1,4 @@ + FileMessage::get( new File(Application::getDocumentRoot() . static::LANG_DIR . 'en/' . $fileName) @@ -46,10 +49,10 @@ protected static function checkLangFileDiscrepancy($fileName) } } - protected static function getMessageLang(string $fileName, string $lang, string $standart) + protected static function getMessageLang(string $fileName, string $directory, string $standart, string $lang = '') { $result = []; - $path = Application::getDocumentRoot() . static::LANG_DIR . $lang . '/' . $fileName; + $path = Application::getDocumentRoot() . $directory . $lang . '/' . $fileName; $messages = Sniffer::run([$path], [$standart]); foreach ($messages as $message) { $result[] = mb_strcut($message->getMessage(), 1, -1); @@ -60,38 +63,59 @@ protected static function getMessageLang(string $fileName, string $lang, string protected static function run() { + static::check(static::HEADER, static::NEEDED_STRING_HEADER); + static::check(static::FOOTER, static::NEEDED_STRING_FOOTER); + } - static::checkLangFileDiscrepancy(static::HEADER); - static::checkLangFileDiscrepancy(static::FOOTER); + protected static function check($filename, $neededString) + { + static::stringChecker($filename, $neededString); + static::usageCheck($filename); + static::checkLangFileDiscrepancy($filename); } - protected static function usageCheck($fileName) + protected static function stringChecker($fileName, $neededString) { - $usage = static::getMessageLang($fileName, static::RU, static::LANG_USAGE); - $strings = static::getMessageLang($fileName, static::RU, static::LANG_DEFINITION); - foreach ($strings as $message) { - Assert::true(in_array($message, $usage), - Loc::getMessage('INTERVOLGA_EDU.COURSE_1_LESSON_3_NOT_FOUND_USAGE_STRING',//в файле ** не используется ** + $strings = static::getMessageLang($fileName, static::LANG_DIR, static::LANG_DEFINITION, static::RU); + foreach ($strings as $string) { + Assert::true(in_array($string, $neededString), + Loc::getMessage('INTERVOLGA_EDU.COURSE_1_LESSON_3_UNKNOWN_STRING', [ '#FILE#' => FileMessage::get( - new File(Application::getDocumentRoot() . static::LANG_DIR . 'en/' . $fileName) + new File(Application::getDocumentRoot() . static::LANG_DIR . 'ru/' . $fileName) ), - '#VALUE#' => $message + '#VALUE#' => $string ] ) ); } + Assert::empty($diff = array_diff($neededString, $strings), + Loc::getMessage('INTERVOLGA_EDU.COURSE_1_LESSON_3_NOT_FOUND_STRING', + [ + '#FILE#' => FileMessage::get( + new File(Application::getDocumentRoot() . static::LANG_DIR . 'ru/' . $fileName) + ), + '#VALUE#' => implode(' || ', $diff) + ] + ) + ); } - protected static function getLangArrayTemplateDir(ComponentTemplate $templateDir) + protected static function usageCheck($fileName) { - foreach ($templateDir->getKnownFiles() as $template) { - $result = Sniffer::run([$template->getPath()], ['langUsage']); - foreach ($result as $message) { - $newTest[] = mb_strcut($message->getMessage(), 1, -1); - } + $usage = static::getMessageLang($fileName, static::INCLUDE_DIR, static::LANG_USAGE); + $strings = static::getMessageLang($fileName, static::LANG_DIR, static::LANG_DEFINITION, static::RU); + foreach ($strings as $message) { + Assert::true(in_array($message, $usage), + Loc::getMessage('INTERVOLGA_EDU.COURSE_1_LESSON_3_NOT_FOUND_USAGE_STRING', + [ + '#FILE#' => FileMessage::get( + new File(Application::getDocumentRoot() . static::INCLUDE_DIR . $fileName) + ), + '#VALUE#' => $message + ] + ) + ); } - - return $newTest; } } \ No newline at end of file From eec52ce77eeecebc305f99302bbddb5f029e32f8 Mon Sep 17 00:00:00 2001 From: liliya Date: Wed, 21 Jun 2023 16:09:18 +0300 Subject: [PATCH 18/32] =?UTF-8?q?[IVEDU-116]=20=D0=9F=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B0=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=20"=D1=81=D0=BB=D0=B0=D0=B9=D0=B4?= =?UTF-8?q?=D0=B5=D1=80"=20(=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5,=20=D0=BE=D0=B1=D1=89=D0=B0=D1=8F=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D0=BA=D0=BE=D0=B4?= =?UTF-8?q?=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include.php | 5 ++ .../lib/locator/component/template/slider.php | 2 + .../io/componenttemplate/slidertemplate.php | 2 + .../course2/lesson1_2/testslidercomponent.php | 2 + lib/locator/component/template/slider.php | 29 +++++++++++ .../io/componenttemplate/slidertemplate.php | 24 +++++++++ .../general/Sniffs/php/CheckArPrefixSniff.php | 1 + lib/tester.php | 3 +- .../course2/lesson1_2/testslidercomponent.php | 52 +++++++++++++++++++ 9 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 lang/ru/lib/locator/component/template/slider.php create mode 100644 lang/ru/lib/locator/io/componenttemplate/slidertemplate.php create mode 100644 lang/ru/lib/tests/course2/lesson1_2/testslidercomponent.php create mode 100644 lib/locator/component/template/slider.php create mode 100644 lib/locator/io/componenttemplate/slidertemplate.php create mode 100644 lib/tests/course2/lesson1_2/testslidercomponent.php diff --git a/include.php b/include.php index c25b3424..3e77fb5a 100644 --- a/include.php +++ b/include.php @@ -31,6 +31,11 @@ 'random_review', 'random_reviews', ], + 'SLIDER' => [ + 'slider', + 'promo_slider', + 'slider_promo', + ], ], 'PATHS' => [ 'DESKTOP' => [ diff --git a/lang/ru/lib/locator/component/template/slider.php b/lang/ru/lib/locator/component/template/slider.php new file mode 100644 index 00000000..f5c2a082 --- /dev/null +++ b/lang/ru/lib/locator/component/template/slider.php @@ -0,0 +1,2 @@ + INTERVOLGA_EDU_GUESS_VARIANTS['TEMPLATES']['SLIDER'], + ]; + } + + /** + * @return string|ComponentLocator + */ + public static function getComponent(): string + { + return NewsList::class; + } + + public static function getNameLoc(): string + { + return Loc::getMessage('INTERVOLGA_EDU.COMPONENT_SLIDER'); + } +} \ No newline at end of file diff --git a/lib/locator/io/componenttemplate/slidertemplate.php b/lib/locator/io/componenttemplate/slidertemplate.php new file mode 100644 index 00000000..cd262154 --- /dev/null +++ b/lib/locator/io/componenttemplate/slidertemplate.php @@ -0,0 +1,24 @@ + static::SLIDER_PATH])); + } + + Assert::directoryLocator($locatorClass); + if ($templateDir = $locatorClass::find(static::getComponentTemplateTree())) { + /** + * @var ComponentTemplate $templateDir + */ + static::testTemplateTrash($templateDir); + static::testTemplateCode($templateDir); + } + } + + protected static function getLocator() + { + return SliderTemplate::class; + } + + protected static function getComponentTemplateTree() + { + return SimpleComponentTemplate::class; + } + + protected static function checkNotExistingFilesTemplate(ComponentTemplate $templateDir) + { + Assert::fseNotExists($templateDir->getImagesDir()); + Assert::fseNotExists($templateDir->getDescriptionFile()); + } +} \ No newline at end of file From 2022c31be59755e9aafd859ab4539ed827c17836 Mon Sep 17 00:00:00 2001 From: liliya Date: Wed, 21 Jun 2023 17:01:50 +0300 Subject: [PATCH 19/32] =?UTF-8?q?[IVEDU-116]=20=D0=90=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=20=D0=BA=D0=BE=D0=B4=D0=B0=20=D0=B2=20result=5Fmod?= =?UTF-8?q?ifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tester.php | 1 + .../lesson1_2/testslidercodeanalysis.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 lib/tests/course2/lesson1_2/testslidercodeanalysis.php diff --git a/lib/tester.php b/lib/tester.php index 3ad2e7b7..357412df 100644 --- a/lib/tester.php +++ b/lib/tester.php @@ -89,6 +89,7 @@ protected static function getTestClasses() \Intervolga\Edu\Tests\Course1\Lesson11\TestPropertyInFilter::class, \Intervolga\Edu\Tests\Course2\Lesson1_2\TestSliderComponent::class, + \Intervolga\Edu\Tests\Course2\Lesson1_2\TestSliderCodeAnalysis::class, \Intervolga\Edu\Tests\Course2\Lesson1_2\TestCatalogBindingProperty::class, \Intervolga\Edu\Tests\Course2\Lesson1_2\TestPropertyPrice::class, diff --git a/lib/tests/course2/lesson1_2/testslidercodeanalysis.php b/lib/tests/course2/lesson1_2/testslidercodeanalysis.php new file mode 100644 index 00000000..2e3735ab --- /dev/null +++ b/lib/tests/course2/lesson1_2/testslidercodeanalysis.php @@ -0,0 +1,31 @@ +<\'\"]*\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*(\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*\})*|[\w\s\d{$=\-:()[\]\.;,><\'\"])*getList\(/i'; + const REG_RESIZE_IMAGE = '/(foreach|while)+\s*([\w\s\d$=\-:()[\]\.;,><\'\"]*\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*(\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*\})*|[\w\s\d{$=\-:()[\]\.;,><\'\"])*ResizeImageGet\(/i'; + + protected static function run() + { + AssertComponent::componentLocator(Slider::class); + Assert::directoryLocator(SliderTemplate::class); + if ($directory = SliderTemplate::find()) { + $file = FileSystem::getInnerFile($directory, 'result_modifier.php'); + Assert::fileContentMatches($file, new Regex('/LINK_IBLOCK_ID/i', 'LINK_IBLOCK_ID')); + Assert::fileContentNotMatches($file, new Regex('/nPageSize/i', 'nPageSize')); + Assert::fileContentNotMatches($file, new Regex('/GetNextELement/i', 'GetNextELement')); + + Assert::fileContentNotMatches($file, new Regex(static::REG_GET_LIST, 'GetList in foreach/while')); + Assert::fileContentMatches($file, new Regex(static::REG_RESIZE_IMAGE, 'ResizeImageGet in foreach')); + } + } +} \ No newline at end of file From f4b998c85607f2d5b3461683b2ae20278e98de8a Mon Sep 17 00:00:00 2001 From: liliya Date: Thu, 22 Jun 2023 10:36:15 +0300 Subject: [PATCH 20/32] =?UTF-8?q?[IVEDU-116]=20=D0=90=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=20=D0=BA=D0=BE=D0=B4=D0=B0=20=D0=B2=20result=5Fmod?= =?UTF-8?q?ifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/include.php | 2 ++ .../course2/lesson1_2/testslidercodeanalysis.php | 4 ++++ .../course2/lesson1_2/testslidercodeanalysis.php | 14 ++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 lang/ru/lib/tests/course2/lesson1_2/testslidercodeanalysis.php diff --git a/lang/ru/include.php b/lang/ru/include.php index 014452ff..086a122d 100644 --- a/lang/ru/include.php +++ b/lang/ru/include.php @@ -127,6 +127,8 @@ $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_PROPERTYISEXIST_DESCRIPTION'] = 'Инфоблок должен иметь свойство "В наличии", оно должно быть заполненно хотя бы у 1 элемента раздела "Мягкая мебель"'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_PROPERTYINFILTER'] = 'Используется в умном фильтре'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_PROPERTYINFILTER_DESCRIPTION'] = 'Проверка параметра свойства "использовать в умном фильтре"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDERCODEANALYSIS'] = 'Проверка кода файла result_modifier'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDERCODEANALYSIS_DESCRIPTION'] = 'Анализ кода news.list/slider/result_modifier.php'; $MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_CATALOGBINDINGPROPERTY'] = 'Проверка свойства "Привязка к каталогу"'; $MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_CATALOGBINDINGPROPERTY_DESCRIPTION'] = 'Свойство должно существовать, иметь тип "Привязка к элементам" и быть заполненно хотя бы у 3 элементов'; $MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_PROPERTYPRICE'] = 'Проверка свойства "Цена"'; diff --git a/lang/ru/lib/tests/course2/lesson1_2/testslidercodeanalysis.php b/lang/ru/lib/tests/course2/lesson1_2/testslidercodeanalysis.php new file mode 100644 index 00000000..2f841446 --- /dev/null +++ b/lang/ru/lib/tests/course2/lesson1_2/testslidercodeanalysis.php @@ -0,0 +1,4 @@ +<\'\"]*\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*(\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*\})*|[\w\s\d{$=\-:()[\]\.;,><\'\"])*getList\(/i'; - const REG_RESIZE_IMAGE = '/(foreach|while)+\s*([\w\s\d$=\-:()[\]\.;,><\'\"]*\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*(\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*\})*|[\w\s\d{$=\-:()[\]\.;,><\'\"])*ResizeImageGet\(/i'; + const REG_GET_LIST = '/(foreach|while)+\s*([\w\s\d$=\-:()[\]\.;,><\'\"]*\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*(\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*\})+|[\w\s\d{$=\-:()[\]\.;,><\'\"])*getList\(/i'; + const REG_GET_LIST_COUNT = '/([\w\s\d{}$=\-:()[\]\.;,><\'\"]*GetList){2,}/i'; + const REG_RESIZE_IMAGE = '/(foreach|while)+\s*([\w\s\d$=\-:()[\]\.;,><\'\"]*\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*(\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*\})+|[\w\s\d{$=\-:()[\]\.;,><\'\"])*ResizeImageGet\(/i'; protected static function run() { @@ -24,8 +26,12 @@ protected static function run() Assert::fileContentNotMatches($file, new Regex('/nPageSize/i', 'nPageSize')); Assert::fileContentNotMatches($file, new Regex('/GetNextELement/i', 'GetNextELement')); - Assert::fileContentNotMatches($file, new Regex(static::REG_GET_LIST, 'GetList in foreach/while')); - Assert::fileContentMatches($file, new Regex(static::REG_RESIZE_IMAGE, 'ResizeImageGet in foreach')); + Assert::fileContentNotMatches($file, new Regex(static::REG_GET_LIST, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_GET_LIST'))); + Assert::fileContentMatches($file, new Regex(static::REG_RESIZE_IMAGE, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_RESIZE_IMAGE'))); + Assert::fileContentNotMatches($file, new Regex(static::REG_GET_LIST_COUNT, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_GET_LIST_COUNT'))); } } } \ No newline at end of file From da69b9eacca02383cbc34715ecc5388fe38a24c6 Mon Sep 17 00:00:00 2001 From: liliya Date: Thu, 22 Jun 2023 10:41:29 +0300 Subject: [PATCH 21/32] =?UTF-8?q?[IVEDU-116]=20=D0=97=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D1=80=D1=82=D1=8B=D0=B9=20=D1=83=D1=80=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tester.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tester.php b/lib/tester.php index 357412df..7f34e9eb 100644 --- a/lib/tester.php +++ b/lib/tester.php @@ -120,7 +120,7 @@ protected static function getTestClasses() \Intervolga\Edu\Tests\Course2\Lesson7\TestSecureAuthorization::class, \Intervolga\Edu\Tests\Course2\Lesson8\TestGadgetTemplate::class, - //\Intervolga\Edu\Tests\Course2\Lesson8\TestSettingResultLinks::class, + \Intervolga\Edu\Tests\Course2\Lesson8\TestSettingResultLinks::class, \Intervolga\Edu\Tests\Course2\Lesson8\TestDesktopPage::class, From 336111d9d8038df71146dee849b4ac0312d66214 Mon Sep 17 00:00:00 2001 From: liliya Date: Thu, 22 Jun 2023 12:14:27 +0300 Subject: [PATCH 22/32] =?UTF-8?q?[IVEDU-17]=20=D0=97=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=BB=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D1=83=20=D1=80=D0=B0=D1=81=D0=BF=D0=BE=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BB=D0=B0=D0=B9=D0=B4=D0=B5?= =?UTF-8?q?=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/include.php | 12 ++++---- lang/ru/lib/locator/io/mainheadertemplate.php | 2 ++ .../lesson1_2/testcomponentinclude.php | 2 ++ .../lesson1_2/testcomponentinclude.php | 26 ++++++++++------- .../course2/lesson1_2/testslidercomponent.php | 29 ++----------------- 5 files changed, 27 insertions(+), 44 deletions(-) create mode 100644 lang/ru/lib/locator/io/mainheadertemplate.php create mode 100644 lang/ru/lib/tests/course2/lesson1_2/testcomponentinclude.php diff --git a/lang/ru/include.php b/lang/ru/include.php index bea723c5..5133894a 100644 --- a/lang/ru/include.php +++ b/lang/ru/include.php @@ -117,10 +117,6 @@ $MESS['INTERVOLGA_EDU.COURSE1_LESSON9_NAVPAGE'] = 'Проверка постраничной навигации'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON10_SEARCHACTION'] = 'Проверка формы поиска'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON10_SEARCHACTION_DESCRIPTION'] = 'Должна быть настроена на раздел, а не на index.php-страницу'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_COMPONENTINCLUDE'] = 'Проверка подключения "Слайдера"'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_COMPONENTINCLUDE_DESCRIPTION'] = 'В header.php главной страницы должен подключаться компонент списка новостей с шаблоном слайдера'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDER'] = 'Проверка содержимого шаблона Слайдера'; -$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDER_DESCRIPTION'] = 'Должны быть правильно заполнены ссылки, getList не должен быть в цикле, js-скрипты подключаются в правильном файле'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_CATALOGRATING'] = 'Проверка на наличие включенного рейтинга'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_CATALOGRATING_DESCRIPTION'] = 'В настройках bitrix:catalog должен быть установлен параметр «Включить рейтинг товара»'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_CHECKSETVIEWTARGET'] = 'Проверка SetViewTarget'; @@ -133,6 +129,11 @@ $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_PROPERTYISEXIST_DESCRIPTION'] = 'Инфоблок должен иметь свойство "В наличии", оно должно быть заполненно хотя бы у 1 элемента раздела "Мягкая мебель"'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_PROPERTYINFILTER'] = 'Используется в умном фильтре'; $MESS['INTERVOLGA_EDU.COURSE1_LESSON11_PROPERTYINFILTER_DESCRIPTION'] = 'Проверка параметра свойства "использовать в умном фильтре"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_COMPONENTINCLUDE'] = 'Проверка подключения "Слайдера"'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_COMPONENTINCLUDE_DESCRIPTION'] = 'В header.php главной страницы должен подключаться компонент списка новостей с шаблоном слайдера'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDER'] = 'Проверка содержимого шаблона Слайдера'; +$MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDER_DESCRIPTION'] = 'Должны быть правильно заполнены ссылки, getList не должен быть в цикле, js-скрипты подключаются в правильном файле'; + $MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDERCODEANALYSIS'] = 'Проверка кода файла result_modifier'; $MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_SLIDERCODEANALYSIS_DESCRIPTION'] = 'Анализ кода news.list/slider/result_modifier.php'; $MESS['INTERVOLGA_EDU.COURSE2_LESSON1_2_CATALOGBINDINGPROPERTY'] = 'Проверка свойства "Привязка к каталогу"'; @@ -282,8 +283,7 @@ $MESS['INTERVOLGA_EDU.CUSTOM_MODULE_TIP'] = 'intervolga.? в #MODULES#'; $MESS['INTERVOLGA_EDU.INCLUDEAREA_PARTNERS'] = 'Включаемая область в разделе Партнерам'; $MESS['INTERVOLGA_EDU.INCLUDEAREA_PARTNERS_TIPS'] = 'в названии должно быть: #PARTS#'; -$MESS['INTERVOLGA_EDU.MAIN_HEADER_TEMPLATE'] = 'Шаблон header главной страницы'; -$MESS['INTERVOLGA_EDU.MAIN_HEADER_TEMPLATE_INCLUDE_COMPONENT'] = 'подключение шаблона слайдера компонента списка новостей'; + $MESS['INTERVOLGA_EDU.SLIDER_STOCK_TEMPLATE'] = 'Шаблон слайдера'; $MESS['INTERVOLGA_EDU.TOP_MENU_TEMPLATE'] = 'Шаблон верхнего меню'; $MESS['INTERVOLGA_EDU.LEFT_MENU_TEMPLATE'] = 'Шаблон левого меню'; diff --git a/lang/ru/lib/locator/io/mainheadertemplate.php b/lang/ru/lib/locator/io/mainheadertemplate.php new file mode 100644 index 00000000..f9562e67 --- /dev/null +++ b/lang/ru/lib/locator/io/mainheadertemplate.php @@ -0,0 +1,2 @@ +IncludeComponent\(\s*(\'|")bitrix\:news\.list(\'|")\,\s*(\'|")#SLID2ER#/i'; - /** - * @return string|TemplateLocator - */ - protected static function getLocator() + protected static function run() { - return Slider::class; + AssertComponent::componentLocator(Slider::class); + if ($slider = Slider::find()) { + Assert::fileLocator(MainHeaderTemplate::class); + if ($page = MainHeaderTemplate::find()) { + $regex = str_replace('#SLIDER#', $slider['TEMPLATE_NAME'], static::REG_INCLUDE_SLIDER); + Assert::fileContentMatches($page, new Regex($regex, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.WRONG_PATH_SLIDER'))); + } + } } - } \ No newline at end of file diff --git a/lib/tests/course2/lesson1_2/testslidercomponent.php b/lib/tests/course2/lesson1_2/testslidercomponent.php index e3e88ad1..ce0e24ab 100644 --- a/lib/tests/course2/lesson1_2/testslidercomponent.php +++ b/lib/tests/course2/lesson1_2/testslidercomponent.php @@ -1,45 +1,20 @@ static::SLIDER_PATH])); - } - - Assert::directoryLocator($locatorClass); - if ($templateDir = $locatorClass::find(static::getComponentTemplateTree())) { - /** - * @var ComponentTemplate $templateDir - */ - static::testTemplateTrash($templateDir); - static::testTemplateCode($templateDir); - } - } - - protected static function getLocator() + protected static function getLocator(): string { return SliderTemplate::class; } - protected static function getComponentTemplateTree() + protected static function getComponentTemplateTree(): string { return SimpleComponentTemplate::class; } From 3abb694bc1238e2ad73f17244e61f2a7ade41adb Mon Sep 17 00:00:00 2001 From: liliya Date: Thu, 22 Jun 2023 12:21:47 +0300 Subject: [PATCH 23/32] =?UTF-8?q?[IVEDU-116]=20=D0=9C=D0=B5=D0=BB=D0=BA?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../course2/lesson1_2/testslidercomponent.php | 2 -- .../lesson1_2/testslidercodeanalysis.php | 24 ++++++++++-------- .../course2/lesson1_2/testslidercomponent.php | 25 ------------------- 3 files changed, 14 insertions(+), 37 deletions(-) delete mode 100644 lang/ru/lib/tests/course2/lesson1_2/testslidercomponent.php diff --git a/lang/ru/lib/tests/course2/lesson1_2/testslidercomponent.php b/lang/ru/lib/tests/course2/lesson1_2/testslidercomponent.php deleted file mode 100644 index 3de1be1b..00000000 --- a/lang/ru/lib/tests/course2/lesson1_2/testslidercomponent.php +++ /dev/null @@ -1,2 +0,0 @@ -isExists()) { + Assert::fileContentMatches($file, new Regex('/LINK_IBLOCK_ID/i', 'LINK_IBLOCK_ID')); + Assert::fileContentNotMatches($file, new Regex('/nPageSize/i', 'nPageSize')); + Assert::fileContentNotMatches($file, new Regex('/GetNextELement/i', 'GetNextELement')); - Assert::fileContentNotMatches($file, new Regex(static::REG_GET_LIST, - Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_GET_LIST'))); - Assert::fileContentMatches($file, new Regex(static::REG_RESIZE_IMAGE, - Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_RESIZE_IMAGE'))); - Assert::fileContentNotMatches($file, new Regex(static::REG_GET_LIST_COUNT, - Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_GET_LIST_COUNT'))); + Assert::fileContentNotMatches($file, new Regex(static::REG_GET_LIST, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_GET_LIST'))); + Assert::fileContentMatches($file, new Regex(static::REG_RESIZE_IMAGE, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_RESIZE_IMAGE'))); + Assert::fileContentNotMatches($file, new Regex(static::REG_GET_LIST_COUNT, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.REG_GET_LIST_COUNT'))); + } } } } \ No newline at end of file diff --git a/lib/tests/course2/lesson1_2/testslidercomponent.php b/lib/tests/course2/lesson1_2/testslidercomponent.php index e3e88ad1..b59ea4b1 100644 --- a/lib/tests/course2/lesson1_2/testslidercomponent.php +++ b/lib/tests/course2/lesson1_2/testslidercomponent.php @@ -1,39 +1,14 @@ static::SLIDER_PATH])); - } - - Assert::directoryLocator($locatorClass); - if ($templateDir = $locatorClass::find(static::getComponentTemplateTree())) { - /** - * @var ComponentTemplate $templateDir - */ - static::testTemplateTrash($templateDir); - static::testTemplateCode($templateDir); - } - } - protected static function getLocator() { return SliderTemplate::class; From 08802494a3f31af070c2781cee7f95004f056425 Mon Sep 17 00:00:00 2001 From: liliya Date: Thu, 22 Jun 2023 13:09:47 +0300 Subject: [PATCH 24/32] =?UTF-8?q?[IVEDU-17]=20=D0=9F=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B0=D0=BB=D0=B0=20testslider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/include.php | 9 +- .../tests/course2/lesson1_2/testslider.php | 6 ++ lib/locator/io/sliderstocktemplate.php | 23 ----- .../lesson1_2/testcomponentinclude.php | 2 +- lib/tests/course2/lesson1_2/testslider.php | 87 +++++++++---------- 5 files changed, 49 insertions(+), 78 deletions(-) create mode 100644 lang/ru/lib/tests/course2/lesson1_2/testslider.php delete mode 100644 lib/locator/io/sliderstocktemplate.php diff --git a/lang/ru/include.php b/lang/ru/include.php index 5133894a..5043c9fc 100644 --- a/lang/ru/include.php +++ b/lang/ru/include.php @@ -295,14 +295,7 @@ $MESS['INTERVOLGA_EDU.TEST_IBLOCK_NAME'] = 'Проверка Инфоблока #IBLOCK#'; $MESS['INTERVOLGA_EDU.TEST_IBLOCK_DESCRIPTION'] = 'Проверка типа, прав, количества элементов, свойств по заданию, формы редактирования в админке'; $MESS['INTERVOLGA_EDU.SEARCH_FORM_TEMPLATE'] = 'Шаблон формы поиска'; -$MESS['INTERVOLGA_EDU.GET_LIST_IN_FOREACH'] = 'GetList помещен в foreach'; -$MESS['INTERVOLGA_EDU.NOT_FOUND_RESIZE'] = 'ресайз детального изображения'; -$MESS['INTERVOLGA_EDU.LINK_SET_NOT_BINDING_VALUE'] = 'заполнение ссылки вручную'; -$MESS['INTERVOLGA_EDU.LINK_SET_NOT_BINDING_VALUE_IMG'] = 'заполнение ссылки вручную в '; -$MESS['INTERVOLGA_EDU.NOT_BINDING_ARRAY'] = 'Массив связанного элемента не заполнен'; -$MESS['INTERVOLGA_EDU.JS_NOT_FOUND_IN_COMPONENT_EPILOG'] = 'подключение js-скриптов карусели или подключение не соответствует ядру D7'; -$MESS['INTERVOLGA_EDU.NOT_TITLE_IN_LINK'] = 'title в ссылке на связанный элемент'; -$MESS['INTERVOLGA_EDU.NOT_TITLE_IN_LINK_IMG'] = 'title в ссылке на связанный элемент в '; + $MESS['INTERVOLGA_EDU.CATALOG_SECTION_TEMPLATE'] = 'Шаблон секций каталога'; $MESS['INTERVOLGA_EDU.GALLERY_TEMPLATE'] = 'Шаблон gallery'; $MESS['INTERVOLGA_EDU.SHOW_VIEW_CONTENT_NOT_FOUND_MATERIALS'] = 'Show View Content для области материалов'; diff --git a/lang/ru/lib/tests/course2/lesson1_2/testslider.php b/lang/ru/lib/tests/course2/lesson1_2/testslider.php new file mode 100644 index 00000000..42515d1b --- /dev/null +++ b/lang/ru/lib/tests/course2/lesson1_2/testslider.php @@ -0,0 +1,6 @@ +'; +$MESS['INTERVOLGA_EDU.COURSE_2.LESSON_1_2.LINK_SET_NOT_BINDING_VALUE'] = 'заполнение ссылки вручную'; +$MESS['INTERVOLGA_EDU.COURSE_2.LESSON_1_2.LINK_SET_NOT_BINDING_VALUE_IMG'] = 'заполнение ссылки вручную в теге '; \ No newline at end of file diff --git a/lib/locator/io/sliderstocktemplate.php b/lib/locator/io/sliderstocktemplate.php deleted file mode 100644 index 48e674fe..00000000 --- a/lib/locator/io/sliderstocktemplate.php +++ /dev/null @@ -1,23 +0,0 @@ -IncludeComponent\(\s*(\'|")bitrix\:news\.list(\'|")\,\s*(\'|")#SLID2ER#/i'; + const REG_INCLUDE_SLIDER = '/\$APPLICATION-\>IncludeComponent\(\s*(\'|")bitrix\:news\.list(\'|")\,\s*(\'|")#SLIDER#/i'; protected static function run() { diff --git a/lib/tests/course2/lesson1_2/testslider.php b/lib/tests/course2/lesson1_2/testslider.php index 7242bec3..c81395ea 100644 --- a/lib/tests/course2/lesson1_2/testslider.php +++ b/lib/tests/course2/lesson1_2/testslider.php @@ -1,71 +1,66 @@ getTemplateFile()); - static::testTemplate($templateDir); - Assert::fseExists($templateDir->getResultModifier()); - static::testResultModifier($templateDir); - Assert::fseExists($templateDir->getComponentEpilogFile()); - static::testComponentEpilogFile($templateDir); + const REG_TITLE_IMG = '/?=$[\]\'\"%&;:\.()]*title[\w\s<>?=$[\]\'"%&;:\.()]*\/>/is'; + const REG_TITLE = '/?=$[\]\'"%&;:\.()]*title[\w\s<>?=$[\]\'"%&;:\.()]*>[\w\s<>?=$[\]\'"%&;:\.()]*(подробнее|Loc::getMessage)[\w\s<>?=$[\]\'"%&;:\.()]*\/a>/ius'; + const REG_BINDING_VALUE_IMG = '/?=$[\]\'"]*href\s*=\s*"[\/]+[\w\s<>?=$[\]\'"\/]*"[\w\s<>?=$[\]\'"%&;:]*>/is'; + const REG_BINDING_VALUE = '/?=$[\]\'"]*href\s*=\s*"[\/]+[\w\s<>?=$[\]\'"\/]*"[\w\s<>?=$[\]\'"%&;:]*>/is'; + public static function interceptErrors() + { + return true; } - /** - * @return string|DirectoryLocator - */ - protected static function getLocator() + protected static function run() { - return SliderStockTemplate::class; + Assert::directoryLocator(SliderTemplate::class); + if ($directory = SliderTemplate::find()) { + static::testTemplate($directory); + static::testComponentEpilogFile($directory); + } } /** - * @return string|ComponentTemplate + * @throws AssertException */ - protected static function getComponentTemplateTree() + protected static function testTemplate(Directory $directory) { - return SimpleComponentTemplate::class; - } - - protected static function testTemplate(ComponentTemplate $templateDir) - { - Assert::directoryLocator(static::getLocator()); - - Assert::fileContentMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"\%\&\;\:\.\(\)]*title[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/>/is', Loc::getMessage('INTERVOLGA_EDU.NOT_TITLE_IN_LINK_IMG'))); - Assert::fileContentMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"\%\&\;\:\.\(\)]*title[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*>[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*(подробнее|Loc::getMessage)[\w\s<>?=$\[\]\'"\%\&\;\:\.\(\)]*\/a>/ius', Loc::getMessage('INTERVOLGA_EDU.NOT_TITLE_IN_LINK'))); - - Assert::fileContentNotMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"]*href\s*=\s*"[\/]+[\w\s<>?=$\[\]\'"\/]*"[\w\s<>?=$\[\]\'"\%\&\;\:]*>/is', Loc::getMessage('INTERVOLGA_EDU.LINK_SET_NOT_BINDING_VALUE_IMG'))); - Assert::fileContentNotMatches($templateDir->getTemplateFile(), new Regex('/?=$\[\]\'"]*href\s*=\s*"[\/]+[\w\s<>?=$\[\]\'"\/]*"[\w\s<>?=$\[\]\'"\%\&\;\:]*>/is', Loc::getMessage('INTERVOLGA_EDU.LINK_SET_NOT_BINDING_VALUE'))); + $file = FileSystem::getInnerFile($directory, 'template.php'); + Assert::fseExists($file); + if ($file->isExists()) { + Assert::fileContentMatches($file, new Regex(static::REG_TITLE_IMG, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.NOT_TITLE_IN_LINK_IMG'))); + Assert::fileContentMatches($file, new Regex(static::REG_TITLE, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.NOT_TITLE_IN_LINK'))); + Assert::fileContentNotMatches($file, new Regex(static::REG_BINDING_VALUE_IMG, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.LINK_SET_NOT_BINDING_VALUE_IMG'))); + Assert::fileContentNotMatches($file, new Regex(static::REG_BINDING_VALUE, + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.LINK_SET_NOT_BINDING_VALUE'))); + } } - protected static function testResultModifier(ComponentTemplate $templateDir) - { - Assert::fileContentMatches($templateDir->getResultModifier(), new Regex('/CFile::ResizeImageGet/i', Loc::getMessage('INTERVOLGA_EDU.NOT_FOUND_RESIZE'))); - } - - protected static function testComponentEpilogFile(ComponentTemplate $templateDir) + /** + * @throws AssertException + */ + protected static function testComponentEpilogFile(Directory $directory) { - Assert::fileContentMatches($templateDir->getComponentEpilogFile(), new Regex('/slides\.min\.jquery\.js/is', Loc::getMessage('INTERVOLGA_EDU.JS_NOT_FOUND_IN_COMPONENT_EPILOG'))); + $file = FileSystem::getInnerFile($directory, 'component_epilog.php'); + Assert::fseExists($file); + if ($file->isExists()) { + Assert::fileContentMatches($file, new Regex('/slides\.min\.jquery\.js/is', + Loc::getMessage('INTERVOLGA_EDU.COURSE_2.LESSON_1_2.JS_NOT_FOUND_IN_COMPONENT_EPILOG'))); + } } - } \ No newline at end of file From cd5482ab2eb561ea5d22f31ea0d458deac7e19da Mon Sep 17 00:00:00 2001 From: liliya Date: Thu, 22 Jun 2023 14:53:28 +0300 Subject: [PATCH 25/32] =?UTF-8?q?[IVEDU-116]=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B5=D0=B3?= =?UTF-8?q?=D1=83=D0=BB=D1=8F=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tests/course2/lesson1_2/testslidercodeanalysis.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tests/course2/lesson1_2/testslidercodeanalysis.php b/lib/tests/course2/lesson1_2/testslidercodeanalysis.php index 07b3e369..fd50ba57 100644 --- a/lib/tests/course2/lesson1_2/testslidercodeanalysis.php +++ b/lib/tests/course2/lesson1_2/testslidercodeanalysis.php @@ -13,7 +13,7 @@ class TestSliderCodeAnalysis extends BaseTest { const REG_GET_LIST = '/(foreach|while)+\s*([\w\s\d$=\-:()[\]\.;,><\'\"]*\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*(\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*\})+|[\w\s\d{$=\-:()[\]\.;,><\'\"])*getList\(/i'; - const REG_GET_LIST_COUNT = '/([\w\s\d{}$=\-:()[\]\.;,><\'\"]*GetList){2,}/i'; + const REG_GET_LIST_COUNT = '/GetList[\w\s\d()$[\]\'",;:\/А-я\=}{><\-]*GetList/i'; const REG_RESIZE_IMAGE = '/(foreach|while)+\s*([\w\s\d$=\-:()[\]\.;,><\'\"]*\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*(\{[\w\s\d{$=\-:()[\]\.;,><\'\"]*\})+|[\w\s\d{$=\-:()[\]\.;,><\'\"])*ResizeImageGet\(/i'; protected static function run() @@ -22,7 +22,7 @@ protected static function run() Assert::directoryLocator(SliderTemplate::class); if ($directory = SliderTemplate::find()) { - $file = FileSystem::getInnerFile($directory, 'result_m2odifier.php'); + $file = FileSystem::getInnerFile($directory, 'result_modifier.php'); Assert::fseExists($file); if ($file->isExists()) { Assert::fileContentMatches($file, new Regex('/LINK_IBLOCK_ID/i', 'LINK_IBLOCK_ID')); From 5b6c896d41720aa9a70ce665b6317939fa537724 Mon Sep 17 00:00:00 2001 From: Liliya Date: Fri, 21 Jun 2024 12:44:28 +0300 Subject: [PATCH 26/32] =?UTF-8?q?[IVEDU-24]=20=D0=9F=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BB=D0=B5=D0=BD=D0=B3=D0=BE=D0=B2=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php b/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php index 37b21a32..23c453c5 100644 --- a/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php +++ b/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php @@ -1,3 +1,3 @@ Создать'; -$MESS['INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_MATCH'] = 'Фвйл robots.txt должен содержать:
User-agent: *
Disallow: /'; \ No newline at end of file +$MESS['INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_MATCH'] = 'Файл robots.txt должен содержать:
User-agent: *
Disallow: /'; \ No newline at end of file From 86e226bfe535cae2288a3e2712833f3a29c87120 Mon Sep 17 00:00:00 2001 From: liliya Date: Wed, 26 Jun 2024 09:39:14 +0300 Subject: [PATCH 27/32] [IVEDU-11] --- lib/tests/basecomponenttemplatetest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tests/basecomponenttemplatetest.php b/lib/tests/basecomponenttemplatetest.php index 3d45437f..0baa67bb 100644 --- a/lib/tests/basecomponenttemplatetest.php +++ b/lib/tests/basecomponenttemplatetest.php @@ -6,6 +6,7 @@ use Intervolga\Edu\FilesTree\ComponentTemplate; use Intervolga\Edu\FilesTree\ComponentTemplate\NewsTemplate; use Intervolga\Edu\Locator\IO\DirectoryLocator; +use Intervolga\Edu\Sniffer; abstract class BaseComponentTemplateTest extends BaseTest { From 4c1ac81994a0d5e711645a40df480842700cdfb5 Mon Sep 17 00:00:00 2001 From: liliya Date: Wed, 26 Jun 2024 11:40:13 +0300 Subject: [PATCH 28/32] =?UTF-8?q?[IVEDU-24]=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B5=D0=B3?= =?UTF-8?q?=D1=83=D0=BB=D1=8F=D1=80=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B2=D1=8B?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F,=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B0=D1=81=D1=81=D0=B5=D1=80=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lesson1/{robotschecker.php => testrobotschecker.php} | 4 ++-- lib/asserts/assert.php | 2 +- lib/tester.php | 2 +- .../lesson1/{robotschecker.php => testrobotschecker.php} | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename lang/ru/lib/tests/courseintervolga/lesson1/{robotschecker.php => testrobotschecker.php} (59%) rename lib/tests/courseintervolga/lesson1/{robotschecker.php => testrobotschecker.php} (73%) diff --git a/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php b/lang/ru/lib/tests/courseintervolga/lesson1/testrobotschecker.php similarity index 59% rename from lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php rename to lang/ru/lib/tests/courseintervolga/lesson1/testrobotschecker.php index 23c453c5..439e8502 100644 --- a/lang/ru/lib/tests/courseintervolga/lesson1/robotschecker.php +++ b/lang/ru/lib/tests/courseintervolga/lesson1/testrobotschecker.php @@ -1,3 +1,3 @@ Создать'; -$MESS['INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_MATCH'] = 'Файл robots.txt должен содержать:
User-agent: *
Disallow: /'; \ No newline at end of file +$MESS['INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_FOUND'] = 'Файл robots.txt не найден. Создать'; +$MESS['INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_MATCH'] = 'Файл #VALUE# должен содержать:
User-agent: *
Disallow: /'; \ No newline at end of file diff --git a/lib/asserts/assert.php b/lib/asserts/assert.php index bddb19e5..9c0daab3 100644 --- a/lib/asserts/assert.php +++ b/lib/asserts/assert.php @@ -500,8 +500,8 @@ public static function fseExists(FileSystemEntry $value, string $message = '') public static function fileContentMatches(File $value, Regex $regex, string $message = '') { static::fseExists($value); + Assert::fileNotEmpty($value); $content = $value->getContents(); - Assert::notEmpty($content); $matches = []; if ($content) { preg_match_all($regex->getRegex(), $content, $matches, PREG_SET_ORDER); diff --git a/lib/tester.php b/lib/tester.php index 2053f32f..2afb2266 100644 --- a/lib/tester.php +++ b/lib/tester.php @@ -159,7 +159,7 @@ protected static function getTestClasses() \Intervolga\Edu\Tests\Course3\Lesson9\TestCompositeEnabled::class, - \Intervolga\Edu\Tests\CourseIntervolga\Lesson1\RobotsChecker::class, + \Intervolga\Edu\Tests\CourseIntervolga\Lesson1\TestRobotsChecker::class, ]; } diff --git a/lib/tests/courseintervolga/lesson1/robotschecker.php b/lib/tests/courseintervolga/lesson1/testrobotschecker.php similarity index 73% rename from lib/tests/courseintervolga/lesson1/robotschecker.php rename to lib/tests/courseintervolga/lesson1/testrobotschecker.php index aa59f3d3..7c118dd4 100644 --- a/lib/tests/courseintervolga/lesson1/robotschecker.php +++ b/lib/tests/courseintervolga/lesson1/testrobotschecker.php @@ -7,12 +7,12 @@ use Intervolga\Edu\Tests\BaseTest; use Intervolga\Edu\Util\Regex; -class RobotsChecker extends BaseTest +class TestRobotsChecker extends BaseTest { protected static function run() { $robotsFile = new RobotsFile(SITE_ID); Assert::true($robotsFile->isExists(), Loc::getMessage('INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_FOUND')); - Assert::fileContentMatches($robotsFile, new Regex ('/User-agent:\s\*\s*Disallow:\s\//i', ''), Loc::getMessage('INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_MATCH')); + Assert::fileContentMatches($robotsFile, new Regex ('/User-agent:\s*\*\s*[\w\s\d\/\:\.\=\_\?\&\*]*Disallow:\s*\/\s*$/im', ''), Loc::getMessage('INTERVOLGA_EDU.COURSE_INTERVOLGA_ROBOTS_NOT_MATCH')); } } \ No newline at end of file From e026dd582e3d3801d4b4fd074d835e8827b08fce Mon Sep 17 00:00:00 2001 From: liliya Date: Wed, 26 Jun 2024 11:50:11 +0300 Subject: [PATCH 29/32] =?UTF-8?q?[IVEDU-23]=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B5=D0=B3?= =?UTF-8?q?=D1=83=D0=BB=D1=8F=D1=80=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B2=D1=8B?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F,=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B0=D1=81=D1=81=D0=B5=D1=80=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lesson2/{modulescheck.php => testmodulescheck.php} | 0 lib/tester.php | 2 +- .../lesson2/{modulescheck.php => testmodulescheck.php} | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename lang/ru/lib/tests/courseintervolga/lesson2/{modulescheck.php => testmodulescheck.php} (100%) rename lib/tests/courseintervolga/lesson2/{modulescheck.php => testmodulescheck.php} (96%) diff --git a/lang/ru/lib/tests/courseintervolga/lesson2/modulescheck.php b/lang/ru/lib/tests/courseintervolga/lesson2/testmodulescheck.php similarity index 100% rename from lang/ru/lib/tests/courseintervolga/lesson2/modulescheck.php rename to lang/ru/lib/tests/courseintervolga/lesson2/testmodulescheck.php diff --git a/lib/tester.php b/lib/tester.php index 645bde70..2f97a1af 100644 --- a/lib/tester.php +++ b/lib/tester.php @@ -160,7 +160,7 @@ protected static function getTestClasses() \Intervolga\Edu\Tests\Course3\Lesson9\TestCompositeEnabled::class, \Intervolga\Edu\Tests\CourseIntervolga\Lesson1\TestRobotsChecker::class, - \Intervolga\Edu\Tests\CourseIntervolga\Lesson2\ModulesCheck::class, + \Intervolga\Edu\Tests\CourseIntervolga\Lesson2\TestModulesCheck::class, ]; } diff --git a/lib/tests/courseintervolga/lesson2/modulescheck.php b/lib/tests/courseintervolga/lesson2/testmodulescheck.php similarity index 96% rename from lib/tests/courseintervolga/lesson2/modulescheck.php rename to lib/tests/courseintervolga/lesson2/testmodulescheck.php index efa4a1bb..2354f0ff 100644 --- a/lib/tests/courseintervolga/lesson2/modulescheck.php +++ b/lib/tests/courseintervolga/lesson2/testmodulescheck.php @@ -5,7 +5,7 @@ use Intervolga\Edu\Asserts\Assert; use Intervolga\Edu\Tests\BaseTest; -class ModulesCheck extends BaseTest +class TestModulesCheck extends BaseTest { public static function interceptErrors() { From 3a8de0951ab86d9cbd90c56f30e5a61f2485e363 Mon Sep 17 00:00:00 2001 From: liliya Date: Wed, 26 Jun 2024 12:31:15 +0300 Subject: [PATCH 30/32] [IVEDU-142] TestPropertyCode --- .../course3/lesson3/testpropertycode.php | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/lib/tests/course3/lesson3/testpropertycode.php b/lib/tests/course3/lesson3/testpropertycode.php index 5fe313ad..2385c270 100644 --- a/lib/tests/course3/lesson3/testpropertycode.php +++ b/lib/tests/course3/lesson3/testpropertycode.php @@ -10,41 +10,43 @@ class TestPropertyCode extends BaseTest { - public static function interceptErrors() - { - return false; - } + public static function interceptErrors() + { + return true; + } - protected static function run() - { - static::checkComponentFile(CustomRespondents::class); - static::checkTemplate(RespondentTemplate::class); - } + protected static function run() + { + static::checkComponentFile(CustomRespondents::class); + static::checkTemplate(RespondentTemplate::class); + } - /** - * @param DirectoryLocator|string $dirComponent - */ - protected static function checkComponentFile($dirComponent) - { - Assert::directoryLocator($dirComponent); - $file = $dirComponent::getComponentFile(); - Assert::fileContentNotMatches($file, - new Regex('/(\'|")(SALARY|GENDER|AGE)(\'|")/i', '\'SALARY\', \'GENDER\', \'AGE\'')); - } + /** + * @param DirectoryLocator|string $dirComponent + */ + protected static function checkComponentFile($dirComponent) + { + Assert::directoryLocator($dirComponent); + if ($dirComponent::find()) { + $file = $dirComponent::getComponentFile(); + Assert::fileContentNotMatches($file, + new Regex('/(\'|")(SALARY|GENDER|AGE)(\'|")/i', '\'SALARY\', \'GENDER\', \'AGE\'')); + } + } - /** - * @param DirectoryLocator|string $dirTemplate - */ - protected static function checkTemplate($dirTemplate) - { - Assert::directoryLocator($dirTemplate); - $directory = $dirTemplate::find(); - - foreach ($directory->getChildren() as $child) { - if ($child->isFile()) { - Assert::fileContentNotMatches($child, - new Regex('/(\'|")(SALARY|GENDER|AGE)(\'|")/i', '\'SALARY\', \'GENDER\', \'AGE\'')); - } - } - } + /** + * @param DirectoryLocator|string $dirTemplate + */ + protected static function checkTemplate($dirTemplate) + { + Assert::directoryLocator($dirTemplate); + if ($directory = $dirTemplate::find()) { + foreach ($directory->getChildren() as $child) { + if ($child->isFile()) { + Assert::fileContentNotMatches($child, + new Regex('/(\'|")(SALARY|GENDER|AGE)(\'|")/i', '\'SALARY\', \'GENDER\', \'AGE\'')); + } + } + } + } } \ No newline at end of file From 0a78d993887f2882a024a31dec9a16b029c35c7e Mon Sep 17 00:00:00 2001 From: liliya Date: Wed, 26 Jun 2024 12:42:55 +0300 Subject: [PATCH 31/32] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tests/basecomponenttemplatetest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tests/basecomponenttemplatetest.php b/lib/tests/basecomponenttemplatetest.php index 0baa67bb..bfcd8732 100644 --- a/lib/tests/basecomponenttemplatetest.php +++ b/lib/tests/basecomponenttemplatetest.php @@ -7,6 +7,8 @@ use Intervolga\Edu\FilesTree\ComponentTemplate\NewsTemplate; use Intervolga\Edu\Locator\IO\DirectoryLocator; use Intervolga\Edu\Sniffer; +use Intervolga\Edu\Util\Admin; +use Intervolga\Edu\Util\FileSystem; abstract class BaseComponentTemplateTest extends BaseTest { From d21db4e0b5a143ac5c0b86dd73e092d188291092 Mon Sep 17 00:00:00 2001 From: Liliya Date: Mon, 1 Jul 2024 16:27:45 +0300 Subject: [PATCH 32/32] =?UTF-8?q?=D0=A0=D0=B5=D0=BB=D0=B8=D0=B7=201.1.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install/version.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/version.php b/install/version.php index bcc5fc12..fa84999e 100644 --- a/install/version.php +++ b/install/version.php @@ -1,5 +1,5 @@ '1.1.1', - 'VERSION_DATE' => '2024-06-14 15:00:00' + 'VERSION' => '1.1.2', + 'VERSION_DATE' => '2024-06-26 16:00:00' ]; \ No newline at end of file