assertInstanceOf(Tune::class, $tune); } public function testCanIntializeFromArray() { $titles = ['Title']; $authors = ['Richard Morgan']; $config = [ 'Titles' => $titles, 'Authors' => $authors ]; $tune = new Tune($config); $this->assertInstanceOf(Tune::class, $tune); $this->assertEquals($tune->getTitles(), $titles); } 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]); } public function testMergeAddsExtraDataToTune() { $targetTune = new Tune([ 'titles' => ['target'] ]); $sourceTune = new Tune([ 'titles' => ['source'] ]); $result = $targetTune->merge($sourceTune); $this->assertEquals(new Tune([ 'titles' => ['target', 'source'] ]), $result); } }