add ExtractTune use case
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\AbcParser\Application\UseCases;
|
||||
|
||||
use XaiCorp\AbcParser\Application\UseCases\ImportAbcFile;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
|
||||
class ImportAbcFileTest extends \Codeception\Test\Unit
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return bool|string
|
||||
*/
|
||||
private function getAbc($filename = '/abc/valid_abc_1.abc')
|
||||
{
|
||||
return file_get_contents(codecept_data_dir($filename));
|
||||
}
|
||||
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$importer = ImportAbcFile::create();
|
||||
|
||||
$this->assertInstanceOf(ImportAbcFile::class, $importer);
|
||||
}
|
||||
|
||||
public function testCreateInjectingBuilder()
|
||||
{
|
||||
$builder = new Builder();
|
||||
$importer = ImportAbcFile::create($builder);
|
||||
|
||||
$this->assertInstanceOf(ImportAbcFile::class, $importer);
|
||||
}
|
||||
|
||||
public function testImport()
|
||||
{
|
||||
$abc = $this->getAbc('/abc/jigs.abc');
|
||||
$importer = ImportAbcFile::create();
|
||||
|
||||
$result = $importer->import($abc);
|
||||
|
||||
$this->assertInstanceOf(TuneCollection::class, $result);
|
||||
$this->assertGreaterThan(1, $result->count());
|
||||
}
|
||||
|
||||
public function testImport2FilesConsecutively()
|
||||
{
|
||||
$abc2 = $this->getAbc('/abc/valid_abc_2.abc');
|
||||
$abc3 = $this->getAbc('/abc/valid_abc_3.abc');
|
||||
$importer = ImportAbcFile::create();
|
||||
|
||||
$result1 = $importer->import($abc2);
|
||||
$result2 = $importer->import($abc3);
|
||||
|
||||
$this->assertNotEquals($result1, $result2);
|
||||
}
|
||||
|
||||
public function testImportMultiple()
|
||||
{
|
||||
$abc1 = $this->getAbc('/abc/valid_abc_1.abc');
|
||||
$abc2 = $this->getAbc('/abc/valid_abc_2.abc');
|
||||
$abc3 = $this->getAbc('/abc/valid_abc_3.abc');
|
||||
$importer = ImportAbcFile::create();
|
||||
|
||||
$result = $importer->importMultiple([$abc1, $abc2, $abc3]);
|
||||
|
||||
$this->assertInstanceOf(TuneCollection::class, $result);
|
||||
$this->assertGreaterThan(1, $result->count());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user