diff --git a/composer.json b/composer.json index 881afd1..9af051c 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,17 @@ }, "require-dev": { "phpro/grumphp": "^0.15.0", - "friendsofphp/php-cs-fixer": "^2.14" + "friendsofphp/php-cs-fixer": "^2.14", + "phpunit/phpunit": "^8.0" }, "autoload": { "psr-4": { "FooBar\\": "src/" } + }, + "autoload-dev": { + "psr-4": { + "FooBar\\tests\\": "tests" + } } } diff --git a/grumphp.yml b/grumphp.yml index 596a5ef..190300a 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -3,4 +3,5 @@ parameters: bin_dir: vendor/bin tasks: phpcsfixer2: - config: .php_cs \ No newline at end of file + config: .php_cs + phpunit: ~ diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..2072321 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,8 @@ + + + + tests + + diff --git a/tests/ConfigurationTest.php b/tests/ConfigurationTest.php new file mode 100644 index 0000000..c341e80 --- /dev/null +++ b/tests/ConfigurationTest.php @@ -0,0 +1,29 @@ +getSampleConfig(); + + $this->assertTrue($config->isAuthorized('127.0.0.1')); + $this->assertFalse($config->isAuthorized('8.8.8.8')); + } + + public function testLoadConfig() + { + $this->assertNotNull(Configuration::loadConfig()); + } + + private function getSampleConfig(): Configuration + { + $path = dirname(__DIR__) . '/config/config.sample.php'; + + return new Configuration(require $path); + } +}