More unittests
This commit is contained in:
parent
f4257b39e4
commit
3f63cad176
27
tests/Pipe/PipelineTest.php
Normal file
27
tests/Pipe/PipelineTest.php
Normal 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);
|
||||
}
|
||||
}
|
31
tests/Plugin/PluginManagerTest.php
Normal file
31
tests/Plugin/PluginManagerTest.php
Normal 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
3
tests/spark.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"preload": [ "./.spark/plugins/*" ]
|
||||
}
|
Loading…
Reference in New Issue
Block a user