Add infrstructure required for tests
This commit is contained in:
parent
aa0d6ce20e
commit
9062f4e6a6
15 changed files with 3874 additions and 4 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
|||
vendor
|
||||
vendor/
|
||||
tests/coverage/
|
||||
.php_cs.cache
|
||||
|
||||
|
||||
# Windows files
|
||||
|
|
29
.php_cs.dist
Normal file
29
.php_cs.dist
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/** @license MIT
|
||||
* Copyright 2018 J. King et al.
|
||||
* See LICENSE and AUTHORS files for details */
|
||||
|
||||
namespace MensBeam\UTF8;
|
||||
|
||||
const BASE = __DIR__.DIRECTORY_SEPARATOR;
|
||||
|
||||
$paths = [
|
||||
__FILE__,
|
||||
BASE."RoboFile.php",
|
||||
BASE."lib",
|
||||
BASE."tests",
|
||||
];
|
||||
$rules = [
|
||||
'@PSR2' => true,
|
||||
'braces' => ['position_after_functions_and_oop_constructs' => "same"],
|
||||
];
|
||||
|
||||
$finder = \PhpCsFixer\Finder::create();
|
||||
foreach ($paths as $path) {
|
||||
if (is_file($path)) {
|
||||
$finder = $finder->append([$path]);
|
||||
} else {
|
||||
$finder = $finder->in($path);
|
||||
}
|
||||
}
|
||||
return \PhpCsFixer\Config::create()->setRules($rules)->setFinder($finder);
|
76
RoboFile.php
Normal file
76
RoboFile.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
use Robo\Result;
|
||||
|
||||
/**
|
||||
* This is project's console commands configuration for Robo task runner.
|
||||
*
|
||||
* @see http://robo.li/
|
||||
*/
|
||||
class RoboFile extends \Robo\Tasks {
|
||||
const BASE = __DIR__.\DIRECTORY_SEPARATOR;
|
||||
const BASE_TEST = self::BASE."tests".\DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Runs the full test suite
|
||||
*
|
||||
* Arguments passed to the task are passed on to PHPUnit. Thus one may, for
|
||||
* example, run the following command and get the expected results:
|
||||
*
|
||||
* ./robo test --testsuite TTRSS --exclude-group slow --testdox
|
||||
*
|
||||
* Please see the PHPUnit documentation for available options.
|
||||
*/
|
||||
public function test(array $args): Result {
|
||||
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
|
||||
$confpath = realpath(self::BASE_TEST."phpunit.xml");
|
||||
return $this->taskExec("php")->arg($execpath)->option("-c", $confpath)->args($args)->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the full test suite
|
||||
*
|
||||
* This is an alias of the "test" task.
|
||||
*/
|
||||
public function testFull(array $args): Result {
|
||||
return $this->test($args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a quick subset of the test suite
|
||||
*
|
||||
* See help for the "test" task for more details.
|
||||
*/
|
||||
public function testQuick(array $args): Result {
|
||||
return $this->test(array_merge(["--exclude-group", "slow,optional"], $args));
|
||||
}
|
||||
|
||||
/** Produces a code coverage report
|
||||
*
|
||||
* By default this task produces an HTML-format coverage report in
|
||||
* arsse/tests/coverage/. Additional reports may be produced by passing
|
||||
* arguments to this task as one would to PHPUnit.
|
||||
*
|
||||
* Robo first tries to use phpdbg and will fall back to Xdebug if available.
|
||||
* Because Xdebug slows down non-coverage tasks, however, phpdbg is highly
|
||||
* recommanded is debugging facilities are not otherwise needed.
|
||||
*/
|
||||
public function coverage(array $args): Result {
|
||||
// run tests with code coverage reporting enabled
|
||||
$exec = $this->findCoverageEngine();
|
||||
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
|
||||
$confpath = realpath(self::BASE_TEST."phpunit.xml");
|
||||
return $this->taskExec($exec)->arg($execpath)->option("-c", $confpath)->option("--coverage-html", self::BASE_TEST."coverage")->args($args)->run();
|
||||
}
|
||||
|
||||
protected function findCoverageEngine(): string {
|
||||
$null = null;
|
||||
$code = 0;
|
||||
exec("phpdbg --version", $null, $code);
|
||||
if (!$code) {
|
||||
return "phpdbg -qrr";
|
||||
} else {
|
||||
return "php";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,6 +15,14 @@
|
|||
"require": {
|
||||
"php": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-intl": "*",
|
||||
"bamarni/composer-bin-plugin": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"post-install-cmd": ["@composer bin all install"],
|
||||
"post-update-cmd": ["@composer bin all update"]
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"MensBeam\\UTF8\\": "lib/"
|
||||
|
|
48
composer.lock
generated
48
composer.lock
generated
|
@ -4,9 +4,49 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "8394b8ab5a816511b1fad1a40758b186",
|
||||
"content-hash": "5a5d645774a71daaee13b05eb2b172d0",
|
||||
"packages": [],
|
||||
"packages-dev": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "bamarni/composer-bin-plugin",
|
||||
"version": "v1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bamarni/composer-bin-plugin.git",
|
||||
"reference": "62fef740245a85f00665e81ea8f0aa0b72afe6e7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/62fef740245a85f00665e81ea8f0aa0b72afe6e7",
|
||||
"reference": "62fef740245a85f00665e81ea8f0aa0b72afe6e7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "dev-master",
|
||||
"symfony/console": "^2.5 || ^3.0"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"class": "Bamarni\\Composer\\Bin\\Plugin",
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Bamarni\\Composer\\Bin\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"time": "2017-09-11T13:13:58+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
|
@ -15,5 +55,7 @@
|
|||
"platform": {
|
||||
"php": "^7.0"
|
||||
},
|
||||
"platform-dev": []
|
||||
"platform-dev": {
|
||||
"ext-intl": "*"
|
||||
}
|
||||
}
|
||||
|
|
10
robo
Normal file
10
robo
Normal file
|
@ -0,0 +1,10 @@
|
|||
#! /bin/sh
|
||||
base=`dirname "$0"`
|
||||
roboCommand="$1"
|
||||
|
||||
shift
|
||||
if [ "$1" == "clean" ]; then
|
||||
"$base/vendor/bin/robo" "$roboCommand" $*
|
||||
else
|
||||
"$base/vendor/bin/robo" "$roboCommand" -- $*
|
||||
fi
|
21
robo.bat
Normal file
21
robo.bat
Normal file
|
@ -0,0 +1,21 @@
|
|||
@echo off
|
||||
setlocal
|
||||
set base=%~dp0
|
||||
set roboCommand=%1
|
||||
|
||||
rem get all arguments except the first
|
||||
shift
|
||||
set "args="
|
||||
:parse
|
||||
if "%~1" neq "" (
|
||||
set args=%args% %1
|
||||
shift
|
||||
goto :parse
|
||||
)
|
||||
if defined args set args=%args:~1%
|
||||
|
||||
if "%1"=="clean" (
|
||||
call "%base%vendor\bin\robo" "%roboCommand%" %args%
|
||||
) else (
|
||||
call "%base%vendor\bin\robo" "%roboCommand%" -- %args%
|
||||
)
|
13
tests/bootstrap.php
Normal file
13
tests/bootstrap.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/** @license MIT
|
||||
* Copyright 2018 J. King et al.
|
||||
* See LICENSE and AUTHORS files for details */
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace MensBeam\UTF8;
|
||||
|
||||
const NS_BASE = __NAMESPACE__."\\";
|
||||
define(NS_BASE."BASE", dirname(__DIR__).DIRECTORY_SEPARATOR);
|
||||
ini_set("memory_limit", "-1");
|
||||
error_reporting(\E_ALL);
|
||||
require_once BASE."vendor".DIRECTORY_SEPARATOR."autoload.php";
|
21
tests/phpunit.xml
Normal file
21
tests/phpunit.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
bootstrap="bootstrap.php"
|
||||
convertErrorsToExceptions="false"
|
||||
convertNoticesToExceptions="false"
|
||||
convertWarningsToExceptions="false"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTestSize="true"
|
||||
stopOnError="true">
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">../lib</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<testsuites>
|
||||
</testsuites>
|
||||
</phpunit>
|
5
vendor-bin/csfixer/composer.json
Normal file
5
vendor-bin/csfixer/composer.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"require": {
|
||||
"friendsofphp/php-cs-fixer": "^2.8"
|
||||
}
|
||||
}
|
1053
vendor-bin/csfixer/composer.lock
generated
Normal file
1053
vendor-bin/csfixer/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
5
vendor-bin/phpunit/composer.json
Normal file
5
vendor-bin/phpunit/composer.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"require": {
|
||||
"phpunit/phpunit": "^6.5"
|
||||
}
|
||||
}
|
1475
vendor-bin/phpunit/composer.lock
generated
Normal file
1475
vendor-bin/phpunit/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
5
vendor-bin/robo/composer.json
Normal file
5
vendor-bin/robo/composer.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"require": {
|
||||
"consolidation/robo": "^1.1"
|
||||
}
|
||||
}
|
1105
vendor-bin/robo/composer.lock
generated
Normal file
1105
vendor-bin/robo/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue