From 8e2a2c46b173b809d5eb5985ae3576266369b75a Mon Sep 17 00:00:00 2001 From: "J. King" Date: Tue, 14 Feb 2017 22:34:08 -0500 Subject: [PATCH] Refactor test infrastructure to use PSR-4. --- composer.json | 6 +- composer.lock | 62 +-------------------- tests/TestConf.php | 3 +- tests/TestException.php | 2 +- tests/TestLang.php | 2 +- tests/TestLangErrors.php | 2 +- tests/{bootstrap.php => lib/Lang/Setup.php} | 24 ++------ tests/lib/Tools.php | 18 ++++++ tests/phpunit.xml | 2 +- tests/testLangComplex.php | 2 +- 10 files changed, 35 insertions(+), 88 deletions(-) rename tests/{bootstrap.php => lib/Lang/Setup.php} (68%) create mode 100644 tests/lib/Tools.php diff --git a/composer.json b/composer.json index 4630a33..0ced7af 100644 --- a/composer.json +++ b/composer.json @@ -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/" + } } } \ No newline at end of file diff --git a/composer.lock b/composer.lock index f0d6ddf..e0522d7 100644 --- a/composer.lock +++ b/composer.lock @@ -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", diff --git a/tests/TestConf.php b/tests/TestConf.php index aefd8b4..fbbacf6 100644 --- a/tests/TestConf.php +++ b/tests/TestConf.php @@ -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"); } } diff --git a/tests/TestException.php b/tests/TestException.php index 3689aca..902f328 100644 --- a/tests/TestException.php +++ b/tests/TestException.php @@ -4,7 +4,7 @@ namespace JKingWeb\NewsSync; class TestException extends \PHPUnit\Framework\TestCase { - use TestingHelpers; + use Test\Tools; static function setUpBeforeClass() { Lang::set(""); diff --git a/tests/TestLang.php b/tests/TestLang.php index 664bfab..9b81f53 100644 --- a/tests/TestLang.php +++ b/tests/TestLang.php @@ -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; diff --git a/tests/TestLangErrors.php b/tests/TestLangErrors.php index 67e69b7..0bc93c8 100644 --- a/tests/TestLangErrors.php +++ b/tests/TestLangErrors.php @@ -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; diff --git a/tests/bootstrap.php b/tests/lib/Lang/Setup.php similarity index 68% rename from tests/bootstrap.php rename to tests/lib/Lang/Setup.php index 865b15e..05fc316 100644 --- a/tests/bootstrap.php +++ b/tests/lib/Lang/Setup.php @@ -1,28 +1,14 @@ 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' => ' "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; diff --git a/tests/lib/Tools.php b/tests/lib/Tools.php new file mode 100644 index 0000000..ba2b353 --- /dev/null +++ b/tests/lib/Tools.php @@ -0,0 +1,18 @@ +expectException($class); + $this->expectExceptionCode($code); + } +} \ No newline at end of file diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 3278285..efe3398 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -1,7 +1,7 @@