From afad6a5b0977a58f877b81cd0981a2bb75f4c77e Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 28 Apr 2016 01:01:04 +0300 Subject: [PATCH] Implemented Loader class and added reference repository (for now as git repo, in future - as composer package) --- composer.json | 18 ++++++++++++++++- src/Loader.php | 38 +++++++++++++++++++++++++++++++++++ tests/Loadertest.php | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/Loader.php create mode 100644 tests/Loadertest.php diff --git a/composer.json b/composer.json index 0c0285b..4055333 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name": "ely/php-tempmailbuster", "license": "MIT", + "type": "library", "authors": [ { "name": "ErickSkrauch", @@ -9,11 +10,26 @@ ], "require": { "php" : "~5.4|~7.0", - "lib-curl" : "*" + "lib-curl" : "*", + "ely/anti-tempmail-repo" : "*" }, "require-dev": { "phpunit/phpunit": "~4.8 || ~5.0" }, + "repositories": [ + { + "type": "package", + "package": { + "name": "ely/anti-tempmail-repo", + "version": "0.0.0", + "source": { + "url": "https://github.com/elyby/anti-tempmail-repo", + "type": "git", + "reference": "master" + } + } + } + ], "autoload": { "psr-4": { "Ely\\TempMailBuster\\": "src" diff --git a/src/Loader.php b/src/Loader.php new file mode 100644 index 0000000..1026c59 --- /dev/null +++ b/src/Loader.php @@ -0,0 +1,38 @@ +assertTrue(is_array(Loader::getPaths())); + } + + public function testLoad() + { + $this->assertTrue(is_array(Loader::load())); + } + + public function testLoadExceptionWrongPaths() + { + $this->expectException('Exception'); + LoaderWithWrongPaths::load(); + } + + public function testLoadExceptionInvalidJson() + { + $this->expectException('Exception'); + LoaderWithInvalidJson::load(); + } +} + +class LoaderWithWrongPaths extends Loader +{ + public static function getPaths() + { + return [ + __DIR__ . '/virtual_reality.json', + ]; + } +} + +class LoaderWithInvalidJson extends Loader +{ + public static function getPaths() + { + return [ + __DIR__ . '/LoaderTest.php', + ]; + } +}