|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace CyrilVerloop\Codingame\Tests\Training\Expert\MusicScores; |
| 6 | + |
| 7 | +use CyrilVerloop\Codingame\Tests\PuzzleTest; |
| 8 | +use CyrilVerloop\Codingame\Training\Expert\MusicScores\MusicScores; |
| 9 | + |
| 10 | +/** |
| 11 | + * Tests for the "MusicScores" puzzle. |
| 12 | + * |
| 13 | + * @covers \CyrilVerloop\Codingame\Training\Expert\MusicScores\MusicScores |
| 14 | + * @group musicScores |
| 15 | + */ |
| 16 | +final class MusicScoresTest extends PuzzleTest |
| 17 | +{ |
| 18 | + public function setUp(): void |
| 19 | + { |
| 20 | + $this->puzzle = new MusicScores(); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Test that the code can be executed for "One quarter note between lines". |
| 25 | + * |
| 26 | + * @group musicScores_oneQuarterNoteBetweenLines |
| 27 | + */ |
| 28 | + public function testCanExecuteOneQuarterNoteBetweenLines(): void |
| 29 | + { |
| 30 | + $this->expectExecuteOutputAnswer( |
| 31 | + __DIR__ . '/input/01 - one quarter note between lines.txt', |
| 32 | + 'AQ' . PHP_EOL |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Test that the code can be executed for "One quarter note on a line". |
| 38 | + * |
| 39 | + * @group musicScores_oneQuarterNoteOnALine |
| 40 | + */ |
| 41 | + public function testCanExecuteOneQuarterNoteOnALine(): void |
| 42 | + { |
| 43 | + $this->expectExecuteOutputAnswer( |
| 44 | + __DIR__ . '/input/02 - one quarter note on a line.txt', |
| 45 | + 'BQ' . PHP_EOL |
| 46 | + ); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Test that the code can be executed for "One half note between lines". |
| 51 | + * |
| 52 | + * @group musicScores_oneHalfNoteBetweenLines |
| 53 | + */ |
| 54 | + public function testCanExecuteOneHalfNoteBetweenLines(): void |
| 55 | + { |
| 56 | + $this->expectExecuteOutputAnswer( |
| 57 | + __DIR__ . '/input/03 - one half note between lines.txt', |
| 58 | + 'AH' . PHP_EOL |
| 59 | + ); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Test that the code can be executed for "One half note on a line". |
| 64 | + * |
| 65 | + * @group musicScores_oneHalfNoteOnALine |
| 66 | + */ |
| 67 | + public function testCanExecuteOneHalfNoteOnALine(): void |
| 68 | + { |
| 69 | + $this->expectExecuteOutputAnswer( |
| 70 | + __DIR__ . '/input/04 - one half note on a line.txt', |
| 71 | + 'BH' . PHP_EOL |
| 72 | + ); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Test that the code can be executed for "Only quarter notes without lower C". |
| 77 | + * |
| 78 | + * @group musicScores_onlyQuarterNotesWithoutLowerC |
| 79 | + */ |
| 80 | + public function testCanExecuteOnlyQuarterNotesWithoutLowerC(): void |
| 81 | + { |
| 82 | + $this->expectExecuteOutputAnswer( |
| 83 | + __DIR__ . '/input/05 - only quarter notes without lower C.txt', |
| 84 | + 'CQ CQ CQ CQ DQ EQ CQ AQ' . PHP_EOL |
| 85 | + ); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Test that the code can be executed for "Only half notes without lower C". |
| 90 | + * |
| 91 | + * @group musicScores_onlyHalfNotesWithoutLowerC |
| 92 | + */ |
| 93 | + public function testCanExecuteOnlyHalfNotesWithoutLowerC(): void |
| 94 | + { |
| 95 | + $this->expectExecuteOutputAnswer( |
| 96 | + __DIR__ . '/input/06 - only half notes without lower C.txt', |
| 97 | + 'DH EH FH AH CH EH DH' . PHP_EOL |
| 98 | + ); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Test that the code can be executed for "Scale half and quarter notes". |
| 103 | + * |
| 104 | + * @group musicScores_scalehalfAndQuarterNotes |
| 105 | + */ |
| 106 | + public function testCanExecuteScalehalfAndQuarterNotes(): void |
| 107 | + { |
| 108 | + $this->expectExecuteOutputAnswer( |
| 109 | + __DIR__ . '/input/07 - scale half and quarter notes.txt', |
| 110 | + 'EQ FH GQ AH BQ CH DQ EH FQ' . PHP_EOL |
| 111 | + ); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Test that the code can be executed for "Lower C". |
| 116 | + * |
| 117 | + * @group musicScores_lowerC |
| 118 | + */ |
| 119 | + public function testCanExecuteLowerC(): void |
| 120 | + { |
| 121 | + $this->expectExecuteOutputAnswer( |
| 122 | + __DIR__ . '/input/08 - lower C.txt', |
| 123 | + 'CQ CQ CQ DQ EH DH CQ EQ DQ DQ CH' . PHP_EOL |
| 124 | + ); |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Test that the code can be executed for "Very close". |
| 129 | + * |
| 130 | + * @group musicScores_veryClose |
| 131 | + */ |
| 132 | + public function testCanExecuteVeryClose(): void |
| 133 | + { |
| 134 | + $this->expectExecuteOutputAnswer( |
| 135 | + __DIR__ . '/input/09 - very close.txt', |
| 136 | + 'BQ CH DH EH FQ GQ GQ BQ DH BQ' . PHP_EOL |
| 137 | + ); |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * Test that the code can be executed for "Only 1 pixel wide". |
| 142 | + * |
| 143 | + * @group musicScores_only1PixelWide |
| 144 | + */ |
| 145 | + public function testCanExecuteOnly1PixelWide(): void |
| 146 | + { |
| 147 | + $this->expectExecuteOutputAnswer( |
| 148 | + __DIR__ . '/input/10 - Only 1 pixel wide.txt', |
| 149 | + 'BQ CH DH EH FQ GQ GQ BQ DH BQ BQ CH DH EH FQ GQ GQ BQ DH BQ' . PHP_EOL |
| 150 | + ); |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * Test that the code can be executed for "Doctor Who theme". |
| 155 | + * |
| 156 | + * @group musicScores_doctorWhoTheme |
| 157 | + */ |
| 158 | + public function testCanExecuteDoctorWhoTheme(): void |
| 159 | + { |
| 160 | + $this->expectExecuteOutputAnswer( |
| 161 | + __DIR__ . '/input/11 - doctor Who theme.txt', |
| 162 | + file_get_contents(__DIR__ . '/output/11 - doctor Who theme.txt') |
| 163 | + ); |
| 164 | + } |
| 165 | + |
| 166 | + /** |
| 167 | + * Test that the code can be executed for "Random". |
| 168 | + * |
| 169 | + * @group musicScores_random |
| 170 | + */ |
| 171 | + public function testCanExecuteRandom(): void |
| 172 | + { |
| 173 | + $this->expectExecuteOutputAnswer( |
| 174 | + __DIR__ . '/input/12 - random.txt', |
| 175 | + file_get_contents(__DIR__ . '/output/12 - random.txt') |
| 176 | + ); |
| 177 | + } |
| 178 | +} |
0 commit comments