php-ml/tests/Phpml/ModelManagerTest.php
Marcin Michalski 3ac658c397 php-cs-fixer - more rules (#118)
* Add new cs-fixer rules and run them

* Do not align double arrows/equals
2017-08-17 08:50:37 +02:00

36 lines
897 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()
{
$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()
{
$filepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'unexisting';
$modelManager = new ModelManager();
$modelManager->restoreFromFile($filepath);
}
}