Skip to content

Commit cf20ea7

Browse files
authored
Merge pull request #9 from OpenBuildings/phpunit-7
Upgrade to PHPUnit 7
2 parents bac4fc7 + 4c4dbf7 commit cf20ea7

17 files changed

Lines changed: 234 additions & 200 deletions

.php_cs.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ return Config::create()
6262
'space_before' => 'none',
6363
],
6464
'ternary_to_null_coalescing' => true,
65+
'yoda_style' => [
66+
'equal' => false,
67+
'identical' => false,
68+
'less_and_greater' => false,
69+
],
6570
])
6671
->setUsingCache(true)
6772
->setRiskyAllowed(true)

.travis.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ sudo: false
55

66
php:
77
- 7.1
8+
- 7.2
89

910
branches:
1011
only:
@@ -19,21 +20,16 @@ notifications:
1920
slack:
2021
secure: QDE52Y7qq+PEEy6xagZ/eIJ2pd/BCCq0quN41pl+iwKXO72dlNlLINuro0Mis/dNlzMrmdwKLDBsl+r0Kkqq6L7TpnnpziVX88fBvMl4PXxkfJJwSV0fiBcXBz1hJi9E/n22gOVvO1orUBMSVTx5IDzVAEssnzABrPshoReEejw=
2122

22-
addons:
23-
firefox: "31.0"
24-
2523
install: composer install --no-interaction
2624

25+
before_script:
26+
- mkdir -p build/logs
27+
- php -S localhost:9000 -t tests >/dev/null 2>&1 &
28+
2729
script:
2830
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml
2931
- vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --dry-run --diff --no-interaction --using-cache=no --path-mode=intersection `git diff --name-only --diff-filter=d $TRAVIS_COMMIT_RANGE`
3032

31-
before_script:
32-
- mkdir -p build/logs
33-
- "export DISPLAY=:99.0"
34-
- "sh -e /etc/init.d/xvfb start"
35-
- "nohup java -jar vendor/se/selenium-server-standalone/composer/bin/selenium-server-standalone.jar > /dev/null 2> /dev/null &"
36-
3733
after_script:
3834
- wget https://scrutinizer-ci.com/ocular.phar
3935
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml

