From ecd690c6f2d52466a13dac688d9568c36617658e Mon Sep 17 00:00:00 2001 From: lmarthins0 Date: Fri, 29 May 2026 13:05:19 -0300 Subject: [PATCH 1/3] Adicionando docker e dusk --- .gitignore | 1 + Dockerfile | 76 ++------------ Dockerfile-old | 75 ++++++++++++++ composer.json | 3 +- composer.lock | 142 ++++++++++++++++++++++++++- docker-compose.yml | 46 +++++++++ tests/Browser/ExampleTest.php | 21 ++++ tests/Browser/IndexTest.php | 21 ++++ tests/Browser/Pages/HomePage.php | 36 +++++++ tests/Browser/Pages/Page.php | 20 ++++ tests/Browser/console/.gitignore | 2 + tests/Browser/screenshots/.gitignore | 2 + tests/Browser/source/.gitignore | 2 + tests/DuskTestCase.php | 50 ++++++++++ 14 files changed, 427 insertions(+), 70 deletions(-) create mode 100644 Dockerfile-old create mode 100644 docker-compose.yml create mode 100644 tests/Browser/ExampleTest.php create mode 100644 tests/Browser/IndexTest.php create mode 100644 tests/Browser/Pages/HomePage.php create mode 100644 tests/Browser/Pages/Page.php create mode 100644 tests/Browser/console/.gitignore create mode 100644 tests/Browser/screenshots/.gitignore create mode 100644 tests/Browser/source/.gitignore create mode 100644 tests/DuskTestCase.php diff --git a/.gitignore b/.gitignore index bd4d1919..c20a421d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ npm-debug.log yarn-error.log public/vendor/ /sandbox +.phpunit.cache/ test.db diff --git a/Dockerfile b/Dockerfile index 4b228e1f..4ac10403 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,75 +1,15 @@ -FROM php:8.3-apache +FROM uspdev/uspdev-php-apache:8.4 -ENV DEBIAN_FRONTEND=noninteractive +RUN sed -i 's|/var/www/html|/var/www/html/public|' \ + /etc/apache2/sites-available/000-default.conf -RUN apt-get update && apt-get install -y \ - unixodbc \ - unixodbc-dev \ - freetds-dev \ - freetds-bin \ - tdsodbc \ - libsybdb5 \ - unzip \ - git \ - curl \ - libpng-dev \ - libjpeg-dev \ - libfreetype6-dev \ - libzip-dev \ - libonig-dev \ - libxml2-dev \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer - -RUN docker-php-ext-configure gd --with-freetype --with-jpeg -RUN docker-php-ext-install \ - pdo_mysql \ - pdo_dblib \ - gd \ - mbstring \ - zip \ - xml \ - bcmath \ - pcntl \ - opcache - -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer - -RUN echo "[FreeTDS]" >> /etc/odbcinst.ini \ - && echo "Description = FreeTDS Driver" >> /etc/odbcinst.ini \ - && echo "Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so" >> /etc/odbcinst.ini \ - && echo "Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so" >> /etc/odbcinst.ini - -RUN a2enmod rewrite - -COPY dokku-deploy/apache-php.conf /etc/apache2/conf-available/ -RUN a2enconf apache-php - -RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/*.conf \ - && sed -ri -e 's!/var/www/!/var/www/html/public!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf - -COPY composer.json composer.lock ./ USER www-data -RUN composer install --no-interaction --no-dev --no-autoloader - -WORKDIR /var/www/html - -COPY composer.json composer.lock ./ - -RUN composer install --no-interaction --no-dev --no-autoloader -USER root COPY --chown=www-data . . -RUN mkdir -p storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache \ - && chown -R www-data:www-data storage bootstrap/cache \ - && chmod -R 775 storage bootstrap/cache - -USER www-data -RUN composer dump-autoload - -EXPOSE 80 +RUN composer install \ + --no-dev \ + --optimize-autoloader \ + --no-interaction -CMD ["apache2-foreground"] +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/Dockerfile-old b/Dockerfile-old new file mode 100644 index 00000000..4b228e1f --- /dev/null +++ b/Dockerfile-old @@ -0,0 +1,75 @@ +FROM php:8.3-apache + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + unixodbc \ + unixodbc-dev \ + freetds-dev \ + freetds-bin \ + tdsodbc \ + libsybdb5 \ + unzip \ + git \ + curl \ + libpng-dev \ + libjpeg-dev \ + libfreetype6-dev \ + libzip-dev \ + libonig-dev \ + libxml2-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +RUN docker-php-ext-configure gd --with-freetype --with-jpeg +RUN docker-php-ext-install \ + pdo_mysql \ + pdo_dblib \ + gd \ + mbstring \ + zip \ + xml \ + bcmath \ + pcntl \ + opcache + +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +RUN echo "[FreeTDS]" >> /etc/odbcinst.ini \ + && echo "Description = FreeTDS Driver" >> /etc/odbcinst.ini \ + && echo "Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so" >> /etc/odbcinst.ini \ + && echo "Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so" >> /etc/odbcinst.ini + +RUN a2enmod rewrite + +COPY dokku-deploy/apache-php.conf /etc/apache2/conf-available/ +RUN a2enconf apache-php + +RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/*.conf \ + && sed -ri -e 's!/var/www/!/var/www/html/public!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + +COPY composer.json composer.lock ./ +USER www-data +RUN composer install --no-interaction --no-dev --no-autoloader + +WORKDIR /var/www/html + +COPY composer.json composer.lock ./ + +RUN composer install --no-interaction --no-dev --no-autoloader + +USER root +COPY --chown=www-data . . + +RUN mkdir -p storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache \ + && chown -R www-data:www-data storage bootstrap/cache \ + && chmod -R 775 storage bootstrap/cache + +USER www-data +RUN composer dump-autoload + +EXPOSE 80 + +CMD ["apache2-foreground"] diff --git a/composer.json b/composer.json index 1a82f951..c16f0255 100644 --- a/composer.json +++ b/composer.json @@ -26,12 +26,13 @@ "uspdev/wsfoto": "^2.0" }, "require-dev": { - "spatie/laravel-ignition": "^2.0", "fakerphp/faker": "^1.10", + "laravel/dusk": "^8.6", "lucascudo/laravel-pt-br-localization": "^1.1", "mockery/mockery": "^1.3.1", "nunomaduro/collision": "^8.1", "phpunit/phpunit": "^11.0", + "spatie/laravel-ignition": "^2.0", "uspdev/laravel-usp-faker": "^1.0" }, "repositories": [ diff --git a/composer.lock b/composer.lock index f49c4213..bcbcbcf8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "471250d3b2fa0343f647a708805fcd46", + "content-hash": "88ff028a715ef223af5ba078b7b289e6", "packages": [ { "name": "brick/math", @@ -8444,6 +8444,80 @@ }, "time": "2025-04-30T06:54:44+00:00" }, + { + "name": "laravel/dusk", + "version": "v8.6.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/dusk.git", + "reference": "e7fd48762c6a82ad2cd311db07587aa2a97ce143" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/dusk/zipball/e7fd48762c6a82ad2cd311db07587aa2a97ce143", + "reference": "e7fd48762c6a82ad2cd311db07587aa2a97ce143", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-zip": "*", + "guzzlehttp/guzzle": "^7.5", + "illuminate/console": "^10.0|^11.0|^12.0|^13.0", + "illuminate/support": "^10.0|^11.0|^12.0|^13.0", + "php": "^8.1", + "php-webdriver/webdriver": "^1.15.2", + "symfony/console": "^6.2|^7.0|^8.0", + "symfony/finder": "^6.2|^7.0|^8.0", + "symfony/process": "^6.2|^7.0|^8.0", + "vlucas/phpdotenv": "^5.2" + }, + "require-dev": { + "laravel/framework": "^10.0|^11.0|^12.0|^13.0", + "mockery/mockery": "^1.6", + "orchestra/testbench-core": "^8.19|^9.17|^10.8|^11.0", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.1|^11.0|^12.0.1", + "psy/psysh": "^0.11.12|^0.12", + "symfony/yaml": "^6.2|^7.0|^8.0" + }, + "suggest": { + "ext-pcntl": "Used to gracefully terminate Dusk when tests are running." + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Laravel\\Dusk\\DuskServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Dusk\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel Dusk provides simple end-to-end testing and browser automation.", + "keywords": [ + "laravel", + "testing", + "webdriver" + ], + "support": { + "issues": "https://github.com/laravel/dusk/issues", + "source": "https://github.com/laravel/dusk/tree/v8.6.0" + }, + "time": "2026-04-15T14:50:40+00:00" + }, { "name": "lucascudo/laravel-pt-br-localization", "version": "v1.2.5", @@ -8845,6 +8919,72 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "php-webdriver/webdriver", + "version": "1.16.0", + "source": { + "type": "git", + "url": "https://github.com/php-webdriver/php-webdriver.git", + "reference": "ac0662863aa120b4f645869f584013e4c4dba46a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/ac0662863aa120b4f645869f584013e4c4dba46a", + "reference": "ac0662863aa120b4f645869f584013e4c4dba46a", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-zip": "*", + "php": "^7.3 || ^8.0", + "symfony/polyfill-mbstring": "^1.12", + "symfony/process": "^5.0 || ^6.0 || ^7.0 || ^8.0" + }, + "replace": { + "facebook/webdriver": "*" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.20.0", + "ondram/ci-detector": "^4.0", + "php-coveralls/php-coveralls": "^2.4", + "php-mock/php-mock-phpunit": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpunit/phpunit": "^9.3", + "squizlabs/php_codesniffer": "^3.5", + "symfony/var-dumper": "^5.0 || ^6.0 || ^7.0 || ^8.0" + }, + "suggest": { + "ext-simplexml": "For Firefox profile creation" + }, + "type": "library", + "autoload": { + "files": [ + "lib/Exception/TimeoutException.php" + ], + "psr-4": { + "Facebook\\WebDriver\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.", + "homepage": "https://github.com/php-webdriver/php-webdriver", + "keywords": [ + "Chromedriver", + "geckodriver", + "php", + "selenium", + "webdriver" + ], + "support": { + "issues": "https://github.com/php-webdriver/php-webdriver/issues", + "source": "https://github.com/php-webdriver/php-webdriver/tree/1.16.0" + }, + "time": "2025-12-28T23:57:40+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "11.0.12", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..3aded720 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +services: + chamados: + build: . + container_name: chamados + ports: + - "8000:80" + depends_on: + - mariadb + networks: + - chamados-network + volumes: + - ./:/var/www/html + environment: + HOME: /tmp + user: "${UID:-1000}:${GID:-1000}" + + mariadb: + image: mariadb:11 + container_name: chamados_mariadb + restart: always + environment: + MYSQL_DATABASE: chamados + MYSQL_USER: chamados + MYSQL_PASSWORD: chamados + MYSQL_ROOT_PASSWORD: chamados + volumes: + - mariadb_data:/var/lib/mysql + networks: + - chamados-network + ports: + - "3306:3306" + + selenium: + image: selenium/standalone-chrome + container_name: chamados_selenium + ports: + - "7900:7900" # VNC (pra ver o browser rodando) + networks: + - chamados-network + shm_size: 2gb + +networks: + chamados-network: + +volumes: + mariadb_data: \ No newline at end of file diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php new file mode 100644 index 00000000..2d451fc5 --- /dev/null +++ b/tests/Browser/ExampleTest.php @@ -0,0 +1,21 @@ +browse(function (Browser $browser) { + $browser->visit('/') + ->assertSee('Laravel'); + }); + } +} diff --git a/tests/Browser/IndexTest.php b/tests/Browser/IndexTest.php new file mode 100644 index 00000000..32189c12 --- /dev/null +++ b/tests/Browser/IndexTest.php @@ -0,0 +1,21 @@ +browse(function (Browser $browser) { + $browser->visit('/') + ->assertSee('Chamados'); + }); + } +} diff --git a/tests/Browser/Pages/HomePage.php b/tests/Browser/Pages/HomePage.php new file mode 100644 index 00000000..45d9283f --- /dev/null +++ b/tests/Browser/Pages/HomePage.php @@ -0,0 +1,36 @@ + + */ + public function elements(): array + { + return [ + '@element' => '#selector', + ]; + } +} diff --git a/tests/Browser/Pages/Page.php b/tests/Browser/Pages/Page.php new file mode 100644 index 00000000..eb9a2ded --- /dev/null +++ b/tests/Browser/Pages/Page.php @@ -0,0 +1,20 @@ + + */ + public static function siteElements(): array + { + return [ + '@element' => '#selector', + ]; + } +} diff --git a/tests/Browser/console/.gitignore b/tests/Browser/console/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/tests/Browser/console/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/Browser/screenshots/.gitignore b/tests/Browser/screenshots/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/tests/Browser/screenshots/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/Browser/source/.gitignore b/tests/Browser/source/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/tests/Browser/source/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php new file mode 100644 index 00000000..f171a545 --- /dev/null +++ b/tests/DuskTestCase.php @@ -0,0 +1,50 @@ +addArguments(collect([ + $this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080', + '--disable-search-engine-choice-screen', + '--disable-smooth-scrolling', + ])->unless($this->hasHeadlessDisabled(), function (Collection $items) { + return $items->merge([ + '--disable-gpu', + '--headless=new', + ]); + })->all()); + + return RemoteWebDriver::create( + $_ENV['DUSK_DRIVER_URL'] ?? env('DUSK_DRIVER_URL') ?? 'http://localhost:9515', + DesiredCapabilities::chrome()->setCapability( + ChromeOptions::CAPABILITY, $options + ) + ); + } +} From 3751b46caceddb289dfb3055d4c5165ad90f88f6 Mon Sep 17 00:00:00 2001 From: lmarthins0 Date: Mon, 1 Jun 2026 07:18:00 -0300 Subject: [PATCH 2/3] =?UTF-8?q?atualiza=C3=A7=C3=A3o=20dockerfile=20e=20re?= =?UTF-8?q?mo=C3=A7=C3=A3o=20de=20pasta=20dokku-deploy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-old | 75 ------------------------------------ dokku-deploy/apache-php.conf | 7 ---- dokku-deploy/release.sh | 8 ---- 3 files changed, 90 deletions(-) delete mode 100644 Dockerfile-old delete mode 100644 dokku-deploy/apache-php.conf delete mode 100755 dokku-deploy/release.sh diff --git a/Dockerfile-old b/Dockerfile-old deleted file mode 100644 index 4b228e1f..00000000 --- a/Dockerfile-old +++ /dev/null @@ -1,75 +0,0 @@ -FROM php:8.3-apache - -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get update && apt-get install -y \ - unixodbc \ - unixodbc-dev \ - freetds-dev \ - freetds-bin \ - tdsodbc \ - libsybdb5 \ - unzip \ - git \ - curl \ - libpng-dev \ - libjpeg-dev \ - libfreetype6-dev \ - libzip-dev \ - libonig-dev \ - libxml2-dev \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer - -RUN docker-php-ext-configure gd --with-freetype --with-jpeg -RUN docker-php-ext-install \ - pdo_mysql \ - pdo_dblib \ - gd \ - mbstring \ - zip \ - xml \ - bcmath \ - pcntl \ - opcache - -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer - -RUN echo "[FreeTDS]" >> /etc/odbcinst.ini \ - && echo "Description = FreeTDS Driver" >> /etc/odbcinst.ini \ - && echo "Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so" >> /etc/odbcinst.ini \ - && echo "Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so" >> /etc/odbcinst.ini - -RUN a2enmod rewrite - -COPY dokku-deploy/apache-php.conf /etc/apache2/conf-available/ -RUN a2enconf apache-php - -RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/*.conf \ - && sed -ri -e 's!/var/www/!/var/www/html/public!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf - -COPY composer.json composer.lock ./ -USER www-data -RUN composer install --no-interaction --no-dev --no-autoloader - -WORKDIR /var/www/html - -COPY composer.json composer.lock ./ - -RUN composer install --no-interaction --no-dev --no-autoloader - -USER root -COPY --chown=www-data . . - -RUN mkdir -p storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache \ - && chown -R www-data:www-data storage bootstrap/cache \ - && chmod -R 775 storage bootstrap/cache - -USER www-data -RUN composer dump-autoload - -EXPOSE 80 - -CMD ["apache2-foreground"] diff --git a/dokku-deploy/apache-php.conf b/dokku-deploy/apache-php.conf deleted file mode 100644 index e17115c5..00000000 --- a/dokku-deploy/apache-php.conf +++ /dev/null @@ -1,7 +0,0 @@ -php_value upload_max_filesize 2M -php_value post_max_size 2M -php_value memory_limit 256M -php_value max_execution_time 300 -php_value max_input_time 300 -php_value max_input_vars 1000 -php_value max_file_uploads 2 diff --git a/dokku-deploy/release.sh b/dokku-deploy/release.sh deleted file mode 100755 index feb6e1b5..00000000 --- a/dokku-deploy/release.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -mkdir -p storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache -chown -R www-data:www-data storage bootstrap/cache -chmod -R 775 storage bootstrap/cache - -composer install --no-dev --optimize-autoloader --no-interaction --no-scripts -php artisan migrate --force From e9d17f48feb9bd841b9843c79c0091108ede6eb0 Mon Sep 17 00:00:00 2001 From: lmarthins0 Date: Tue, 2 Jun 2026 09:18:43 -0300 Subject: [PATCH 3/3] =?UTF-8?q?retirando=20exposi=C3=A7=C3=A3o=20de=20port?= =?UTF-8?q?as=20do=20mariadb=20do=20docker-compose.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3aded720..38091697 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,8 +27,6 @@ services: - mariadb_data:/var/lib/mysql networks: - chamados-network - ports: - - "3306:3306" selenium: image: selenium/standalone-chrome