More unittests

This commit is contained in:
Chris 2021-12-23 15:44:02 +01:00
parent f4257b39e4
commit 3f63cad176
3 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace Spark\Pipe;
class PipelineTest extends \PhpUnit\Framework\TestCase
{
/**
* @covers Pipeline::setInputFile
* @covers Pipeline::setOutputFile
* @covers Pipeline::run
*/
public function testPipingData()
{
$rand = random_bytes(1024);
file_put_contents("/tmp/rand.in", $rand);
$pipe = new Pipeline();
$pipe->setInputFile("/tmp/rand.in");
$pipe->setOutputFile("/tmp/rand.out");
$pipe->run();
$out = file_get_contents("/tmp/rand.out");
$this->assertEquals($rand, $out);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace Spark\Plugin;
use SparkPlug;
class PluginManagerTest extends \PhpUnit\Framework\TestCase
{
/**
* @covers PluginManager::registerPlugin
* @covers PluginManager::getPlugin
*/
public function testRegisteringAndFetchingPlugin()
{
$manager = new PluginManager();
$plugin = new TestPlugin();
$manager->registerPlugin('test.testplugin', $plugin);
$gplugin = $manager->getPlugin('test.testplugin');
$this->assertEquals($plugin, $gplugin);
}
}
class TestPlugin extends SparkPlug
{
public function load()
{}
}

3
tests/spark.json Normal file
View File

@ -0,0 +1,3 @@
{
"preload": [ "./.spark/plugins/*" ]
}