From 153d7f9862c2107bafed348f3665c60a759136ee Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Mon, 18 Mar 2024 12:46:04 -0300 Subject: [PATCH] Fix more tests. --- .styleci.yml | 83 ++++++++++++++++++- composer.json | 1 + .../resource/layout/component/alert.php | 4 +- .../layout/component/footer-icons.php | 3 +- .../resource/layout/component/menu.php | 16 ++-- .../layout/component/toggle_language.php | 7 +- src/Framework/resource/layout/footer.php | 14 ++-- src/UseCase/Site/view/404.php | 5 +- src/UseCase/Site/view/about.php | 6 +- src/UseCase/Site/view/index.php | 5 +- tests/Unit/MenuTest.php | 12 +-- 11 files changed, 109 insertions(+), 47 deletions(-) diff --git a/.styleci.yml b/.styleci.yml index 074cbbf..d9b7e2a 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,7 +1,86 @@ -preset: psr2 +preset: psr12 +risky: true + +version: 8.1 finder: exclude: - docs - - tests/_support - vendor + +enabled: + - alpha_ordered_traits + - array_indentation + - array_push + - combine_consecutive_issets + - combine_consecutive_unsets + - combine_nested_dirname + - declare_strict_types + - dir_constant + - empty_loop_body_braces + - fully_qualified_strict_types + - function_to_constant + - hash_to_slash_comment + - integer_literal_case + - is_null + - logical_operators + - magic_constant_casing + - magic_method_casing + - method_separation + - modernize_types_casting + - native_function_casing + - native_function_type_declaration_casing + - no_alias_functions + - no_empty_comment + - no_empty_phpdoc + - no_empty_statement + - no_extra_block_blank_lines + - no_short_bool_cast + - no_superfluous_elseif + - no_unneeded_control_parentheses + - no_unneeded_curly_braces + - no_unneeded_final_method + - no_unset_cast + - no_unused_imports + - no_unused_lambda_imports + - no_useless_else + - no_useless_return + - normalize_index_brace + - php_unit_dedicate_assert + - php_unit_dedicate_assert_internal_type + - php_unit_expectation + - php_unit_mock + - php_unit_mock_short_will_return + - php_unit_namespaced + - php_unit_no_expectation_annotation + - phpdoc_no_empty_return + - phpdoc_no_useless_inheritdoc + - phpdoc_order + - phpdoc_property + - phpdoc_scalar + - phpdoc_singular_inheritdoc + - phpdoc_trim + - phpdoc_trim_consecutive_blank_line_separation + - phpdoc_type_to_var + - phpdoc_types + - phpdoc_types_order + - print_to_echo + - regular_callable_call + - return_assignment + - self_accessor + - self_static_accessor + - set_type_to_cast + - short_array_syntax + - short_list_syntax + - simplified_if_return + - single_quote + - standardize_not_equals + - ternary_to_null_coalescing + - trailing_comma_in_multiline_array + - unalign_double_arrow + - unalign_equals + - union_type_without_spaces + +disabled: + - function_declaration + - psr12_braces diff --git a/composer.json b/composer.json index ec15223..52ded8f 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "sjaakp/yii2-icon": "^1.0", "ui-awesome/html": "^0.1", "ui-awesome/html-component": "^0.1", + "ui-awesome/html-helper":"^0.1", "yii2-extensions/asset-bootstrap5": "^0.1", "yii2-extensions/bootstrap5": "^0.1", "yii2-extensions/localeurls": "dev-main", diff --git a/src/Framework/resource/layout/component/alert.php b/src/Framework/resource/layout/component/alert.php index 5336119..f0c3adb 100644 --- a/src/Framework/resource/layout/component/alert.php +++ b/src/Framework/resource/layout/component/alert.php @@ -2,9 +2,7 @@ declare(strict_types=1); -use UIAwesome\Html\Component\Alert; -use UIAwesome\Html\Component\Cookbook\BootstrapAlertDismiss; -use UIAwesome\Html\Group\Div; +use UIAwesome\Html\{Component\Alert, Component\Cookbook\BootstrapAlertDismiss, Group\Div}; $session = Yii::$app->getSession(); $flashMessages = $session->getAllFlashes(); diff --git a/src/Framework/resource/layout/component/footer-icons.php b/src/Framework/resource/layout/component/footer-icons.php index b4d97df..3df1a7c 100644 --- a/src/Framework/resource/layout/component/footer-icons.php +++ b/src/Framework/resource/layout/component/footer-icons.php @@ -2,8 +2,7 @@ declare(strict_types=1); -use UIAwesome\Html\Graphic\Svg; -use UIAwesome\Html\Textual\A; +use UIAwesome\Html\{Graphic\Svg, Textual\A}; $linkIconDefinitions = [ 'class()' => ['d-none d-sm-block d-md-block d-lg-block d-xl-block text-muted hover:text-dark text-decoration-none ms-3'], diff --git a/src/Framework/resource/layout/component/menu.php b/src/Framework/resource/layout/component/menu.php index 4756327..c39e2fa 100644 --- a/src/Framework/resource/layout/component/menu.php +++ b/src/Framework/resource/layout/component/menu.php @@ -2,13 +2,14 @@ declare(strict_types=1); -use UIAwesome\Html\Component\Cookbook\BootstrapNavBarMenuItemsRigth; -use UIAwesome\Html\Component\Item; -use UIAwesome\Html\Component\Menu; -use UIAwesome\Html\Component\NavBar; -use UIAwesome\Html\Multimedia\Img; -use yii\helpers\Url; -use yii\web\User; +use UIAwesome\Html\{ + Component\Cookbook\BootstrapNavBarMenuItemsRigth, + Component\Item, + Component\Menu, + Component\NavBar, + Multimedia\Img +}; +use yii\{helpers\Url, web\User}; $user = null; @@ -51,6 +52,5 @@ Menu::widget() ->currentPath(Yii::$app->request->url) ->items(...$items) - ->linkActiveClass('active') ) ->render(); diff --git a/src/Framework/resource/layout/component/toggle_language.php b/src/Framework/resource/layout/component/toggle_language.php index fc341ee..1faaf14 100644 --- a/src/Framework/resource/layout/component/toggle_language.php +++ b/src/Framework/resource/layout/component/toggle_language.php @@ -3,11 +3,8 @@ declare(strict_types=1); use App\Framework\Asset\LocaleAsset; -use UIAwesome\Html\Component\Cookbook\BootstrapDropdownLanguage; -use UIAwesome\Html\Component\Dropdown; -use UIAwesome\Html\Component\Item; -use yii\helpers\Url; -use yii\web\View; +use UIAwesome\Html\Component\{Cookbook\BootstrapDropdownLanguage, Dropdown, Item}; +use yii\{helpers\Url, web\View}; /** * @var string $languageLabel diff --git a/src/Framework/resource/layout/footer.php b/src/Framework/resource/layout/footer.php index e3016dc..4ce4b16 100644 --- a/src/Framework/resource/layout/footer.php +++ b/src/Framework/resource/layout/footer.php @@ -3,12 +3,14 @@ declare(strict_types=1); use App\Framework\Asset\ToggleThemeAsset; -use UIAwesome\Html\Component\Cookbook\BootstrapToggleTheme; -use UIAwesome\Html\Component\Toggle; -use UIAwesome\Html\Group\Div; -use UIAwesome\Html\Semantic\Footer; -use UIAwesome\Html\Textual\A; -use UIAwesome\Html\Textual\Span; +use UIAwesome\Html\{ + Component\Cookbook\BootstrapToggleTheme, + Component\Toggle, + Group\Div, + Semantic\Footer, + Textual\A, + Textual\Span +}; use yii\web\View; /** diff --git a/src/UseCase/Site/view/404.php b/src/UseCase/Site/view/404.php index 5b009e9..c5e9c5b 100644 --- a/src/UseCase/Site/view/404.php +++ b/src/UseCase/Site/view/404.php @@ -2,10 +2,7 @@ declare(strict_types=1); -use UIAwesome\Html\Group\Div; -use UIAwesome\Html\Helper\Encode; -use UIAwesome\Html\Multimedia\Img; -use UIAwesome\Html\Semantic\H; +use UIAwesome\Html\{Group\Div, Helper\Encode, Multimedia\Img, Semantic\H}; use yii\web\View; /** diff --git a/src/UseCase/Site/view/about.php b/src/UseCase/Site/view/about.php index 8a2a5e5..287e570 100644 --- a/src/UseCase/Site/view/about.php +++ b/src/UseCase/Site/view/about.php @@ -2,11 +2,7 @@ declare(strict_types=1); -use UIAwesome\Html\Group\Div; -use UIAwesome\Html\Group\P; -use UIAwesome\Html\Helper\Encode; -use UIAwesome\Html\Semantic\H; -use UIAwesome\Html\Tag; +use UIAwesome\Html\{Group\Div, Group\P, Helper\Encode, Semantic\H, Tag}; use yii\web\View; /** diff --git a/src/UseCase/Site/view/index.php b/src/UseCase/Site/view/index.php index e25058a..c9ab56d 100644 --- a/src/UseCase/Site/view/index.php +++ b/src/UseCase/Site/view/index.php @@ -2,10 +2,7 @@ declare(strict_types=1); -use UIAwesome\Html\Group\Div; -use UIAwesome\Html\Group\P; -use UIAwesome\Html\Helper\Encode; -use UIAwesome\Html\Semantic\H; +use UIAwesome\Html\{Group\Div, Group\P, Helper\Encode, Semantic\H}; use yii\web\View; /** diff --git a/tests/Unit/MenuTest.php b/tests/Unit/MenuTest.php index 8e00d48..6d34ec5 100644 --- a/tests/Unit/MenuTest.php +++ b/tests/Unit/MenuTest.php @@ -7,6 +7,7 @@ use App\Tests\Support\Data\UserIdentity; use Codeception\Test\Unit; use Yii; +use yii\web\Request; use yii\web\User; use yii\web\View; @@ -18,20 +19,15 @@ public function testMenu(): void { $view = new View(); - Yii::$container->set( - User::class, - [ - 'identityClass' => UserIdentity::class, - ] - ); - + Yii::$app->request->setUrl('http://example.com'); Yii::$app->params['app.menu.islogged'] = [ [ 'label' => 'Logout', - 'url' => ['/logout/index'], + 'link' => ['/logout/index'], 'order' => 1, ], ]; + Yii::$container->set(User::class, ['identityClass' => UserIdentity::class]); $user = Yii::$container->get(User::class); $user->login(UserIdentity::findIdentity('user1'), 0);