Additional test

This commit is contained in:
Jens True 2024-01-16 07:46:32 +00:00
parent 61e7b8dd49
commit 09ee4534e5
3 changed files with 44 additions and 11 deletions

22
composer.lock generated

@ -1197,16 +1197,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.10.55", "version": "1.10.56",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949" "reference": "27816a01aea996191ee14d010f325434c0ee76fa"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/27816a01aea996191ee14d010f325434c0ee76fa",
"reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", "reference": "27816a01aea996191ee14d010f325434c0ee76fa",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1255,7 +1255,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-01-08T12:32:40+00:00" "time": "2024-01-15T10:43:00+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -1580,16 +1580,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "10.5.5", "version": "10.5.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856" "reference": "e5c5b397a95cb0db013270a985726fcae93e61b8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed21115d505b4b4f7dc7b5651464e19a2c7f7856", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e5c5b397a95cb0db013270a985726fcae93e61b8",
"reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856", "reference": "e5c5b397a95cb0db013270a985726fcae93e61b8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1661,7 +1661,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy", "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.5" "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.7"
}, },
"funding": [ "funding": [
{ {
@ -1677,7 +1677,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-12-27T15:13:52+00:00" "time": "2024-01-14T16:40:30+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",

@ -4,6 +4,7 @@ namespace DNW\Skills\Tests;
use DNW\Skills\Guard; use DNW\Skills\Guard;
use Exception; use Exception;
class GuardTest extends TestCase class GuardTest extends TestCase
{ {
public function testArgumentNotNull(): void public function testArgumentNotNull(): void

32
tests/RatingTest.php Normal file

@ -0,0 +1,32 @@
<?php
namespace DNW\Skills\Tests;
use DNW\Skills\Rating;
class RatingTest extends TestCase
{
public function testGetRatingParameters(): void
{
$rating = new Rating(100, 10, 5);
$this->assertEquals(100, $rating->getMean());
$this->assertEquals(10, $rating->getStandardDeviation());
$this->assertEquals(50, $rating->getConservativeRating());
$this->assertEquals("mean=100.0000, standardDeviation=10.0000", (string)$rating);
}
public function testPartialUpdate(): void
{
$rating = new Rating(100, 10, 5);
$rating_prior = new Rating(100, 10, 5);
$rating_new = new Rating(200, 10, 5);
$rating_partial = $rating ->getPartialUpdate($rating_prior, $rating_new, 0.5);
$this->assertEquals(150, $rating_partial->getMean());
$this->assertEquals(10, $rating_partial->getStandardDeviation());
$this->assertEquals(100, $rating_partial->getConservativeRating());
$this->assertEquals("mean=150.0000, standardDeviation=10.0000", (string)$rating_partial);
}
}