From 9cb67d98e02754a2a097447fec07deec1c88f9f0 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula <42547589+terabytesoftw@users.noreply.github.com> Date: Wed, 25 Jan 2023 09:37:16 -0300 Subject: [PATCH] Fixed tests. (#79) * Fixed tests. --- .github/workflows/build.yml | 2 +- .github/workflows/static.yml | 2 +- composer.json | 4 ++-- phpunit.xml.dist | 6 +---- src/Breadcrumbs.php | 4 ++-- src/Dropdown.php | 2 +- src/Menu.php | 4 ++-- src/Message.php | 26 ++++++++++----------- src/Modal.php | 2 +- src/ModalCard.php | 20 ++++++++-------- src/Nav.php | 34 ++++++++++++++-------------- src/NavBar.php | 44 ++++++++++++++++++------------------ src/Panel.php | 26 ++++++++++----------- src/ProgressBar.php | 2 +- src/Tabs.php | 20 ++++++++-------- tests/TestCase.php | 2 +- 16 files changed, 98 insertions(+), 102 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0dde6b6..8506ea1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,4 +28,4 @@ jobs: os: >- ['ubuntu-latest', 'windows-latest'] php: >- - ['7.4', '8.0', '8.1'] + ['8.0', '8.1'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 40ac260..96b2679 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -28,4 +28,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['7.4', '8.0', '8.1'] + ['8.0', '8.1'] diff --git a/composer.json b/composer.json index 4b239b8..a3f5af9 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,11 @@ "source": "https://github.com/yiisoft/yii-bulma" }, "require": { - "php": "^7.4|^8.0", + "php": "^8.0", "yiisoft/arrays": "^2.0|^3.0", "yiisoft/assets": "^2.0", "yiisoft/html": "^2.0|^3.0", - "yiisoft/widget": "^1.0" + "yiisoft/widget": "^2.0" }, "require-dev": { "phpunit/phpunit": "^9.5", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ac2dba8..0ec932f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,12 +2,8 @@ - ./ + ./src - - ./tests - ./vendor - diff --git a/src/Breadcrumbs.php b/src/Breadcrumbs.php index bc63efb..c64bc77 100644 --- a/src/Breadcrumbs.php +++ b/src/Breadcrumbs.php @@ -210,7 +210,7 @@ public function itemTemplate(string $value): self return $new; } - protected function run(): string + public function render(): string { if (empty($this->items)) { return ''; @@ -234,8 +234,8 @@ protected function run(): string Html::closeTag('ul') . PHP_EOL; return $customTag + ->addAttributes($attributes) ->content($content) - ->attributes($attributes) ->encode(false) ->render(); } diff --git a/src/Dropdown.php b/src/Dropdown.php index eb50400..e0dd328 100644 --- a/src/Dropdown.php +++ b/src/Dropdown.php @@ -381,7 +381,7 @@ public function submenuAttributes(array $values): self /** * @throws CircularReferenceException|InvalidConfigException|NotFoundException|NotInstantiableException */ - protected function run(): string + public function render(): string { return $this->renderDropdown(); } diff --git a/src/Menu.php b/src/Menu.php index 2dd8246..1b31a6c 100644 --- a/src/Menu.php +++ b/src/Menu.php @@ -337,7 +337,7 @@ public function urlTemplate(string $value): self * * @return string the result of Widget execution to be outputted. */ - protected function run(): string + public function render(): string { $items = $this->normalizeItems($this->items); @@ -599,7 +599,7 @@ private function renderMenu(array $items): string $content .= Html::closeTag('ul') . PHP_EOL; return $customTag - ->attributes($attributes) + ->addAttributes($attributes) ->content($content) ->encode(false) ->render(); diff --git a/src/Message.php b/src/Message.php index a6e741e..9bbe5e6 100644 --- a/src/Message.php +++ b/src/Message.php @@ -299,7 +299,7 @@ public function withoutHeader(bool $value): self return $new; } - protected function run(): string + public function render(): string { return $this->renderMessage(); } @@ -332,10 +332,10 @@ private function renderCloseButton(): string } return Button::tag() - ->attributes($closeButtonAttributes) - ->content($label) - ->encode(false) - ->render() . PHP_EOL; + ->attributes($closeButtonAttributes) + ->content($label) + ->encode(false) + ->render() . PHP_EOL; } private function renderHeader(): string @@ -359,10 +359,10 @@ private function renderHeader(): string if ($this->withoutHeader === false) { $html = Div::tag() - ->attributes($headerAttributes) - ->content($headerMessage) - ->encode(false) - ->render() . PHP_EOL; + ->attributes($headerAttributes) + ->content($headerMessage) + ->encode(false) + ->render() . PHP_EOL; } return $html; @@ -407,9 +407,9 @@ private function renderMessageBody(): string } return Div::tag() - ->attributes($bodyAttributes) - ->content($body) - ->encode(false) - ->render() . PHP_EOL; + ->attributes($bodyAttributes) + ->content($body) + ->encode(false) + ->render() . PHP_EOL; } } diff --git a/src/Modal.php b/src/Modal.php index c2bcd95..0a53b33 100644 --- a/src/Modal.php +++ b/src/Modal.php @@ -360,7 +360,7 @@ public function begin(): ?string return $html; } - protected function run(): string + public function render(): string { $html = Html::closeTag('div') . PHP_EOL; // .modal-content $html .= Html::closeTag('div'); // .modal diff --git a/src/ModalCard.php b/src/ModalCard.php index 1011318..5f909c3 100644 --- a/src/ModalCard.php +++ b/src/ModalCard.php @@ -558,7 +558,7 @@ public function begin(): ?string return $html; } - protected function run(): string + public function render(): string { $html = $this->renderBodyEnd() . "\n"; $html .= $this->renderFooter() . "\n"; @@ -621,8 +621,8 @@ private function renderCloseButton(): string } return Button::tag() - ->attributes($closeButtonAttributes) - ->render() . PHP_EOL; + ->attributes($closeButtonAttributes) + ->render() . PHP_EOL; } /** @@ -663,19 +663,19 @@ private function renderHeader(): string Html::addCssClass($titleAttributes, $this->titleClass); $content .= P::tag() - ->attributes($titleAttributes) - ->content($this->title) - ->render() . PHP_EOL; + ->attributes($titleAttributes) + ->content($this->title) + ->render() . PHP_EOL; if ($this->withoutCloseButton === false) { $content .= $this->renderCloseButton(); } return CustomTag::name('header') - ->attributes($headerAttributes) - ->content(PHP_EOL . $content) - ->encode(false) - ->render() . PHP_EOL; + ->attributes($headerAttributes) + ->content(PHP_EOL . $content) + ->encode(false) + ->render() . PHP_EOL; } /** diff --git a/src/Nav.php b/src/Nav.php index cdaf3c5..24df55e 100644 --- a/src/Nav.php +++ b/src/Nav.php @@ -167,7 +167,7 @@ public function withoutActivateItems(): self /** * @throws CircularReferenceException|InvalidConfigException|NotFoundException|NotInstantiableException */ - protected function run(): string + public function render(): string { return $this->renderNav(); } @@ -188,12 +188,12 @@ protected function run(): string private function renderDropdown(array $items): string { return Dropdown::widget() - ->cssClass('navbar-dropdown') - ->dividerCssClass('navbar-divider') - ->enclosedByContainer() - ->itemCssClass('navbar-item') - ->items($items) - ->render() . PHP_EOL; + ->cssClass('navbar-dropdown') + ->dividerCssClass('navbar-divider') + ->enclosedByContainer() + ->itemCssClass('navbar-item') + ->items($items) + ->render() . PHP_EOL; } /** @@ -279,9 +279,9 @@ private function renderLabelItem( if ($iconText !== '' || $iconCssClass !== '') { $html = Span::tag() - ->attributes($iconAttributes) + ->addAttributes($iconAttributes) ->content(CustomTag::name('i') - ->class($iconCssClass) + ->addClass($iconCssClass) ->content($iconText) ->encode(false) ->render()) @@ -419,19 +419,19 @@ private function renderNav(): string if ($this->enclosedByStartMenu) { $links = PHP_EOL . Div::tag() - ->class($this->startCssClass) - ->content($links) - ->encode(false) - ->render() . + ->class($this->startCssClass) + ->content($links) + ->encode(false) + ->render() . PHP_EOL; } if ($this->enclosedByEndMenu) { $links = PHP_EOL . Div::tag() - ->class($this->endCssClass) - ->content($links) - ->encode(false) - ->render() . + ->class($this->endCssClass) + ->content($links) + ->encode(false) + ->render() . PHP_EOL; } diff --git a/src/NavBar.php b/src/NavBar.php index 49620c2..6e3ff73 100644 --- a/src/NavBar.php +++ b/src/NavBar.php @@ -341,7 +341,7 @@ public function role(string $value): self return $new; } - protected function run(): string + public function render(): string { return Html::closeTag('nav'); } @@ -372,11 +372,11 @@ private function renderNavBarBrand(): string ->url($this->brandImage) ->render(); $brand = PHP_EOL . A::tag() - ->class($this->itemCssClass) - ->content($brandImage) - ->encode(false) - ->url($this->brandUrl) - ->render(); + ->class($this->itemCssClass) + ->content($brandImage) + ->encode(false) + ->url($this->brandUrl) + ->render(); } if ($this->brandText !== '') { @@ -388,25 +388,25 @@ private function renderNavBarBrand(): string if (empty($this->brandUrl)) { $brand = PHP_EOL . Span::tag() - ->attributes($this->brandTextAttributes) - ->class($this->itemCssClass) - ->content($brandText) - ->render(); + ->addAttributes($this->brandTextAttributes) + ->addClass($this->itemCssClass) + ->content($brandText) + ->render(); } else { $brand = PHP_EOL . A::tag() - ->class($this->itemCssClass) - ->content($brandText) - ->encode(false) - ->url($this->brandUrl) - ->render(); + ->addClass($this->itemCssClass) + ->content($brandText) + ->encode(false) + ->url($this->brandUrl) + ->render(); } } $brand .= $this->renderNavBarBurger(); return Div::tag() - ->attributes($this->brandAttributes) - ->class($this->brandCssClass) + ->addAttributes($this->brandAttributes) + ->addClass($this->brandCssClass) ->content($brand) ->encode(false) ->render(); @@ -440,10 +440,10 @@ private function renderNavBarBurger(): string $burgerAttributes['role'] = $this->buttonLinkRole; return PHP_EOL . A::tag() - ->attributes($burgerAttributes) - ->class($this->burgerCssClass) - ->content($this->buttonLinkContent) - ->encode(false) - ->render() . PHP_EOL; + ->addAttributes($burgerAttributes) + ->addClass($this->burgerCssClass) + ->content($this->buttonLinkContent) + ->encode(false) + ->render() . PHP_EOL; } } diff --git a/src/Panel.php b/src/Panel.php index 367d151..2cdef88 100644 --- a/src/Panel.php +++ b/src/Panel.php @@ -285,7 +285,7 @@ public function template(string $value): self return $new; } - protected function run(): string + public function render(): string { $attributes = $this->attributes; @@ -320,9 +320,9 @@ private function renderHeading(): string Html::addCssClass($headingAttributes, $this->headingClass); return P::tag() - ->attributes($headingAttributes) - ->content($this->heading) - ->render() . PHP_EOL; + ->attributes($headingAttributes) + ->content($this->heading) + ->render() . PHP_EOL; } return ''; @@ -342,10 +342,10 @@ private function renderTabs(string $id): string Html::addCssClass($tabsAttributes, $this->tabClass); return P::tag() - ->attributes($tabsAttributes) - ->content(PHP_EOL . $tabs) - ->encode(false) - ->render() . PHP_EOL; + ->attributes($tabsAttributes) + ->content(PHP_EOL . $tabs) + ->encode(false) + ->render() . PHP_EOL; } return ''; @@ -440,12 +440,12 @@ private function renderItem(array $item): string if ($icon !== '') { $icon = PHP_EOL . I::tag() - ->attributes(['aria-hidden' => 'true']) - ->class($icon) . PHP_EOL; + ->attributes(['aria-hidden' => 'true']) + ->class($icon) . PHP_EOL; $label = PHP_EOL . Span::tag() - ->attributes($labelAttributes) - ->content($icon) - ->encode(false) . PHP_EOL . + ->attributes($labelAttributes) + ->content($icon) + ->encode(false) . PHP_EOL . $label . PHP_EOL; } diff --git a/src/ProgressBar.php b/src/ProgressBar.php index 7cd0e8d..e4721a6 100644 --- a/src/ProgressBar.php +++ b/src/ProgressBar.php @@ -177,7 +177,7 @@ public function value(?float $value): self return $new; } - protected function run(): string + public function render(): string { $attributes = $this->build($this->attributes); $content = ''; diff --git a/src/Tabs.php b/src/Tabs.php index 2b4d2f6..2f7f103 100644 --- a/src/Tabs.php +++ b/src/Tabs.php @@ -300,7 +300,7 @@ public function tabsContentAttributes(array $value): self return $new; } - protected function run(): string + public function render(): string { $attributes = $this->attributes; @@ -327,11 +327,11 @@ protected function run(): string } return Div::tag() - ->attributes($attributes) - ->content(PHP_EOL . $this->renderItems() . PHP_EOL) - ->id($id) - ->encode(false) - ->render() . $this->renderTabsContent(); + ->attributes($attributes) + ->content(PHP_EOL . $this->renderItems() . PHP_EOL) + ->id($id) + ->encode(false) + ->render() . $this->renderTabsContent(); } private function renderItems(): string @@ -496,10 +496,10 @@ private function renderTabsContent(): string if (!empty($this->tabsContent)) { $html .= PHP_EOL . Div::tag() - ->attributes($tabsContentAttributes) - ->content(PHP_EOL . implode(PHP_EOL, $tabsContent) . PHP_EOL) - ->encode(false) - ->render(); + ->attributes($tabsContentAttributes) + ->content(PHP_EOL . implode(PHP_EOL, $tabsContent) . PHP_EOL) + ->encode(false) + ->render(); } return $html; diff --git a/tests/TestCase.php b/tests/TestCase.php index c4b0f2c..2875656 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -19,7 +19,7 @@ protected function setUp(): void parent::setUp(); $this->container = new SimpleContainer(); - WidgetFactory::initialize($this->container, []); + WidgetFactory::initialize($this->container); } protected function tearDown(): void