Skip to content

Commit

Permalink
bump versions (#77)
Browse files Browse the repository at this point in the history
* bump versions

* updated readme

* trigger

* remove SetUpTearDownTrait

* updated symfony/phpunit-bridge

* fixing TimeoutTest

* added bamarni/composer-bin-plugin, updated mink/driver-testsuite

* fixing ScreenshotListener

* fixing ScreenshotListener

* update ci.yml and defined SYMFONY_DEPRECATIONS_HELPER

* created FirefoxProfile

* trigger

* - moved bamarni/composer-bin-plugin to dev.
- updated readme.

* - moved bamarni/composer-bin-plugin to dev.

* add nc
  • Loading branch information
oleg-andreyev authored Oct 29, 2022
1 parent f570e0f commit c64d82e
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 38 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 7.2, 7.3, 7.4, 8.0 ]
php: [ 7.4, 8.0, 8.1 ]
browser: [ chrome, firefox ]
experimental: [false]
include:
- php: 8.1
- php: 8.2
experimental: true
browser: chrome
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@2.12.0
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
Expand All @@ -46,7 +46,7 @@ jobs:
run: echo "::set-output name=directory::$(composer config cache-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2.1.6
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.directory }}
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down Expand Up @@ -75,6 +75,8 @@ jobs:
else
xvfb-run --auto-servernum $GECKOWEBDRIVER/geckodriver --host 127.0.0.1 -vv --port 4444 &>./logs/webdriver.log &
fi;
while ! nc -z localhost 4444 </dev/null; do echo Waiting for driver to start...; sleep 1; done
- name: Start webserver
shell: bash
Expand All @@ -84,13 +86,15 @@ jobs:
php -S localhost:8002 -t ./vendor/mink/driver-testsuite/web-fixtures &> ./logs/mink-test-server.log &
- name: Run tests
env:
SYMFONY_DEPRECATIONS_HELPER: 'max[total]=999999'
BROWSER_NAME: ${{ matrix.browser }}
run: |
export BROWSER_NAME="${{ matrix.browser }}"
./vendor/bin/simple-phpunit -v
- name: Archive logs artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: logs_browser-${{ matrix.browser }}_php-${{ matrix.php }}
path: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ chromedriver/
geckodriver/
msedgedriver/
logs/
vendor-bin/**/vendor/
35 changes: 14 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,33 @@ Initially it's started as [PR](https://github.com/minkphp/MinkSelenium2Driver/pu

Major updates include:
- Switch to using `facebook/webdriver`
- Update minimum php version to 7.2
- Update minimum php version to 7.4
- Tested against the latest Google Chrome and Mozilla Firefox both in GUI and Headless modes

## Setup

Install via `oleg-andreyev/mink-phpwebdriver-extension`
Install `oleg-andreyev/mink-phpwebdriver`
```bash
$ composer require --dev oleg-andreyev/mink-phpwebdriver-extension
composer require oleg-andreyev/mink-phpwebdriver
```

Add this extension to your `behat.yml` (see below)

- Set the wd_host to this server instead
```yaml
default:
extensions:
OAndreyev\MinkPhpWebdriverExtension: ~
Behat\MinkExtension:
default_session: webdriver
webdriver:
wd_host: "http://0.0.0.0:4444/wd/hub"
browser: 'chrome'
```
## Behat Extension
https://github.com/oleg-andreyev/MinkPhpWebdriverExtension

## Testing

```bash
$ ./bin/start_webdriver.sh &
#./bin/start_driver.sh <browser> <version>
$ ./bin/start_driver.sh chrome latest &
$ BROWSER_NAME=chrome ./vendor/bin/simple-phpunit
./bin/start_webdriver.sh &
# ./bin/start_driver.sh <browser> <version>
./bin/start_driver.sh chrome latest &
BROWSER_NAME=chrome ./vendor/bin/simple-phpunit
```

This will download the latest driver for specified browser and will execute phpunit

## Running GitHub Acton locally
Follow https://github.com/shivammathur/setup-php#local-testing-setup

## Copyright

Copyright (c) 2019 Oleg Andreyev <[email protected]>
Copyright (c) 2022 Oleg Andreyev <[email protected]>
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@
"roave/security-advisories": "dev-master",
"mink/driver-testsuite": "dev-integration-branch",
"behat/mink-extension": "^2.3",
"symfony/phpunit-bridge": "^5.2"
"symfony/phpunit-bridge": "^4.4 || ^5.4 || ^6.0",
"bamarni/composer-bin-plugin": "^1.8"
},
"scripts": {
"bin": "echo 'bin not installed'",
"post-install-cmd": ["@composer bin all install --ansi"],
"post-update-cmd": ["@composer bin all update --ansi"]
},
"autoload": {
"psr-4": {
Expand All @@ -52,5 +58,10 @@
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"config": {
"allow-plugins": {
"bamarni/composer-bin-plugin": true
}
}
}
9 changes: 5 additions & 4 deletions tests/Custom/TimeoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
use Behat\Mink\Tests\Driver\OnNotSuccessfulTrait;
use Behat\Mink\Tests\Driver\TestCase;
use OAndreyev\Mink\Driver\WebDriver;
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;

class TimeoutTest extends TestCase
{
use SetUpTearDownTrait, OnNotSuccessfulTrait;
use OnNotSuccessfulTrait;

/** @var Session */
private $session;

/** @var WebDriver */
private $driver;

protected function doSetUp()
/**
* @before
*/
protected function before()
{
parent::doSetUp();
$this->session = $this->getSession();
$this->driver = $this->session->getDriver();
}
Expand Down
15 changes: 10 additions & 5 deletions tests/ScreenshotListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Behat\Mink\Session;
use Behat\Mink\Tests\Driver\TestCase;
use Behat\Mink\Tests\Driver\Util\TestCaseInvalidStateException;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
Expand Down Expand Up @@ -57,11 +58,15 @@ public function endTest(Test $test, float $time): void

private function makeScreenshot(Test $test): void
{
/** @var Session $session */
$session = \Closure::bind(function () {
/** @var TestCase $this */
return $this->getSession();
}, $test, $test)();
try {
/** @var Session $session */
$session = \Closure::bind(function () {
/** @var TestCase $this */
return $this->getSession();
}, $test, $test)();
} catch (\Throwable $e) {
return;
}

if (!$session->isStarted()) {
return;
Expand Down
1 change: 1 addition & 0 deletions tests/WebDriverConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function createDriver()
}
$optionsOrProfile = $this->buildChromeOptions($desiredCapabilities, $optionsOrProfile, $driverOptions);
} else if ($browser === 'firefox') {
$optionsOrProfile = new FirefoxProfile();
$optionsOrProfile = $this->buildFirefoxProfile($desiredCapabilities, $optionsOrProfile, $driverOptions);
}

Expand Down
6 changes: 6 additions & 0 deletions vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"vimeo/psalm": "^4.8",
"psalm/plugin-phpunit": "^0.16.1"
}
}

0 comments on commit c64d82e

Please sign in to comment.