Skip to content

Commit

Permalink
set the correct PHPUnit setting
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Mar 6, 2018
1 parent 8cba64c commit a2f2f71
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
language: php
dist: trusty

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

before_script:
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
"wapmorgan\\FileTypeDetector\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"wapmorgan\\FileTypeDetector\\": "tests/"
}
},
"require-dev": {
"phpunit/phpunit": "~4.8.35"
"phpunit/phpunit": "^4.8"
}
}
14 changes: 14 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php" colors="true" backupGlobals="false"
backupStaticAttributes="false" syntaxCheck="false">
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
16 changes: 8 additions & 8 deletions src/Detector.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Detector {

const REG = 'reg';

static protected $aliases = array(
protected static $aliases = array(
'jpg' => self::JPEG,
'tif' => self::TIFF,
'mpg' => self::MPEG,
Expand All @@ -116,7 +116,7 @@ class Detector {
'mid' => self::MIDI,
);

static protected $extensions = array(
protected static $extensions = array(
'jpeg' => self::JPEG,
'bmp' => self::BMP,
'gif' => self::GIF,
Expand Down Expand Up @@ -194,7 +194,7 @@ class Detector {
'reg' => self::REG,
);

static protected $types = array(
protected static $types = array(
self::IMAGE => array(
self::JPEG,
self::BMP,
Expand Down Expand Up @@ -311,7 +311,7 @@ class Detector {
),
);

static protected $mimeTypes = array(
protected static $mimeTypes = array(
self::JPEG => 'image/jpeg',
self::BMP => 'image/bmp',
self::GIF => 'image/gif',
Expand Down Expand Up @@ -399,7 +399,7 @@ class Detector {
self::REG => 'text/plain',
);

static protected $signatures = [
protected static $signatures = [
// Images signatures
self::JPEG => [[0 => [0xFF, 0xD8, 0xFF, 0xE0]]],
self::BMP => [[0 => [0x42, 0x4D]]],
Expand Down Expand Up @@ -671,7 +671,7 @@ class Detector {
]
];

static public function detectByFilename($filename) {
public static function detectByFilename($filename) {
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
if (isset(self::$aliases[$ext])) $ext = self::$aliases[$ext];
if (isset(self::$extensions[$ext])) {
Expand All @@ -688,7 +688,7 @@ static public function detectByFilename($filename) {
return false;
}

static public function detectByContent($source) {
public static function detectByContent($source) {
$stream = new ContentStream($source);
foreach (self::$signatures as $format => $signatures) {
foreach ($signatures as $or_signature) {
Expand Down Expand Up @@ -729,7 +729,7 @@ static public function detectByContent($source) {
return false;
}

static public function getMimeType($file) {
public static function getMimeType($file) {
$format = self::detectByFilename($file) ?: self::detectByContent($file);
if ($format === false)
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/TerminalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class TerminalInfo {
const WIDTH = 1;
const HEIGHT = 2;
static public function isInteractive() {
public static function isInteractive() {
if (strncasecmp(PHP_OS, 'win', 3) === 0) {
// windows has no test for that
return true;
Expand All @@ -18,29 +18,29 @@ static public function isInteractive() {
}
}

static public function getWidth() {
public static function getWidth() {
if (strncasecmp(PHP_OS, 'win', 3) === 0) {
return self::getWindowsTerminalSize(self::WIDTH);
} else {
return self::getUnixTerminalSize(self::WIDTH);
}
}

static public function getHeight() {
public static function getHeight() {
if (strncasecmp(PHP_OS, 'win', 3) === 0) {
return self::getWindowsTerminalSize(self::HEIGHT);
} else {
return self::getUnixTerminalSize(self::HEIGHT);
}
}

static protected function getWindowsTerminalSize($param) {
protected static function getWindowsTerminalSize($param) {
$output = explode("\n", shell_exec('mode'));
$line = explode(':', trim($param == self::WIDTH ? $output[4] : $output[3]));
return trim($line[1]);
}

static protected function getUnixTerminalSize($param) {
protected static function getUnixTerminalSize($param) {
return trim(shell_exec('tput '.($param == self::WIDTH ? 'cols' : 'linus')));
}
}
5 changes: 2 additions & 3 deletions tests/DetectorTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php
namespace wapmorgan\test\FileTypeDetector;
require __DIR__.'/../vendor/autoload.php';

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use wapmorgan\FileTypeDetector\Detector;

class DetectorTest extends PHPUnit_Framework_TestCase {
class DetectorTest extends TestCase {
/**
* @dataProvider filenamesWithTypes()
*/
Expand Down

0 comments on commit a2f2f71

Please sign in to comment.