Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Form): set XHTML5 doctype for test rendering #588

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ ARG VERSION=

FROM php:${VERSION}-cli

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
RUN \
# hadolint ignore=DL3027
RUN --mount=type=cache,target=/var/cache/apt \
export DEBIAN_FRONTEND=noninteractive && \
apt-get update -yq; \
apt-get install -yq unzip libicu-dev libonig-dev libxml2-dev; \
pecl install pcov libsodium; \
docker-php-ext-enable pcov sodium; \
docker-php-ext-install intl;

RUN echo 'memory_limit=512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;
RUN echo 'memory_limit=512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

# Configure www-data user
ARG UID=1000
ARG GID=1000
RUN usermod --uid $UID www-data && groupmod --gid $GID www-data && chown www-data:www-data /var/www
USER www-data
WORKDIR /var/www/html
36 changes: 21 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,51 @@
PHP_VERSION=8.3
UID=$(shell id -u)
GID=$(shell id -g)

.PHONY: help

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build-php: ## Build PHP image for given version
@echo "Build php $(filter-out $@,$(MAKECMDGOALS))"
@DOCKER_BUILDKIT=1 docker build -t "twbs-helper-php:$(filter-out $@,$(MAKECMDGOALS))" --build-arg "VERSION=$(filter-out $@,$(MAKECMDGOALS))" .
setup: build-php install ## Initialize project

build-php: ## Build PHP image
@echo "Build php ${PHP_VERSION}"
@DOCKER_BUILDKIT=1 docker build -t "twbs-helper-php:${PHP_VERSION}" --build-arg "VERSION=${PHP_VERSION}" --build-arg "UID=${UID}" --build-arg "GID=${GID}" .

install: ## Install PHP dependencies for given PHP version
rm -f composer.lock
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer install --no-progress --prefer-dist --optimize-autoloader)
rm -f composer.lock
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer --working-dir=tools install --no-progress --prefer-dist --optimize-autoloader)
@$(call run-php,composer install --no-progress --prefer-dist --optimize-autoloader)
rm -f tools/composer.lock
@$(call run-php,composer --working-dir=tools install --no-progress --prefer-dist --optimize-autoloader)

shell: ## Execute shell in given PHP version container
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) bash)
@$(call run-php,bash)

test: ## Execute tests for given PHP version
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer test)
@$(call run-php,composer test $(filter-out $@,$(MAKECMDGOALS)))

test-update: ## Execute tests and update snapshots for given PHP version
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer test:update-snapshot)
@$(call run-php,composer test:update-snapshot $(filter-out $@,$(MAKECMDGOALS)))

lint: ## Execute lint for given PHP version
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer php-cs-fixer)
@$(call run-php,composer php-cs-fixer $(filter-out $@,$(MAKECMDGOALS)))

lint-fix: ## Execute lint fixing for given PHP version
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer php-cs-fixer:fix)
@$(call run-php,composer php-cs-fixer:fix $(filter-out $@,$(MAKECMDGOALS)))

stan: ## Execute PHPStan for given PHP version
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer stan)
@$(call run-php,composer stan $(filter-out $@,$(MAKECMDGOALS)))

ci: ## Execute CI scripts for given PHP version
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer ci)
@$(call run-php,composer ci $(filter-out $@,$(MAKECMDGOALS)))

generate-docs: ## Generate documentation for given PHP version
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer generate-docs)
@$(call run-php,composer generate-docs $(filter-out $@,$(MAKECMDGOALS)))

## Run PHP for given version
define run-php
@docker run -it --rm -u $(shell id -u):$(shell id -g) -v ${PWD}:${PWD} -w ${PWD} twbs-helper-php:$(1)
@docker run -it --rm -v ${PWD}:${PWD} -w ${PWD} twbs-helper-php:${PHP_VERSION} $(1)
endef

#############################
Expand Down
3 changes: 0 additions & 3 deletions src/TwbsHelper/Form/View/Helper/FormCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public function renderTemplate(\Laminas\Form\Element\Collection $collection): st
protected function renderFieldset(\Laminas\Form\ElementInterface $element): string
{
$wrapper = $this->wrapper;
$this->wrapper = '<fieldset%4$s>%2$s%1$s%3$s</fieldset>';

$columSize = $element->getOption('column');
if ($columSize) {
Expand All @@ -114,7 +113,6 @@ protected function renderFieldset(\Laminas\Form\ElementInterface $element): stri
$this->wrapper = '<fieldset%4$s>%2$s' . $columnWrapper . '</fieldset>';
}


$markup = parent::render($element);

$this->wrapper = $wrapper;
Expand All @@ -123,7 +121,6 @@ protected function renderFieldset(\Laminas\Form\ElementInterface $element): stri
return $markup;
}


