mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-28 15:56:36 +00:00
create phpunit configuration and first tests
This commit is contained in:
parent
ce1653a5a7
commit
dd927ef981
@ -11,6 +11,11 @@
|
||||
"email": "arkadiusz.kondas@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"": "src/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
},
|
||||
|
14
phpunit.xml
Normal file
14
phpunit.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTestSize="true"
|
||||
beStrictAboutChangesToGlobalState="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="PHP-ML Test Suite">
|
||||
<directory>tests/*</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
@ -9,9 +9,9 @@ class InvalidArgumentException extends \Exception
|
||||
/**
|
||||
* @return InvalidArgumentException
|
||||
*/
|
||||
public static function parametersSizeNotMatch()
|
||||
public static function sizeNotMatch()
|
||||
{
|
||||
return new self('Size of parameters not match');
|
||||
return new self('Size of given arguments not match');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class Distance
|
||||
{
|
||||
if(count($a) != count($b))
|
||||
{
|
||||
throw InvalidArgumentException::parametersSizeNotMatch();
|
||||
throw InvalidArgumentException::sizeNotMatch();
|
||||
}
|
||||
|
||||
$distance = 0;
|
||||
|
18
tests/Phpml/Metric/DistanceTest.php
Normal file
18
tests/Phpml/Metric/DistanceTest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace tests\Phpml\Metric;
|
||||
|
||||
use Phpml\Metric\Distance;
|
||||
|
||||
class DistanceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Phpml\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testThrowExceptionOnInvalidArguments()
|
||||
{
|
||||
Distance::euclidean([0, 1, 2], [0, 2]);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user