Add some semblance of testing.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,5 @@ parameters:
|
||||
bin_dir: vendor/bin
|
||||
tasks:
|
||||
phpcsfixer2:
|
||||
config: .php_cs
|
||||
config: .php_cs
|
||||
phpunit: ~
|
||||
|
||||
8
phpunit.xml
Normal file
8
phpunit.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd">
|
||||
<testsuite name="main">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</phpunit>
|
||||
29
tests/ConfigurationTest.php
Normal file
29
tests/ConfigurationTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace tests\FooBar;
|
||||
|
||||
use FooBar\Configuration;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ConfigurationTest extends TestCase
|
||||
{
|
||||
public function testDefaultSecurity()
|
||||
{
|
||||
$config = $this->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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user