diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dc34d97 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,68 @@ +name: CI + +on: + push: + pull_request: + +defaults: + run: + shell: bash + +jobs: + + tests: + name: Tests + runs-on: ubuntu-20.04 + strategy: + matrix: + php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ] + fail-fast: false + env: + MATRIX_PHP: ${{ matrix.php }} + PANTHER_CHROME_BINARY: '/opt/hostedtoolcache/chromium/858016/x64/chrome' + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + coverage: "xdebug" + php-version: "${{ matrix.php }}" + extensions: zip + tools: composer + ini-values: error_reporting=-1, display_errors=On + - name: Install dependencies + run: | + composer install --no-interaction --no-scripts --no-progress --prefer-dist + - uses: browser-actions/setup-chrome@latest + with: + chrome-version: 858016 + - run: chrome --version + - name: Uninstall chromedriver from Ubuntu + run: | + sudo apt-get remove chromium-chromedriver + - name: Add browser drivers + run: | + vendor/bin/bdi driver:chromedriver --driver-version=90.0.4430.24 drivers + - name: Setup Mink test server + run: | + mkdir ./logs + ./vendor/bin/mink-test-server &> ./logs/mink-test-server.log & + - name: Remove preinstalled chromedriver bin from ubuntu + run: sudo rm -rf /usr/local/share/chrome_driver + - name: Run tests + run: | + vendor/bin/phpunit -v --coverage-clover=coverage.xml + - name: Upload coverage + uses: codecov/codecov-action@v2 + with: + files: coverage.xml + - name: Archive logs artifacts + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: logs_php-${{ matrix.php }} + path: | + logs diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3368e83..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -language: php - -os: linux -arch: - - amd64 -dist: bionic - -php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1] - -matrix: - fast_finish: true - include: - # Test against dev versions of dependencies - - php: 7.4 - env: DEPENDENCIES='dev' - -cache: - directories: - - $HOME/.composer/cache/files - -before_install: - - if [ "$DEPENDENCIES" = "dev" ]; then composer config minimum-stability dev; fi; - -install: - - composer install - - if [ "${TRAVIS_PHP_VERSION:0:3}" != "7.1" ]; then composer require --dev dbrekelmans/bdi; fi - - if [ "${TRAVIS_PHP_VERSION:0:3}" != "7.1" ]; then vendor/bin/bdi detect drivers; fi - - if [ "${TRAVIS_PHP_VERSION:0:3}" = "7.1" ]; then bin/updatePantherChromeDriver.sh; fi - - # additionally place 'chromedriver' file also in folder 'driver' for symfony/panther >=0.9 and PHP 7.1 - - if [ "${TRAVIS_PHP_VERSION:0:3}" = "7.1" ]; then mkdir drivers; fi - - if [ "${TRAVIS_PHP_VERSION:0:3}" = "7.1" ]; then mv vendor/symfony/panther/chromedriver-bin/chromedriver_linux64 drivers/chromedriver; fi - # Start a webserver for web fixtures. - - vendor/bin/mink-test-server > /dev/null 2>&1 & - -script: if [ "${TRAVIS_PHP_VERSION:0:3}" = "8.0" ]; then vendor/bin/phpunit -v; else vendor/bin/phpunit -v --coverage-clover=coverage.clover; fi - -after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - if [ "${TRAVIS_PHP_VERSION:0:3}" != "8.0" ]; php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi - -after_failure: - - cat /tmp/webdriver_output.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 00dea19..b64f411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +v1.1.0 / 2022-02-xx +================== + +Features: +* Add support for ```symfony/panther:~2.0```. +* Add support for ```PHP 8.1```. +* Drop support for ```PHP 7.1``` cause of too much maintenance afford. Stick with ```v1.0.8``` if you want to use ```PHP 7.1```. +* Enable RadioTest::testIsChecked and RadioTest::testSetValue as soon as ```symfony/panther#v2.0.2``` ist out. + +Misc: +* Use GitHub Actions instead of Travis CI for continuous integration. + v1.0.8 / 2021-03-14 ================== diff --git a/Dockerfile b/Dockerfile index 5a5e086..b1f25dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG PHP_VERSION=7.2 -FROM composer:latest as composer +FROM composer:2.2 as composer FROM php:${PHP_VERSION} # replace shell with bash so we can source files diff --git a/README.md b/README.md index 50aa516..c00d0d0 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,18 @@ [![Latest Unstable Version](https://poser.pugx.org/robertfausk/mink-panther-driver/v/unstable.svg)](https://packagist.org/packages/robertfausk/mink-panther-driver) [![Total Downloads](https://poser.pugx.org/robertfausk/mink-panther-driver/downloads.svg)](https://packagist.org/packages/robertfausk/mink-panther-driver) [![Monhtly Downloads](https://img.shields.io/packagist/dm/robertfausk/mink-panther-driver?style=flat&color=blue)](https://img.shields.io/packagist/dm/robertfausk/mink-panther-driver) -[![Build Status](https://travis-ci.com/robertfausk/mink-panther-driver.svg?branch=master)](https://travis-ci.com/robertfausk/mink-panther-driver) +[![Daily Downloads](https://img.shields.io/packagist/dd/robertfausk/mink-panther-driver?style=flat&color=blue)](https://img.shields.io/packagist/dm/robertfausk/mink-panther-driver) +[![Tests](https://github.com/robertfausk/mink-panther-driver/actions/workflows/ci.yml/badge.svg)](https://github.com/robertfausk/mink-panther-driver/actions/workflows/ci.yml) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/robertfausk/mink-panther-driver/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/robertfausk/mink-panther-driver/) [![Code Coverage](https://scrutinizer-ci.com/g/robertfausk/mink-panther-driver/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/robertfausk/mink-panther-driver/) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE) -![PHP7 Compatible](https://img.shields.io/travis/php-v/robertfausk/mink-panther-driver/master?style=flat) +[![PHP Version Require](http://poser.pugx.org/robertfausk/mink-panther-driver/require/php)](https://packagist.org/packages/robertfausk/mink-panther-driver) [![Open Issues](https://img.shields.io/github/issues-raw/robertfausk/mink-panther-driver?style=flat)](https://github.com/robertfausk/mink-panther-driver/issues) [![Closed Issues](https://img.shields.io/github/issues-closed-raw/robertfausk/mink-panther-driver?style=flat)](https://github.com/robertfausk/mink-panther-driver/issues?q=is%3Aissue+is%3Aclosed) [![Contributors](https://img.shields.io/github/contributors/robertfausk/mink-panther-driver?style=flat)](https://github.com/robertfausk/mink-panther-driver/graphs/contributors) ![Contributors](https://img.shields.io/maintenance/yes/2022?style=flat) +[![Dependents](http://poser.pugx.org/robertfausk/mink-panther-driver/dependents)](https://packagist.org/packages/robertfausk/mink-panther-driver/dependents) + Symfony Panther driver for Mink framework @@ -69,24 +72,17 @@ and give [robertfausk/behat-panther-extension](https://github.com/robertfausk/be Start docker-compose with php web driver - docker-compose up php8.0 + docker-compose up php8.1 Run phpunit tests - docker-compose exec php8.0 vendor/bin/phpunit + docker-compose exec php8.1 vendor/bin/phpunit If you run into issues of type ```session not created: This version of ChromeDriver only supports Chrome version 79``` then it is because of mismatched versions between installed chrome driver and chromium. Best way to bypass this problem is to update them to their newest version. - docker-compose exec php8.0 composer require --dev dbrekelmans/bdi --ignore-platform-req=php - docker-compose exec php8.0 vendor/bin/bdi detect drivers - -If you are developing for PHP 7.1 then you should use following. -The first line could be sufficient but this depends on your actual setup. - - docker-compose exec php7.1 bin/updatePantherChromeDriver.sh - docker-compose build php7.1 + docker-compose exec php8.1 vendor/bin/bdi detect drivers ## Credits diff --git a/bin/updatePantherChromeDriver.sh b/bin/updatePantherChromeDriver.sh deleted file mode 100755 index 6897036..0000000 --- a/bin/updatePantherChromeDriver.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# ensure that symfony/panther's chromeDriver matches installed chromium version -# this needs chromium and symfony/panther (in vendor folder) to be installed - -mkdir -p vendor/symfony/panther/chromedriver-bin -cd vendor/symfony/panther/chromedriver-bin - -chromiumVersion=$(chromium --product-version 2>&1;); -chromiumBrowserVersion=$(chromium-browser --product-version 2>&1;); -googleChromeVersion=$(google-chrome --product-version 2>&1;); -if [[ ${chromiumVersion} == *"."*"."* ]]; then - chromiumVersion="$( cut -d '.' -f 1 <<< "$chromiumVersion" )"; - echo "Found chromium version ${chromiumVersion}"; - chromeDriverVersion="_${chromiumVersion}" -elif [[ ${chromiumBrowserVersion} == *"."*"."* ]]; then - chromiumBrowserVersion="$( cut -d '.' -f 1 <<< "$chromiumBrowserVersion" )"; - echo "Found chromium-browser version ${chromiumBrowserVersion}"; - chromeDriverVersion="_${chromiumBrowserVersion}" -elif [[ ${googleChromeVersion} == *"."*"."* ]]; then - googleChromeVersion="$( cut -d '.' -f 1 <<< "$googleChromeVersion" )"; - echo "Found google-chrome version ${googleChromeVersion}"; - chromeDriverVersion="_${googleChromeVersion}" -else - "No google-chrome, chromium-browser or chromium found. Using latest release..." - chromeDriverVersion="" -fi - -chromeDriver=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE${chromeDriverVersion}); -echo "Downloading ChromeDriver version ${chromeDriver} from https://chromedriver.storage.googleapis.com/LATEST_RELEASE${chromeDriverVersion} ..." - -declare -a binaries=("chromedriver_linux64" "chromedriver_mac64" "chromedriver_win32") -for name in "${binaries[@]}" -do - curl -s https://chromedriver.storage.googleapis.com/${chromeDriver}/${name}.zip -O - unzip -q -o ${name}.zip - rm ${name}.zip - if [[ -f "chromedriver" ]]; then - mv chromedriver ${name} - fi -done - -curl -s https://chromedriver.storage.googleapis.com/${chromeDriver}/notes.txt -O -echo "Done." diff --git a/composer.json b/composer.json index 883f05e..32f3b6e 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,11 @@ "Symfony", "Mink", "testing", + "panther", + "chrome", + "chromium", + "firefox", + "headless", "browser" ], "homepage": "http://mink.behat.org/", @@ -17,22 +22,26 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.2", "behat/mink": "~1.8", - "symfony/panther": "~0.7|~1.0", + "symfony/panther": "~0.7|~1.0|~2.0", "ext-dom": "*" }, "require-dev": { + "dbrekelmans/bdi": "^1.0", "mink/driver-testsuite": "dev-master", - "phpunit/phpunit": "~6.0|~7.0|~8.0|~9.0", - "symfony/dom-crawler": "~2.3|~3.0|~4.0", - "symfony/http-kernel": "~2.3|~3.0|~4.0" + "phpunit/phpunit": "~8.5|~9.3", + "symfony/dom-crawler": "~4.0|~5.0|~6.0", + "symfony/http-kernel": "~4.0|~5.0|~6.0" }, "scripts": { "qa": "" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "pyrech/composer-changelogs": true + } }, "suggest": { "ext-gd": "*" @@ -49,7 +58,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } } } diff --git a/docker-compose.yml b/docker-compose.yml index 3936558..c1e3bad 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -45,12 +45,3 @@ services: - PHP_VERSION=7.2 volumes: - .:/var/www/html - - php7.1: - tty: true - build: - context: . - args: - - PHP_VERSION=7.1 - volumes: - - .:/var/www/html diff --git a/src/PantherDriver.php b/src/PantherDriver.php index 69e989b..c1e0463 100644 --- a/src/PantherDriver.php +++ b/src/PantherDriver.php @@ -229,7 +229,6 @@ public function back() public function switchToWindow($name = null) { $this->getClient()->switchTo()->window($name); - $this->getClient()->refreshCrawler(); } /** @@ -423,6 +422,7 @@ public function isSelected($xpath) */ public function findElementXpaths($xpath) { + $this->getClient()->refreshCrawler(); $nodes = $this->getCrawler()->filterXPath($xpath); $elements = []; @@ -446,6 +446,7 @@ public function getTagName($xpath) */ public function getText($xpath) { + $this->getClient()->refreshCrawler(); $text = $this->getFilteredCrawler($xpath)->text(); $text = str_replace("\n", ' ', $text); $text = preg_replace('/ {2,}/', ' ', $text); @@ -586,7 +587,6 @@ public function selectOption($xpath, $value, $multiple = false) public function click($xpath) { $this->getClient()->getMouse()->click($this->toCoordinates($xpath)); - $this->getClient()->refreshCrawler(); } /** @@ -610,7 +610,7 @@ public function rightClick($xpath) */ public function isChecked($xpath) { - return $this->getChoiceFormField($xpath)->hasValue(); + return $this->getCrawlerElement($this->getFilteredCrawler($xpath))->isSelected(); } /** @@ -709,7 +709,6 @@ public function submitForm($xpath) $crawler = $this->getFilteredCrawler($xpath); $this->getClient()->submit($crawler->form()); - $this->getClient()->refreshCrawler(); } /** diff --git a/tests/Custom/RadioTest.php b/tests/Custom/RadioTest.php deleted file mode 100644 index f86270e..0000000 --- a/tests/Custom/RadioTest.php +++ /dev/null @@ -1,19 +0,0 @@ -markTestSkipped('Still buggy.'); - } - - public function testSetValue() - { - $this->markTestSkipped('Still buggy.'); - } -}