mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-26 06:46:45 +00:00
653c7c772d
* upgrade to PHP 7.1 * bump travis and composer to PHP 7.1 * fix tests
36 lines
909 B
PHP
36 lines
909 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace tests;
|
|
|
|
use Phpml\ModelManager;
|
|
use Phpml\Regression\LeastSquares;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ModelManagerTest extends TestCase
|
|
{
|
|
public function testSaveAndRestore(): void
|
|
{
|
|
$filename = uniqid();
|
|
$filepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.$filename;
|
|
|
|
$estimator = new LeastSquares();
|
|
$modelManager = new ModelManager();
|
|
$modelManager->saveToFile($estimator, $filepath);
|
|
|
|
$restored = $modelManager->restoreFromFile($filepath);
|
|
$this->assertEquals($estimator, $restored);
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Phpml\Exception\FileException
|
|
*/
|
|
public function testRestoreWrongFile(): void
|
|
{
|
|
$filepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'unexisting';
|
|
$modelManager = new ModelManager();
|
|
$modelManager->restoreFromFile($filepath);
|
|
}
|
|
}
|