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/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..38091697 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,44 @@ +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 + + 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/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 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 + ) + ); + } +}