finished default parser
This commit is contained in:
171
tests/unit/AbcParser/Domain/Core/TuneTest.php
Normal file
171
tests/unit/AbcParser/Domain/Core/TuneTest.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: richard
|
||||
* Date: 11/19/17
|
||||
* Time: 10:09 PM
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\AbcParser\Domain\Core;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use Webpatser\Uuid\Uuid;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\EmailAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Core\Author;
|
||||
use XaiCorp\AbcParser\Domain\Core\Composer;
|
||||
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||
use XaiCorp\AbcParser\Domain\Core\Setting;
|
||||
|
||||
class TuneTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$params = [];
|
||||
|
||||
$tune = new Tune($params);
|
||||
|
||||
$this->assertInstanceOf(Tune::class, $tune);
|
||||
}
|
||||
|
||||
public function testNewTuneHasIdentitySet()
|
||||
{
|
||||
$params = [];
|
||||
|
||||
$tune = new Tune($params);
|
||||
|
||||
$result = $tune->identity();
|
||||
|
||||
$this->assertInstanceOf(Uuid::class, $result);
|
||||
}
|
||||
|
||||
public function testGetIndexReturnsInteger1AsDefault()
|
||||
{
|
||||
$tune = new Tune([]);
|
||||
|
||||
$result = $tune->getIndex();
|
||||
|
||||
$this->assertInternalType('integer', $result);
|
||||
$this->assertEquals(1, $result);
|
||||
}
|
||||
|
||||
public function testSetIndex()
|
||||
{
|
||||
$value = 12;
|
||||
$tune = new Tune([]);
|
||||
$tune->setIndex(new UnsignedIntegerAtom($value));
|
||||
|
||||
$result = $tune->getIndex();
|
||||
|
||||
$this->assertEquals($value, $result);
|
||||
}
|
||||
|
||||
public function testGetTitlesIsEmptyOnNewTune()
|
||||
{
|
||||
$tune = new Tune([]);
|
||||
|
||||
$result = $tune->getTitles();
|
||||
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testAppendTitleAddsOneTitle()
|
||||
{
|
||||
$newTitle = 'New Title';
|
||||
$tune = new Tune([]);
|
||||
$tune->addTitle($newTitle);
|
||||
|
||||
$result = $tune->getTitles();
|
||||
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($newTitle, $result[0]);
|
||||
}
|
||||
|
||||
public function testAddAuthor()
|
||||
{
|
||||
$authorName = new StringAtom('Bob');
|
||||
$authorEmail = new EmailAtom('me@example.com');
|
||||
$author = new Author($authorName, $authorEmail);
|
||||
$tune = new Tune([]);
|
||||
$tune->addAuthor($author);
|
||||
|
||||
$result = $tune->getAuthors();
|
||||
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($author, $result[0]);
|
||||
}
|
||||
|
||||
public function testAddComposer()
|
||||
{
|
||||
$composerName = new StringAtom('Bob');
|
||||
$authorEmail = new EmailAtom('me@example.com');
|
||||
$composer = new Composer($composerName, $authorEmail);
|
||||
$tune = new Tune([]);
|
||||
$tune->addComposer($composer);
|
||||
|
||||
$result = $tune->getComposers();
|
||||
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($composer, $result[0]);
|
||||
}
|
||||
|
||||
public function testAddGroup()
|
||||
{
|
||||
$group = 'flutes';
|
||||
$tune = new Tune([]);
|
||||
$tune->addGroup($group);
|
||||
|
||||
$result = $tune->getGroups();
|
||||
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($group, $result[0]);
|
||||
}
|
||||
|
||||
public function testAddHistoryLine()
|
||||
{
|
||||
$historyLine = 'The works of Shakespeare';
|
||||
$tune = new Tune([]);
|
||||
$tune->addHistoryLine($historyLine);
|
||||
|
||||
$result = $tune->getHistory();
|
||||
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($historyLine, $result[0]);
|
||||
}
|
||||
|
||||
public function testAddOrigin()
|
||||
{
|
||||
$origin = 'Yorkshire';
|
||||
$tune = new Tune([]);
|
||||
$tune->addOrigin($origin);
|
||||
|
||||
$result = $tune->getOrigins();
|
||||
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($origin, $result[0]);
|
||||
}
|
||||
|
||||
public function testAddRhythm()
|
||||
{
|
||||
$rhythm = 'reel';
|
||||
$tune = new Tune([]);
|
||||
$tune->addRhythm($rhythm);
|
||||
|
||||
$result = $tune->getRhythms();
|
||||
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($rhythm, $result[0]);
|
||||
}
|
||||
|
||||
public function testSetting()
|
||||
{
|
||||
$setting = new Setting();
|
||||
$tune = new Tune([]);
|
||||
$tune->addSetting($setting);
|
||||
|
||||
$result = $tune->getSettings();
|
||||
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($setting, $result[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user