Fix the failing unit tests
refactor the codestyle for the tests we wanted to keep
This commit is contained in:
156
tests/unit/arr/AbcCest.php
Normal file
156
tests/unit/arr/AbcCest.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Arr;
|
||||
|
||||
use UnitTester;
|
||||
use XaiCorp\AbcParser\Models\Arr\Abc;
|
||||
use XaiCorp\AbcParser\Parser;
|
||||
|
||||
class AbcCest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $dataDir;
|
||||
|
||||
/**
|
||||
* @var \XaiCorp\AbcParser\Interfaces\Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
/**
|
||||
* @var Parser;
|
||||
*/
|
||||
protected $parser;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dataDir = codecept_data_dir();
|
||||
}
|
||||
|
||||
public function _before(UnitTester $I)
|
||||
{
|
||||
$this->builder = new Abc();
|
||||
}
|
||||
|
||||
public function _after(UnitTester $I)
|
||||
{
|
||||
unset($builder);
|
||||
}
|
||||
|
||||
// tests: trying to...
|
||||
public function createParser(UnitTester $I)
|
||||
{
|
||||
$parser = new Parser($this->builder);
|
||||
|
||||
$I->assertInstanceOf(Parser::class, $parser);
|
||||
}
|
||||
|
||||
public function seeParseEmptyAbcWithoutErrors(UnitTester $I)
|
||||
{
|
||||
$abc = '';
|
||||
$parser = new Parser($this->builder);
|
||||
|
||||
$result = $parser->parseABC($abc);
|
||||
$I->assertEmpty($result);
|
||||
}
|
||||
|
||||
public function seeParseABCExample1(UnitTester $I)
|
||||
{
|
||||
$abc = file_get_contents($this->dataDir . '/abc/valid_abc_1.abc');
|
||||
$parser = new Parser($this->builder);
|
||||
$expected = [
|
||||
1 => [
|
||||
'X' => '3',
|
||||
'M' => '4/4',
|
||||
'K' => 'C',
|
||||
'music' => 'gaab babc :|',
|
||||
],
|
||||
];
|
||||
|
||||
$result = $parser->parseABC($abc);
|
||||
$I->assertNotEmpty($result);
|
||||
|
||||
$I->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function seeParseABCExample2(UnitTester $I)
|
||||
{
|
||||
$abc = file_get_contents($this->dataDir . '/abc/valid_abc_2.abc');
|
||||
$parser = new Parser($this->builder);
|
||||
$expected = [
|
||||
1 => [
|
||||
'X' => '40',
|
||||
'T' => ['Abbotts Bromley Horn Dance'],
|
||||
'A' => ['trad'],
|
||||
'C' => ['trad.'],
|
||||
'D' => ['None'],
|
||||
'G' => ['lute'],
|
||||
'H' => [
|
||||
'Thousand year old tradition',
|
||||
'The Horns live in the church and are removed for the dance once a year',
|
||||
],
|
||||
'R' => ['Jig'],
|
||||
'F' => ['none.abc'],
|
||||
'B' => ['Traditional English tunes'],
|
||||
'W' => ['None'],
|
||||
'Q' => '1/8=80',
|
||||
'L' => '1/8',
|
||||
'M' => '6/8',
|
||||
'N' => ['Traditional English'],
|
||||
'O' => ['England'],
|
||||
'Z' => ['Andy Hornby'],
|
||||
'S' => ['http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html'],
|
||||
'P' => 'ABC',
|
||||
'K' => 'G',
|
||||
'music' => 'e|B2e G2e|B2e E2G|FGA GAB|1AGF G2:|2AGF E2|
|
||||
|e|c2e cde|A2c ABc|FGA GFE|_E=EF B,2g|
|
||||
e2g efg|c2e cde|dcB AGF|E3E2
|
||||
|:A|BcB e3|BcB f3|BcB AGF|1G2F G2:|2E3-E2|]',
|
||||
],
|
||||
];
|
||||
|
||||
$result = $parser->parseABC($abc);
|
||||
$I->assertNotEmpty($result);
|
||||
|
||||
$I->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
|
||||
public function seeParseABCExample3(UnitTester $I)
|
||||
{
|
||||
$abc = file_get_contents($this->dataDir . '/abc/valid_abc_3.abc');
|
||||
$parser = new Parser($this->builder);
|
||||
$expected = [
|
||||
'A' => ['trad'],
|
||||
'C' => ['trad.'],
|
||||
'D' => ['None'],
|
||||
'H' => [
|
||||
'Thousand year old tradition',
|
||||
'The Horns live in the church and are removed for the dance once a year',
|
||||
],
|
||||
'R' => ['Jig'],
|
||||
'F' => ['none.abc'],
|
||||
'B' => ['Traditional English tunes'],
|
||||
'L' => '1/8',
|
||||
'M' => '6/8',
|
||||
'N' => ['Traditional English'],
|
||||
'O' => ['England'],
|
||||
'S' => ['http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html'],
|
||||
'Z' => ['Andy Hornby'],
|
||||
|
||||
1 => [
|
||||
'X' => '3',
|
||||
'M' => '4/4',
|
||||
'K' => 'C',
|
||||
'music' => 'gaab babc :|',
|
||||
'T' => ['Short and Sweet']
|
||||
],
|
||||
];
|
||||
|
||||
$result = $parser->parseABC($abc);
|
||||
$I->assertNotEmpty($result);
|
||||
|
||||
$I->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user