if (!preg_match(self::$fieldsetRegex, $markup, $matches)) {
return $markup;
}
Expand Down
1 change: 1 addition & 0 deletions tests/TestSuite/Documentation/Tests/Forms/Overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
'type' => 'fieldset',
'options' => [
'label' => 'Disabled fieldset example',
'disabled' => true,
],
'attributes' => [
'disabled' => true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ul class="dropdown-menu">
<li>
<form action="" class="px-4 py-3" id="dropdown" method="POST" name="dropdown" role="form">
<form class="px-4 py-3" id="dropdown" method="POST" name="dropdown" role="form">
<div class="mb-3">
<label class="form-label" for="exampleDropdownFormEmail1">Email address</label>
<input class="form-control" id="exampleDropdownFormEmail1" name="email" placeholder="[email protected]" type="email" value="">
Expand All @@ -23,7 +23,7 @@
<li><a class="dropdown-item" href="#">Forgot password?</a></li>
</ul>
<br>
<form action="" class="dropdown-menu p-4" id="dropdown" method="POST" name="dropdown" role="form">
<form class="dropdown-menu p-4" id="dropdown" method="POST" name="dropdown" role="form">
<div class="mb-3">
<label class="form-label" for="exampleDropdownFormEmail1">Email address</label>
<input class="form-control" id="exampleDropdownFormEmail1" name="email" placeholder="[email protected]" type="email" value="">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h5 class="modal-title" id="exampleModalLabel">New message to @mdo</h5>
<button aria-label="Close" class="btn-close" data-bs-dismiss="modal" name="button" type="button" value=""></button>
</div>
<div class="modal-body">
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="mb-3">
<label class="form-label" for="recipient-name">Recipient:</label>
<input class="form-control" id="recipient-name" name="recipient" type="text" value="">
Expand All @@ -27,4 +27,4 @@ <h5 class="modal-title" id="exampleModalLabel">New message to @mdo</h5>
</div>
</div>
</div>
<script type="text/javascript"></script>
<script></script>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a class="nav-link" href="#">About</a>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-light" name="submit" type="submit" value="">Search</button>
</form>
Expand All @@ -44,7 +44,7 @@
<a class="nav-link" href="#">About</a>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-light" name="submit" type="submit" value="">Search</button>
</form>
Expand All @@ -71,7 +71,7 @@
<a class="nav-link" href="#">About</a>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-primary" name="submit" type="submit" value="">Search</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h5 class="offcanvas-title" id="offcanvasNavbarLabel">Offcanvas</h5>
</ul>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-success" name="submit" type="submit" value="">Search</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a aria-disabled="true" class="disabled nav-link" href="#" tabindex="-1">Disabled</a>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-success" name="submit" type="submit" value="">Search</button>
</form>
Expand All @@ -38,7 +38,7 @@
<a aria-disabled="true" class="disabled nav-link" href="#" tabindex="-1">Disabled</a>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-success" name="submit" type="submit" value="">Search</button>
</form>
Expand All @@ -62,7 +62,7 @@
<a aria-disabled="true" class="disabled nav-link" href="#" tabindex="-1">Disabled</a>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-success" name="submit" type="submit" value="">Search</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<a aria-disabled="true" class="disabled nav-link" href="#" tabindex="-1">Link</a>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-success" name="submit" type="submit" value="">Search</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<nav class="bg-light navbar navbar-light">
<div class="container-fluid">
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-success" name="submit" type="submit" value="">Search</button>
</form>
Expand All @@ -10,15 +10,15 @@
<nav class="bg-light navbar navbar-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="element" placeholder="Search" type="search" value="">
<button class="btn btn-outline-success" name="submit" type="submit" value="">Search</button>
</form>
</div>
</nav>
<br>
<nav class="bg-light navbar navbar-light">
<form action="" class="container-fluid" id="form" method="POST" name="form" role="form">
<form class="container-fluid" id="form" method="POST" name="form" role="form">
<div class="input-group">
<span class="input-group-text" id="basic-addon1">@</span>
<input aria-describedby="basic-addon1" aria-label="Username" class="form-control" name="element" placeholder="Username" type="text" value="">
Expand All @@ -27,7 +27,7 @@
</nav>
<br>
<nav class="bg-light navbar navbar-light">
<form action="" class="container-fluid justify-content-start" id="form" method="POST" name="form" role="form">
<form class="container-fluid justify-content-start" id="form" method="POST" name="form" role="form">
<button class="btn btn-outline-success me-2" name="main_button" type="button" value="">Main button</button>
<button class="btn btn-outline-secondary btn-sm" name="smaller_button" type="button" value="">Smaller button</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<a aria-disabled="true" class="disabled nav-link" href="#" tabindex="-1">Disabled</a>
</li>
</ul>
<form action="" class="d-flex" id="form" method="POST" name="form" role="form">
<form class="d-flex" id="form" method="POST" name="form" role="form">
<input aria-label="Search" class="form-control me-2" name="search" placeholder="Search" type="search" value="">
<button class="btn btn-outline-success" name="submit" type="submit" value="">Search</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<input class="form-control" id="floatingPassword" name="password" placeholder="Password" type="password" value="">
<label for="floatingPassword">Password</label>
</div>
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="form-floating">
<input class="form-control" id="floatingInputValue" name="emailWithValue" placeholder="[email protected]" type="email" value="[email protected]">
<label for="floatingInputValue">Input with value</label>
</div>
</form>
<form action="" class="was-validated" id="form" method="POST" name="form" role="form">
<form class="was-validated" id="form" method="POST" name="form" role="form">
<div class="form-floating has-error">
<input class="form-control is-invalid" id="floatingInputInvalid" name="invalidEmailWithValue" placeholder="[email protected]" type="email" value="[email protected]">
<div class="invalid-feedback"></div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="g-2 row">
<div class="col-md form-floating">
<input class="form-control" id="floatingInputGrid" name="floatingInputGrid" placeholder="[email protected]" type="email" value="[email protected]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="mb-3">
<label class="form-label" for="exampleFormControlInput1">Email address</label>
<input class="form-control" id="exampleFormControlInput1" name="email" placeholder="[email protected]" type="email" value="">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="mb-3">
<label class="form-label" for="formFile">Default file input example</label>
<input class="form-control" id="formFile" name="default-file" type="file">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="mb-3 row">
<label class="col-form-label col-sm-2" for="staticEmail">Email</label>
<div class="col-sm-10">
Expand All @@ -13,7 +13,7 @@
</div>
</form>
<br>
<form action="" class="align-items-center row" id="form" method="POST" name="form" role="form">
<form class="align-items-center row" id="form" method="POST" name="form" role="form">
<label class="visually-hidden" for="staticEmail2">Email</label>
<div class="col-auto">
<input class="form-control-plaintext" id="staticEmail2" name="email" readonly type="email" value="[email protected]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="align-items-center gx-3 gy-2 row">
<div class="col-auto">
<label class="visually-hidden" for="autoSizingInput">Name</label>
Expand Down Expand Up @@ -32,7 +32,7 @@
</div>
</form>
<br>
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="align-items-center gx-3 gy-2 row">
<div class="col-sm-3">
<label class="visually-hidden" for="specificSizeInputName">Name</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="g-3 row">
<div class="col-sm-7">
<input aria-label="City" class="form-control" name="city" placeholder="City" type="text" value="">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="row">
<div class="col">
<input aria-label="First name" class="form-control" name="firstName" placeholder="First name" type="text" value="">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="g-3 row">
<div class="col">
<input aria-label="First name" class="form-control" name="firstName" placeholder="First name" type="text" value="">
Expand All @@ -8,7 +8,7 @@
</div>
</div>
</form>
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="g-3 row">
<div class="col-md-6">
<label class="form-label" for="inputEmail4">Email</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="mb-3 row">
<label class="col-form-label col-form-label-sm col-sm-2" for="colFormLabelSm">Email</label>
<div class="col-sm-10">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" id="form" method="POST" name="form" role="form">
<form id="form" method="POST" name="form" role="form">
<div class="mb-3 row">
<label class="col-form-label col-sm-2" for="inputEmail3">Email</label>
<div class="col-sm-10">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="" class="align-items-center g-3 row row-cols-lg-auto" id="form" method="POST" name="form" role="form">
<form class="align-items-center g-3 row row-cols-lg-auto" id="form" method="POST" name="form" role="form">
<label class="visually-hidden" for="inlineFormInputGroupUsername">Username</label>
<div class="col-12">
<div class="input-group">
Expand Down
Loading
Loading