mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Refactor test infrastructure to use PSR-4.
This commit is contained in:
parent
e44ba18d2d
commit
8e2a2c46b1
10 changed files with 35 additions and 88 deletions
|
@ -19,7 +19,6 @@
|
|||
],
|
||||
"require": {
|
||||
"php": "^7.0.0",
|
||||
"simplepie/simplepie": "^1.4.3",
|
||||
"jkingweb/druuid": "^3.0.0",
|
||||
"phpseclib/phpseclib": "^2.0.4",
|
||||
"webmozart/glob": "^4.1.0"
|
||||
|
@ -31,5 +30,10 @@
|
|||
"psr-4": {
|
||||
"JKingWeb\\NewsSync\\": "lib/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"JKingWeb\\NewsSync\\Test\\": "tests/lib/"
|
||||
}
|
||||
}
|
||||
}
|
62
composer.lock
generated
62
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"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": "334e725a6288a04515ca881b049ff2eb",
|
||||
"content-hash": "9170a3eabb0743990fa49f653a346eee",
|
||||
"packages": [
|
||||
{
|
||||
"name": "jkingweb/druuid",
|
||||
|
@ -143,66 +143,6 @@
|
|||
],
|
||||
"time": "2016-10-04T00:57:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "simplepie/simplepie",
|
||||
"version": "1.4.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/simplepie/simplepie.git",
|
||||
"reference": "2a24b6e74aa9bf33243020f52895fe77efe94ccf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/2a24b6e74aa9bf33243020f52895fe77efe94ccf",
|
||||
"reference": "2a24b6e74aa9bf33243020f52895fe77efe94ccf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4 || ~5"
|
||||
},
|
||||
"suggest": {
|
||||
"mf2/mf2": "Microformat module that allows for parsing HTML for microformats"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"SimplePie": "library"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ryan Parman",
|
||||
"homepage": "http://ryanparman.com/",
|
||||
"role": "Creator, alumnus developer"
|
||||
},
|
||||
{
|
||||
"name": "Geoffrey Sneddon",
|
||||
"homepage": "http://gsnedders.com/",
|
||||
"role": "Alumnus developer"
|
||||
},
|
||||
{
|
||||
"name": "Ryan McCue",
|
||||
"email": "me@ryanmccue.info",
|
||||
"homepage": "http://ryanmccue.info/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A simple Atom/RSS parsing library for PHP",
|
||||
"homepage": "http://simplepie.org/",
|
||||
"keywords": [
|
||||
"atom",
|
||||
"feeds",
|
||||
"rss"
|
||||
],
|
||||
"time": "2016-11-27T01:39:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
"version": "1.2.0",
|
||||
|
|
|
@ -5,7 +5,7 @@ use \org\bovigo\vfs\vfsStream;
|
|||
|
||||
|
||||
class TestConf extends \PHPUnit\Framework\TestCase {
|
||||
use TestingHelpers;
|
||||
use Test\Tools;
|
||||
|
||||
static $vfs;
|
||||
static $path;
|
||||
|
@ -100,7 +100,6 @@ class TestConf extends \PHPUnit\Framework\TestCase {
|
|||
*/
|
||||
function testImportFromCorruptFile() {
|
||||
$this->assertException("fileCorrupt", "Conf");
|
||||
// this should not print the output of the non-PHP file
|
||||
$conf = new Conf(self::$path."confCorrupt");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace JKingWeb\NewsSync;
|
|||
|
||||
|
||||
class TestException extends \PHPUnit\Framework\TestCase {
|
||||
use TestingHelpers;
|
||||
use Test\Tools;
|
||||
|
||||
static function setUpBeforeClass() {
|
||||
Lang::set("");
|
||||
|
|
|
@ -5,7 +5,7 @@ use \org\bovigo\vfs\vfsStream;
|
|||
|
||||
|
||||
class TestLang extends \PHPUnit\Framework\TestCase {
|
||||
use TestingHelpers, LanguageTestingHelpers;
|
||||
use Test\Tools, Test\Lang\Setup;
|
||||
|
||||
static $vfs;
|
||||
static $path;
|
||||
|
|
|
@ -5,7 +5,7 @@ use \org\bovigo\vfs\vfsStream;
|
|||
|
||||
|
||||
class TestLangErrors extends \PHPUnit\Framework\TestCase {
|
||||
use TestingHelpers, LanguageTestingHelpers;
|
||||
use Test\Tools, Test\Lang\Setup;
|
||||
|
||||
static $vfs;
|
||||
static $path;
|
||||
|
|
|
@ -1,28 +1,14 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace JKingWeb\NewsSync;
|
||||
require_once __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."bootstrap.php";
|
||||
namespace JKingWeb\NewsSync\Test\Lang;
|
||||
use \org\bovigo\vfs\vfsStream, \JKingWeb\NewsSync\Lang;
|
||||
|
||||
use \org\bovigo\vfs\vfsStream;
|
||||
|
||||
trait TestingHelpers {
|
||||
function assertException(string $msg, string $prefix = "", string $type = "Exception") {
|
||||
$class = NS_BASE . ($prefix !== "" ? str_replace("/", "\\", $prefix) . "\\" : "") . $type;
|
||||
$msgID = ($prefix !== "" ? $prefix . "/" : "") . $type. ".$msg";
|
||||
if(array_key_exists($msgID, Exception::CODES)) {
|
||||
$code = Exception::CODES[$msgID];
|
||||
} else {
|
||||
$code = 0;
|
||||
}
|
||||
$this->expectException($class);
|
||||
$this->expectExceptionCode($code);
|
||||
}
|
||||
}
|
||||
|
||||
trait LanguageTestingHelpers {
|
||||
trait Setup {
|
||||
static function setUpBeforeClass() {
|
||||
// this is required to keep from having exceptions in Lang::msg() in turn calling Lang::msg() and looping
|
||||
Lang\Exception::$test = true;
|
||||
\JKingWeb\NewsSync\Lang\Exception::$test = true;
|
||||
// test files
|
||||
self::$files = [
|
||||
'en.php' => '<?php return ["Test.presentText" => "and the Philosopher\'s Stone"];',
|
||||
|
@ -51,7 +37,7 @@ trait LanguageTestingHelpers {
|
|||
}
|
||||
|
||||
static function tearDownAfterClass() {
|
||||
Lang\Exception::$test = false;
|
||||
\JKingWeb\NewsSync\Lang\Exception::$test = false;
|
||||
Lang::$path = self::$defaultPath;
|
||||
self::$path = null;
|
||||
self::$vfs = null;
|
18
tests/lib/Tools.php
Normal file
18
tests/lib/Tools.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace JKingWeb\NewsSync\Test;
|
||||
use \JKingWeb\NewsSync\Exception;
|
||||
|
||||
trait Tools {
|
||||
function assertException(string $msg, string $prefix = "", string $type = "Exception") {
|
||||
$class = \JKingWeb\NewsSync\NS_BASE . ($prefix !== "" ? str_replace("/", "\\", $prefix) . "\\" : "") . $type;
|
||||
$msgID = ($prefix !== "" ? $prefix . "/" : "") . $type. ".$msg";
|
||||
if(array_key_exists($msgID, Exception::CODES)) {
|
||||
$code = Exception::CODES[$msgID];
|
||||
} else {
|
||||
$code = 0;
|
||||
}
|
||||
$this->expectException($class);
|
||||
$this->expectExceptionCode($code);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
bootstrap="bootstrap.php"
|
||||
bootstrap="../bootstrap.php"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
|
|
|
@ -5,7 +5,7 @@ use \org\bovigo\vfs\vfsStream;
|
|||
|
||||
|
||||
class TestLangComplex extends \PHPUnit\Framework\TestCase {
|
||||
use TestingHelpers, LanguageTestingHelpers;
|
||||
use Test\Tools, Test\Lang\Setup;
|
||||
|
||||
static $vfs;
|
||||
static $path;
|
||||
|
|
Loading…
Reference in a new issue