Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ovanschie committed Jul 4, 2017
0 parents commit 6dcd0a1
Show file tree
Hide file tree
Showing 13 changed files with 297 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Crap
*.log
.sass-cache
.Spotlight-V100
.Trashes
.DS_Store
.DS_Store?
ehthumbs.db
Thumbs.db

# IDE
*.sublime-*
*.idea
.idea

# Project
build
composer.lock
docs
vendor
6 changes: 6 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
preset: laravel

linting: true

disabled:
- single_class_element_per_statement
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: php

php:
- 5.6
- 7.0
- 7.1

env:
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""

before_script:
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

script:
- php vendor/bin/phpunit --coverage-text
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License (MIT)

Copyright (c) Appstract

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Run Dusk tests in Opera

[![Latest Version on Packagist](https://img.shields.io/packagist/v/appstract/laravel-dusk-opera.svg?style=flat-square)](https://packagist.org/packages/appstract/laravel-dusk-opera)
[![Total Downloads](https://img.shields.io/packagist/dt/appstract/laravel-dusk-opera.svg?style=flat-square)](https://packagist.org/packages/appstract/laravel-dusk-opera)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/travis/appstract/laravel-dusk-opera/master.svg?style=flat-square)](https://travis-ci.org/appstract/laravel-dusk-opera)

This package allows you to use Opera Webdriver in Dusk, so you don't need Selenium to run Dusk tests in Opera.

This requires a recent version of Opera.

## Installation

You can install the package via composer:

``` bash
composer require appstract/laravel-dusk-opera
```

## Usage

Add the ``SupportsOpera`` trait to your DuskTestCase:
```php
use Appstract\DuskDrivers\Opera\SupportsOpera;

abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication, SupportsOpera;
```

Now you can start the server in the ```prepare``` method:
```php
public static function prepare()
{
static::startOperaDriver();
}
```

Instruct Dusk to use Opera by changing ```DesiredCapabilities::chrome()```
to ```DesiredCapabilities::opera()``` in the Driver method:

```php
protected function driver()
{
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::opera()
);
}
```

## Contributing

Contributions are welcome, [thanks to y'all](https://github.com/appstract/laravel-blade-directives/graphs/contributors) :)

## About Appstract

Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on [Medium](https://medium.com/appstract). You can [follow us on Twitter](https://twitter.com/teamappstract), [buy us a beer](https://www.paypal.me/teamappstract/10) or [support us on Patreon](https://www.patreon.com/appstract).

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
Binary file added bin/operadriver-linux
Binary file not shown.
Binary file added bin/operadriver-mac
Binary file not shown.
Binary file added bin/operadriver-win.exe
Binary file not shown.
32 changes: 32 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "appstract/laravel-dusk-opera",
"description": "Run Dusk tests in Opera",
"keywords": [
"appstract",
"laravel",
"Dusk",
"Opera",
"testing"
],
"homepage": "https://github.com/appstract/laravel-dusk-opera",
"license": "MIT",
"authors": [
{
"name": "Olav van Schie",
"email": "[email protected]",
"homepage": "https://appstract.team",
"role": "Developer"
}
],
"require": {
"php": ">=5.6"
},
"autoload": {
"psr-4": {
"Appstract\\DuskDrivers\\Opera\\": "src"
}
},
"config": {
"sort-packages": true
}
}
29 changes: 29 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Appstract Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
86 changes: 86 additions & 0 deletions src/SupportsOpera.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Appstract\DuskDrivers\Opera;

use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;

trait SupportsOpera
{
/**
* The OperaDriver process instance.
*/
protected static $operaProcess;

/**
* Start the Opera process.
*
* @return void
*/
public static function startOperaDriver()
{
static::$operaProcess = static::buildOperaProcess();

static::$operaProcess->start();

static::afterClass(function () {
static::stopOperaDriver();
});
}

/**
* Stop the Operadriver process.
*
* @return void
*/
public static function stopOperaDriver()
{
if (static::$operaProcess) {
static::$operaProcess->stop();
}
}

/**
* Build the process to run the Operadriver.
*
* @return \Symfony\Component\Process\Process
*/
protected static function buildOperaProcess()
{
return (new ProcessBuilder())
->setPrefix(realpath(__DIR__.'/../bin/operadriver-'.static::driverSuffix()))
->getProcess()
->setEnv(static::operaEnvironment());
}

/**
* Get the Chromedriver environment variables.
*
* @return array
*/
protected static function operaEnvironment()
{
if (PHP_OS === 'Darwin' || PHP_OS === 'WINNT') {
return [];
}

return ['DISPLAY' => ':0'];
}

/**
* Get the suffix for the Chromedriver binary.
*
* @return string
*/
protected static function driverSuffix()
{
switch (PHP_OS) {
case 'Darwin':
return 'mac';
case 'WINNT':
return 'win.exe';
default:
return 'linux';
}
}
}

0 comments on commit 6dcd0a1

Please sign in to comment.