Skip to content
This repository has been archived by the owner on Mar 15, 2020. It is now read-only.

Commit

Permalink
Harden tests (#22)
Browse files Browse the repository at this point in the history
- Tweak Travis config: improve the composer install step, add support for new PHP versions and fix the config for PHP 5.3
- Adjust the current version for PHPUnit, and PHP.
- Use vfsStream to mock the file system.
  • Loading branch information
peter279k authored and theofidry committed Feb 8, 2018
1 parent 6e6c47a commit 50e137d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
language: php

php:
- '5.3'
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- nightly

matrix:
include:
- php: 5.3
dist: precise
fast_finish: true
allow_failures:
- php: nightly
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
],

"require": {
"php": "^5.3 || ^7.0",
"php": "^5.3 || ^7.0 || ^7.1 || ^7.2",
"ext-openssl": "*",
"composer/ca-bundle": "^1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.1",
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0"
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5",
"mikey179/vfsStream": "^1.6"
},

"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<filter>
<whitelist>
<directory>./src/Humbug/</directory>
<directory>./src/</directory>
</whitelist>
</filter>

Expand Down
15 changes: 5 additions & 10 deletions tests/Humbug/Test/FunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@
namespace Humbug\Test;

use PHPUnit\Framework\TestCase;
use org\bovigo\vfs\vfsStream;

if (!class_exists('\PHPUnit\Framework\TestCase', true)) {
class_alias('\PHPUnit_Framework_TestCase', 'TestCase');
}

/**
* @coversNothing
*/
class FunctionTest extends TestCase
{
private static $result;

public function setup()
{
vfsStream::setup('home_root_path');
if (null === self::$result) {
$result = humbug_get_contents('https://www.howsmyssl.com/a/check');
self::$result = json_decode($result, true);
Expand All @@ -34,7 +29,7 @@ public function setup()

public function teardown()
{
@unlink(sys_get_temp_dir() . '/humbug.tmp');
self::$result = null;
}

public function testRating()
Expand Down Expand Up @@ -69,8 +64,8 @@ public function testUnknownCipherSuites()

public function testFileGetContentsWillPassThrough()
{
file_put_contents(sys_get_temp_dir() . '/humbug.tmp', ($expected = uniqid()), LOCK_EX);
$this->assertEquals(file_get_contents(sys_get_temp_dir() . '/humbug.tmp'), $expected);
file_put_contents(vfsStream::url('home_root_path/humbug.tmp'), ($expected = uniqid()));
$this->assertEquals(file_get_contents(vfsStream::url('home_root_path/humbug.tmp')), $expected);
}

public function testCanGetResponseHeaders()
Expand Down

0 comments on commit 50e137d

Please sign in to comment.