README.md

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Code Coverage](https://scrutinizer-ci.com/g/OpenBuildings/phpunit-spiderling/badges/coverage.png?s=37d447d31d3dc3b4129e6e7c79a33c192f71c322)](https://scrutinizer-ci.com/g/OpenBuildings/phpunit-spiderling/)
66
[![Latest Stable Version](https://poser.pugx.org/openbuildings/phpunit-spiderling/v/stable.png)](https://packagist.org/packages/openbuildings/phpunit-spiderling)
77

8-
Heavily inspired by capybara [capybara](https://github.com/jnicklas/capybara). Using the [spiderling](https://github.com/OpenBuildings/spiderling) package to the fullest. It gives you the ability to quickly write integration test with powerful DSL and choose between different drivers with different combinations of features and performance - e.g. selenium, phanomjs or raw php with curl.
8+
Heavily inspired by capybara [capybara](https://github.com/jnicklas/capybara). Using the [spiderling](https://github.com/OpenBuildings/spiderling) package to the fullest. It gives you the ability to quickly write integration test with powerful DSL and choose between different drivers with different combinations of features and performance - e.g. phanomjs or raw php with curl.
99

1010
Example Test:
1111

@@ -112,7 +112,7 @@ use Openbuildings\PHPUnitSpiderling\TestCase;
112112
class SpiderlingTest extends TestCase {
113113

114114
/**
115-
* @driver selenium
115+
* @driver simple
116116
*/
117117
public function test_sample()
118118
{
@@ -130,46 +130,12 @@ class SpiderlingTest extends TestCase {
130130
}
131131
```
132132

133-
You can have different drivers for each test, the available ones are: ``simple``, ``kohana``, ``selenium`` and ``phantomjs`` - where the default driver is ``simple``. Each driver is loaded with the default configuration, but you can change it by modifying the appropriate method that loads the driver
133+
You can have different drivers for each test, the available ones are: ``simple``, ``kohana`` and ``phantomjs`` - where the default driver is ``simple``. Each driver is loaded with the default configuration, but you can change it by modifying the appropriate method that loads the driver
134134

135135
- driver_simple() - will return Driver_Simple object
136136
- driver_kohana() - will return Driver_Kohana object
137-
- driver_selenium() - will return Driver_Selenium object
138137
- driver_phantomjs() - will return Driver_Phantomjs object
139138

140-
It is recommended that you create a base TestCase class in your tests if you want to extend these methods and have your relevant class extend that class for example if we had selenium running on a different server than localhost we might do something like this:
141-
142-
```php
143-
use Openbuildings\PHPUnitSpiderling\TestCase;
144-
use Openbuildings\Spiderling\Driver_Selenium;
145-
use Openbuildings\Spiderling\Driver_Selenium_Connection;
146-
147-
abstract class TestCase_Selenium extends TestCase {
148-
149-
public function driver_selenium()
150-
{
151-
$connection = new Driver_Selenium_Connection('http://selenium-server.example.com/web/hub/');
152-
return new Driver_Selenium($connection);
153-
}
154-
}
155-
```
156-
157-
And then you would:
158-
159-
```php
160-
161-
class IntegrationTest extends TestCase_Selenium {
162-
163-
/**
164-
* @driver selenium
165-
*/
166-
public function test_sample()
167-
{
168-
// ...
169-
}
170-
}
171-
```
172-
173139
## Save on failure
174140

175141
There is a special testcase listener class included that saves the state of the test when there is a failure, and saves it as an html page for ease referance later. This is the ``Saveonfailure`` class. In order to use it, you'll need to modify your phpunit.xml like this:

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
}
1111
],
1212
"require" : {
13+
"php": "^7.1",
1314
"openbuildings/spiderling": "^0.2",
1415
"openbuildings/environment-backup": "^0.1",
1516
"phpunit/phpunit": "^7"
1617
},
1718
"require-dev": {
18-
"se/selenium-server-standalone": "~2.43.0",
19-
"friendsofphp/php-cs-fixer": "^2.1"
19+
"friendsofphp/php-cs-fixer": "^2.1",
20+
"kohana/core": "^3.3"
2021
},
2122
"autoload": {
2223
"psr-4": {"Openbuildings\\PHPUnitSpiderling\\": "src/"}
2324
},
2425
"autoload-dev": {
25-
"psr-4": {"Openbuildings\\PHPUnitSpiderling\\Test\\": "tests/"}
26+
"psr-4": {"Openbuildings\\PHPUnitSpiderling\\Test\\": "tests/"},
27+
"psr-0": {"": "vendor/kohana/core/classes/"},
28+
"files": ["tests/kohana_constants.php"]
2629
}
2730
}

composer.lock

Lines changed: 74 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml.dist

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<phpunit colors="true" bootstrap="vendor/autoload.php">
2-
<testsuites>
3-
<testsuite>
4-
<directory>tests</directory>
5-
</testsuite>
6-
</testsuites>
7-
<filter>
8-
<whitelist>
9-
<directory suffix=".php">src</directory>
10-
</whitelist>
11-
<blacklist>
12-
<directory suffix=".php">vendor/</directory>
13-
<directory suffix=".php">tests/</directory>
14-
</blacklist>
15-
</filter>
2+
<testsuites>
3+
<testsuite name="all">
4+
<directory>tests</directory>
5+
</testsuite>
6+
</testsuites>
7+
<filter>
8+
<whitelist>
9+
<directory suffix=".php">src</directory>
10+
</whitelist>
11+
</filter>
12+
<listeners>
13+
<listener class="Openbuildings\PHPUnitSpiderling\SaveOnFailure">
14+
<arguments>
15+
<string>var/</string>
16+
<string>file:///</string>
17+
</arguments>
18+
</listener>
19+
</listeners>
1620
</phpunit>

0 commit comments

Comments
 (0)