diff --git a/.env.example b/.env.example index 9881a999..cec3584d 100644 --- a/.env.example +++ b/.env.example @@ -46,72 +46,72 @@ PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" -# REPLICADO ###################################### -# https://github.com/uspdev/replicado -REPLICADO_HOST= -REPLICADO_PORT=5005 -REPLICADO_DATABASE= -REPLICADO_USERNAME= -REPLICADO_PASSWORD= - -# Em alguns métodos é necessário informar o código da unidade. Se houver mais de um código coloque eles separado por vírgulas. -REPLICADO_CODUNDCLG= -REPLICADO_CODUNDCLGS= - -# Se o SGBD é sybase ou versões mais novas do MSSQL use 1. Para versões mais antigas de MSSQL use 0 (default) -REPLICADO_SYBASE=0 - -# Este caminho é adequado para uso em laravel. -REPLICADO_PATHLOG=../storage/logs/replicado.log - -# habilita o uso do cache https://github.com/uspdev/cache (default=false) -# É necessário configurar a biblioteca antes de usar -#REPLICADO_USAR_CACHE= - -# SENHAUNICA-SOCIALITE ###################################### -# https://github.com/uspdev/senhaunica-socialite - -# Credenciais/informações do oauth -SENHAUNICA_KEY=usp_sti -SENHAUNICA_SECRET=sua_super_chave_segura -SENHAUNICA_CALLBACK_ID=1 +# # REPLICADO ###################################### +# # https://github.com/uspdev/replicado +# REPLICADO_HOST= +# REPLICADO_PORT=5005 +# REPLICADO_DATABASE= +# REPLICADO_USERNAME= +# REPLICADO_PASSWORD= + +# # Em alguns métodos é necessário informar o código da unidade. Se houver mais de um código coloque eles separado por vírgulas. +# REPLICADO_CODUNDCLG= +# REPLICADO_CODUNDCLGS= + +# # Se o SGBD é sybase ou versões mais novas do MSSQL use 1. Para versões mais antigas de MSSQL use 0 (default) +# REPLICADO_SYBASE=0 + +# # Este caminho é adequado para uso em laravel. +# REPLICADO_PATHLOG=../storage/logs/replicado.log + +# # habilita o uso do cache https://github.com/uspdev/cache (default=false) +# # É necessário configurar a biblioteca antes de usar +# #REPLICADO_USAR_CACHE= -# URL do servidor oauth no ambiente de dev (default=no) -#SENHAUNICA_DEV="https://dev.uspdigital.usp.br/wsusuario/oauth" +# # SENHAUNICA-SOCIALITE ###################################### +# # https://github.com/uspdev/senhaunica-socialite -# URL do servidor oauth para uso com senhaunica-faker -#SENHAUNICA_DEV="http://127.0.0.1:3141/wsusuario/oauth" +# # Credenciais/informações do oauth +# SENHAUNICA_KEY=usp_sti +# SENHAUNICA_SECRET=sua_super_chave_segura +# SENHAUNICA_CALLBACK_ID=1 -# Desabilite para não salvar o retorno do oauth em storage/app/debug/oauth/ (default=true) -#SENHAUNICA_DEBUG= +# # URL do servidor oauth no ambiente de dev (default=no) +# #SENHAUNICA_DEV="https://dev.uspdigital.usp.br/wsusuario/oauth" -# AS CONFIGURAÇÕES A SEGUIR são relevantes se permission=true +# # URL do servidor oauth para uso com senhaunica-faker +# #SENHAUNICA_DEV="http://127.0.0.1:3141/wsusuario/oauth" -# Esses usuários terão privilégios especiais -ADMINS= -SENHAUNICA_ADMINS= -#SENHAUNICA_GERENTES=4444,5555,6666 +# # Desabilite para não salvar o retorno do oauth em storage/app/debug/oauth/ (default=true) +# #SENHAUNICA_DEBUG= -# Se os logins forem limitados a usuários cadastrados (onlyLocalUsers=true), -# pode ser útil cadastrá-los aqui. -#SENHAUNICA_USERS=777,888 +# # AS CONFIGURAÇÕES A SEGUIR são relevantes se permission=true -# Se true, os privilégios especiais serão revogados ao remover da lista (default=false) -#SENHAUNICA_DROP_PERMISSIONS= +# # Esses usuários terão privilégios especiais +# ADMINS= +# SENHAUNICA_ADMINS= +# #SENHAUNICA_GERENTES=4444,5555,6666 -# Código da unidade para identificar os logins próprios ou de outras unidades -SENHAUNICA_CODIGO_UNIDADE= +# # Se os logins forem limitados a usuários cadastrados (onlyLocalUsers=true), +# # pode ser útil cadastrá-los aqui. +# #SENHAUNICA_USERS=777,888 -# LARAVEL-USP-THEME ####################################### -# https://github.com/uspdev/laravel-usp-theme +# # Se true, os privilégios especiais serão revogados ao remover da lista (default=false) +# #SENHAUNICA_DROP_PERMISSIONS= -# O laravel-usp-theme permite que seja criado links -# para outras aplicações da unidade -#USP_THEME_SISTEMAS_1='{"text":"Pessoas","url":"http://localhost/pessoas"}' -#USP_THEME_SISTEMAS_2='{"text":"LDAP","url":"http://localhost/ldap"}' +# # Código da unidade para identificar os logins próprios ou de outras unidades +# SENHAUNICA_CODIGO_UNIDADE= -# Escolha o skin a ser utilizado (default=uspdev) -#USP_THEME_SKIN= +# # LARAVEL-USP-THEME ####################################### +# # https://github.com/uspdev/laravel-usp-theme + +# # O laravel-usp-theme permite que seja criado links +# # para outras aplicações da unidade +# #USP_THEME_SISTEMAS_1='{"text":"Pessoas","url":"http://localhost/pessoas"}' +# #USP_THEME_SISTEMAS_2='{"text":"LDAP","url":"http://localhost/ldap"}' + +# # Escolha o skin a ser utilizado (default=uspdev) +# #USP_THEME_SKIN= # Configurações Mínimas em dev QUEUE_CONNECTION=sync @@ -143,4 +143,37 @@ SENHAUNICA_CALLBACK_ID=1 SENHAUNICA_ADMINS=111111 SENHAUNICA_DEV="http://auth.local:3141/wsusuario/oauth" -USP_THEME_SKIN=uspdev \ No newline at end of file +USP_THEME_SKIN=uspdev# Configurações Mínimas em dev + +QUEUE_CONNECTION=sync + +MAIL_MAILER=smtp +MAIL_HOST=mailpit +MAIL_PORT=1025 +MAIL_USERNAME= +MAIL_PASSWORD= +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS=test@example.com +MAIL_FROM_NAME="Laravel" + +DB_CONNECTION=mariadb +DB_HOST=mariadb +DB_PORT=3306 +DB_DATABASE=estagios # TROCAR PARA NOME DO SISTEMA +DB_USERNAME=estagios # TROCAR PARA NOME DO SISTEMA +DB_PASSWORD=estagios # TROCAR PARA NOME DO SISTEMA + +APP_URL=http://estagios # TROCAR PARA NOME DO SISTEMA +DUSK_DRIVER_URL='http://selenium:4444/wd/hub' +DUSK_START_MAXIMIZED=true +DUSK_HEADLESS_DISABLED=true + +SENHAUNICA_KEY=faker +SENHAUNICA_SECRET=faker +SENHAUNICA_CALLBACK_ID=1 +SENHAUNICA_ADMINS=111111 +SENHAUNICA_DEV="http://auth.local:3141/wsusuario/oauth" + +USP_THEME_SKIN=uspdev + +REPLICADO_FAKE=1 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4ac10403 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM uspdev/uspdev-php-apache:8.4 + +RUN sed -i 's|/var/www/html|/var/www/html/public|' \ + /etc/apache2/sites-available/000-default.conf + +USER www-data + +COPY --chown=www-data . . + +RUN composer install \ + --no-dev \ + --optimize-autoloader \ + --no-interaction + +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/composer.json b/composer.json index b2dc2f6e..de37e112 100644 --- a/composer.json +++ b/composer.json @@ -32,11 +32,12 @@ "uspdev/utils": "^1.1.0" }, "require-dev": { - "spatie/laravel-ignition": "^2.0", "fakerphp/faker": "^1.9.1", + "laravel/dusk": "^8.6", "mockery/mockery": "^1.3.1", "nunomaduro/collision": "^8.1", - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.0", + "spatie/laravel-ignition": "^2.0" }, "config": { "optimize-autoloader": true, diff --git a/composer.lock b/composer.lock index 3f85f56c..862799ce 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": "f21a10a9a763216c2548c50503201e37", + "content-hash": "5897068e8aaa52a15ae14edf6f459c3e", "packages": [ { "name": "barryvdh/laravel-debugbar", @@ -8913,6 +8913,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": "mockery/mockery", "version": "1.6.12", @@ -9273,6 +9347,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.9", @@ -11128,12 +11268,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.3" }, - "platform-dev": [], - "plugin-api-version": "2.6.0" + "platform-dev": {}, + "plugin-api-version": "2.9.0" } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..1a1461bd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,84 @@ +services: + estagios: + build: . + image: estagios:latest + container_name: estagios + ports: + - "8000:80" + depends_on: + - mariadb + networks: + - estagios-network + volumes: + - ./:/var/www/html + environment: + HOME: /tmp + user: "${UID:-1000}:${GID:-1000}" + + mariadb: + image: mariadb:11 + container_name: estagios_mariadb + restart: always + environment: + MYSQL_DATABASE: estagios + MYSQL_USER: estagios + MYSQL_PASSWORD: estagios + MYSQL_ROOT_PASSWORD: estagios + volumes: + - mariadb_data:/var/lib/mysql + networks: + - estagios-network + + phpmyadmin: + image: phpmyadmin:latest + container_name: estagios_phpmyadmin + restart: always + depends_on: + - mariadb + ports: + - "8081:80" + environment: + PMA_HOST: mariadb + PMA_PORT: 3306 + PMA_USER: root + PMA_PASSWORD: estagios + networks: + - estagios-network + + selenium: + image: selenium/standalone-chrome + container_name: estagios_selenium + ports: + - "7900:7900" + networks: + - estagios-network + shm_size: 2gb + + # No /etc/hosts do seu computador colocar a linha `127.0.0.1 auth.local` + # particularidades do protocolo oAuth1 usado na USP + senhaunica-faker: + image: uspdev/senhaunica-faker + container_name: estagios_senhaunica-faker + ports: + - "3141:3141" + environment: + - APP_URL=http://auth.local:3141 + networks: + estagios-network: + aliases: + - auth.local + + mailpit: + image: axllent/mailpit:latest + container_name: estagios_mailpit + ports: + - "1025:1025" # SMTP + - "8025:8025" # Interface Web + networks: + - estagios-network + +networks: + estagios-network: + +volumes: + mariadb_data: \ No newline at end of file diff --git a/tests/Browser/IndexTest.php b/tests/Browser/IndexTest.php new file mode 100644 index 00000000..172000fa --- /dev/null +++ b/tests/Browser/IndexTest.php @@ -0,0 +1,21 @@ +browse(function (Browser $browser) { + $browser->visit('/') + ->assertSee('Entrar'); + }); + } +} 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 + ) + ); + } +}